aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/x86_64
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-03-22 00:05:02 +0000
committerRoland McGrath <roland@gnu.org>2003-03-22 00:05:02 +0000
commit002ff853059c14c55188a6cbe4fdbc4baa06219e (patch)
treeae49701bf87c2efccb8c954276c19ff53f8f5d27 /sysdeps/x86_64
parent8f9fb0000e345b16902311b2d265f83b329e69c5 (diff)
downloadglibc-002ff853059c14c55188a6cbe4fdbc4baa06219e.tar
glibc-002ff853059c14c55188a6cbe4fdbc4baa06219e.tar.gz
glibc-002ff853059c14c55188a6cbe4fdbc4baa06219e.tar.bz2
glibc-002ff853059c14c55188a6cbe4fdbc4baa06219e.zip
2003-03-21 Roland McGrath <roland@redhat.com>
* sysdeps/i386/i486/bits/atomic.h (atomic_bit_set): Use "ir" constraint to permit non-constant BIT argument. (atomic_bit_test_set): Likewise. * sysdeps/x86_64/bits/atomic.h (atomic_bit_test_set): Likewise. (atomic_bit_set): Likewise. Use 1UL in case that BIT might be >= 32. For quadword case, use "i" constraint if __builtin_constant_p and < 32 or "r" constraint otherwise.
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r--sysdeps/x86_64/bits/atomic.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/sysdeps/x86_64/bits/atomic.h b/sysdeps/x86_64/bits/atomic.h
index 00f55862e6..1d41e7761c 100644
--- a/sysdeps/x86_64/bits/atomic.h
+++ b/sysdeps/x86_64/bits/atomic.h
@@ -279,19 +279,23 @@ typedef uintmax_t uatomic_max_t;
(void) ({ if (sizeof (*mem) == 1) \
__asm __volatile (LOCK "orb %b2, %0" \
: "=m" (*mem) \
- : "m" (*mem), "i" (1 << (bit))); \
+ : "m" (*mem), "ir" (1 << (bit))); \
else if (sizeof (*mem) == 2) \
__asm __volatile (LOCK "orw %w2, %0" \
: "=m" (*mem) \
- : "m" (*mem), "i" (1 << (bit))); \
+ : "m" (*mem), "ir" (1 << (bit))); \
else if (sizeof (*mem) == 4) \
__asm __volatile (LOCK "orl %2, %0" \
: "=m" (*mem) \
+ : "m" (*mem), "ir" (1 << (bit))); \
+ else if (__builtin_constant_p (bit) && (bit) < 32) \
+ __asm __volatile (LOCK "orq %2, %0" \
+ : "=m" (*mem) \
: "m" (*mem), "i" (1 << (bit))); \
else \
__asm __volatile (LOCK "orq %q2, %0" \
: "=m" (*mem) \
- : "m" (*mem), "i" (1 << (bit))); \
+ : "m" (*mem), "r" (1UL << (bit))); \
})
@@ -300,17 +304,17 @@ typedef uintmax_t uatomic_max_t;
if (sizeof (*mem) == 1) \
__asm __volatile (LOCK "btsb %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
- : "m" (*mem), "i" (bit)); \
+ : "m" (*mem), "ir" (bit)); \
else if (sizeof (*mem) == 2) \
__asm __volatile (LOCK "btsw %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
- : "m" (*mem), "i" (bit)); \
+ : "m" (*mem), "ir" (bit)); \
else if (sizeof (*mem) == 4) \
__asm __volatile (LOCK "btsl %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
- : "m" (*mem), "i" (bit)); \
+ : "m" (*mem), "ir" (bit)); \
else \
__asm __volatile (LOCK "btsq %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
- : "m" (*mem), "i" (bit)); \
+ : "m" (*mem), "ir" (bit)); \
__result; })