diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 09:03:23 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 09:03:23 +0000 |
commit | 3dbe0d9517935d549f2630728500b6f275750ec8 (patch) | |
tree | c25d29d53b1ca68d311a36bf9a4b54a200157c06 /sysdeps/i386/i486/bits | |
parent | 91958edc8459a45bc8c0b6d355ffbfdd245296fb (diff) | |
download | glibc-3dbe0d9517935d549f2630728500b6f275750ec8.zip glibc-3dbe0d9517935d549f2630728500b6f275750ec8.tar.gz glibc-3dbe0d9517935d549f2630728500b6f275750ec8.tar.bz2 |
Change atomic_exchange_and_add to return the old value.
Diffstat (limited to 'sysdeps/i386/i486/bits')
-rw-r--r-- | sysdeps/i386/i486/bits/atomic.h | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h index 80a4987..87739c6 100644 --- a/sysdeps/i386/i486/bits/atomic.h +++ b/sysdeps/i386/i486/bits/atomic.h @@ -123,33 +123,24 @@ typedef uintmax_t uatomic_max_t; ({ __typeof (*mem) result; \ __typeof (value) addval = (value); \ if (sizeof (*mem) == 1) \ - { \ - __asm __volatile (LOCK "xaddb %b0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" (addval), "1" (*mem)); \ - result += addval; \ - } \ + __asm __volatile (LOCK "xaddb %b0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (addval), "1" (*mem)); \ else if (sizeof (*mem) == 2) \ - { \ - __asm __volatile (LOCK "xaddw %w0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" (addval), "1" (*mem)); \ - result += addval; \ - } \ + __asm __volatile (LOCK "xaddw %w0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (addval), "1" (*mem)); \ else if (sizeof (*mem) == 4) \ - { \ - __asm __volatile (LOCK "xaddl %0, %1" \ - : "=r" (result), "=m" (*mem) \ - : "0" (addval), "1" (*mem)); \ - result += addval; \ - } \ + __asm __volatile (LOCK "xaddl %0, %1" \ + : "=r" (result), "=m" (*mem) \ + : "0" (addval), "1" (*mem)); \ else \ { \ - __typeof (*mem) oldval; \ __typeof (mem) memp = (mem); \ do \ - result = (oldval = *memp) + addval; \ - while (__arch_compare_and_exchange_64_acq (memp, result, oldval)); \ + result = *memp; \ + while (__arch_compare_and_exchange_64_acq (memp, result + addval, \ + result)); \ } \ result; }) |