aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-06-03 16:04:11 +0000
committerUlrich Drepper <drepper@redhat.com>2004-06-03 16:04:11 +0000
commit75fcceded2cfc65e4879521fff4db6a620a96363 (patch)
tree6d0763c5a2e4b59ece4d57a87232d435d15a5f7f /sysdeps/i386
parent322861e8b62dbca030a66f9ab37e6688b223c65f (diff)
downloadglibc-75fcceded2cfc65e4879521fff4db6a620a96363.tar
glibc-75fcceded2cfc65e4879521fff4db6a620a96363.tar.gz
glibc-75fcceded2cfc65e4879521fff4db6a620a96363.tar.bz2
glibc-75fcceded2cfc65e4879521fff4db6a620a96363.zip
Update.
2004-06-03 Ulrich Drepper <drepper@redhat.com> * sysdeps/i386/i486/bits/atomic.h: Optimize a bit.
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/i486/bits/atomic.h64
1 files changed, 34 insertions, 30 deletions
diff --git a/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h
index 9587eaa87a..7f3d534483 100644
--- a/sysdeps/i386/i486/bits/atomic.h
+++ b/sysdeps/i386/i486/bits/atomic.h
@@ -140,30 +140,31 @@ typedef uintmax_t uatomic_max_t;
#define atomic_exchange_and_add(mem, value) \
- ({ __typeof (*mem) result; \
- __typeof (value) addval = (value); \
+ ({ __typeof (*mem) __result; \
+ __typeof (value) __addval = (value); \
if (sizeof (*mem) == 1) \
__asm __volatile (LOCK_PREFIX "xaddb %b0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" (addval), "m" (*mem)); \
+ : "=r" (__result), "=m" (*mem) \
+ : "0" (__addval), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
__asm __volatile (LOCK_PREFIX "xaddw %w0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" (addval), "m" (*mem)); \
+ : "=r" (__result), "=m" (*mem) \
+ : "0" (__addval), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
__asm __volatile (LOCK_PREFIX "xaddl %0, %1" \
- : "=r" (result), "=m" (*mem) \
- : "0" (addval), "m" (*mem)); \
+ : "=r" (__result), "=m" (*mem) \
+ : "0" (__addval), "m" (*mem)); \
else \
{ \
- __typeof (mem) memp = (mem); \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*mem) __tmpval; \
+ __result = *__memp; \
do \
- result = *memp; \
- while (__arch_compare_and_exchange_val_64_acq (memp, \
- result + addval, \
- result) == result); \
+ __tmpval = __result; \
+ while ((__result = __arch_compare_and_exchange_val_64_acq \
+ (__memp, __result + __addval, __result)) == __tmpval); \
} \
- result; })
+ __result; })
#define atomic_add(mem, value) \
@@ -185,13 +186,14 @@ typedef uintmax_t uatomic_max_t;
: "ir" (value), "m" (*mem)); \
else \
{ \
- __typeof (value) addval = (value); \
- __typeof (*mem) oldval; \
- __typeof (mem) memp = (mem); \
+ __typeof (value) __addval = (value); \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*mem) __oldval = *__memp; \
+ __typeof (*mem) __tmpval; \
do \
- oldval = *memp; \
- while (__arch_compare_and_exchange_val_64_acq \
- (memp, oldval + addval, oldval) == oldval); \
+ __tmpval = __oldval; \
+ while ((__oldval = __arch_compare_and_exchange_val_64_acq \
+ (__memp, __oldval + __addval, __oldval)) == __tmpval); \
} \
})
@@ -249,12 +251,13 @@ typedef uintmax_t uatomic_max_t;
: "m" (*mem)); \
else \
{ \
- __typeof (*mem) oldval; \
- __typeof (mem) memp = (mem); \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*mem) __oldval = *__memp; \
+ __typeof (*mem) __tmpval; \
do \
- oldval = *memp; \
- while (__arch_compare_and_exchange_val_64_acq \
- (memp, oldval + 1, oldval) == oldval); \
+ __tmpval = __oldval; \
+ while ((__oldval = __arch_compare_and_exchange_val_64_acq \
+ (__memp, __oldval + 1, __oldval)) == __tmpval); \
} \
})
@@ -293,12 +296,13 @@ typedef uintmax_t uatomic_max_t;
: "m" (*mem)); \
else \
{ \
- __typeof (*mem) oldval; \
- __typeof (mem) memp = (mem); \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*mem) __oldval = *__memp; \
+ __typeof (*mem) __tmpval; \
do \
- oldval = *memp; \
- while (__arch_compare_and_exchange_val_64_acq \
- (memp, oldval - 1, oldval) == oldval); \
+ __tmpval = __oldval; \
+ while ((__oldval = __arch_compare_and_exchange_val_64_acq \
+ (__memp, __oldval - 1, __oldval)) == __tmpval); \
} \
})