diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 10:18:24 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 10:18:24 +0000 |
commit | f79466a8e909930237d882da8916bbbb1401edf6 (patch) | |
tree | 460afefe452e8550b56d9a01d90dc129012dfd27 /sysdeps/i386 | |
parent | 5132931e18d50a1caf7399aa46dafd0142a7c7ae (diff) | |
download | glibc-f79466a8e909930237d882da8916bbbb1401edf6.zip glibc-f79466a8e909930237d882da8916bbbb1401edf6.tar.gz glibc-f79466a8e909930237d882da8916bbbb1401edf6.tar.bz2 |
Update.
2003-03-20 Ulrich Drepper <drepper@redhat.com>
* include/atomic.h: Define atomic_exchange and
atomic_decrement_if_positive if not already defined. Add some
__builtin_expect.
* sysdeps/i386/i486/bits/atomic.h: Define atomic_exchange.
* sysdeps/x86_64/bits/atomic.h: Likewise.
* sysdeps/ia64/bits/atomic.h: Pretty printing. Define atomic_exchange.
* sysdeps/powerpc/bits/atomic.h: Pretty printing. Define
atomic_exchange, atomic_exchange_and_add, and
atomic_decrement_if_positive
Diffstat (limited to 'sysdeps/i386')
-rw-r--r-- | sysdeps/i386/i486/bits/atomic.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h index 87739c6..e22e560 100644 --- a/sysdeps/i386/i486/bits/atomic.h +++ b/sysdeps/i386/i486/bits/atomic.h @@ -119,6 +119,29 @@ typedef uintmax_t uatomic_max_t; #endif +/* Note that we need no lock prefix. */ +#define atomic_exchange(mem, newvalue) \ + ({ __typeof (*mem) result; \ + if (sizeof (*mem) == 1) \ + __asm __volatile ("xchgb %b0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (newvalue), "1" (*mem)); \ + else if (sizeof (*mem) == 2) \ + __asm __volatile ("xchgw %w0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (newvalue), "1" (*mem)); \ + else if (sizeof (*mem) == 4) \ + __asm __volatile ("xchgl %0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (newvalue), "1" (*mem)); \ + else \ + { \ + result = 0; \ + abort (); \ + } \ + result; }) + + #define atomic_exchange_and_add(mem, value) \ ({ __typeof (*mem) result; \ __typeof (value) addval = (value); \ |