diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 10:29:20 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-03-20 10:29:20 +0000 |
commit | b1aea0989d8a14dcddde207d5414b187b3692a9c (patch) | |
tree | acd7251172b37523ac59fe6fb804d2a74df49e76 /nptl/sysdeps/unix/sysv | |
parent | 9daba4f4b988977b01427a47908a0ca4ab717984 (diff) | |
download | glibc-b1aea0989d8a14dcddde207d5414b187b3692a9c.tar glibc-b1aea0989d8a14dcddde207d5414b187b3692a9c.tar.gz glibc-b1aea0989d8a14dcddde207d5414b187b3692a9c.tar.bz2 glibc-b1aea0989d8a14dcddde207d5414b187b3692a9c.zip |
Update.
2003-03-20 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Include <atomic.h>.
Remove __lll_add, __lll_dev_if_positive, and __lll_test_and_set
definitions. Replace uses with calls to atomic_* functions.
* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
* sysdeps/unix/sysv/linux/lowlevellock.c: Replace __lll_add and
__lll_test_and_set calls with atomic_exchange_and_add and
atomic_exchange calls respectively.
* sysdeps/unix/sysv/linux/sem_post.c: Likewise.
* sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise.
* sysdeps/unix/sysv/linux/sem_trywait.c: Likewise.
* sysdeps/unix/sysv/linux/sem_wait.c: Likewise.
* sysdeps/unix/sysv/linux/ia64/pthread_once.c: Likewise.
* sysdeps/unix/sysv/linux/ia64/sem_port.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/pthread_once.c: Likewise.
* allocatestack.c (allocate_stack): Assume atomic_exchange_and_add
returns the old value.
Diffstat (limited to 'nptl/sysdeps/unix/sysv')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h | 42 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h | 52 |
2 files changed, 8 insertions, 86 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h index fc37e5d4fb..6f999221c5 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h @@ -24,6 +24,7 @@ #include <sys/param.h> #include <bits/pthreadtypes.h> #include <ia64intrin.h> +#include <atomic.h> #define SYS_futex 1230 #define FUTEX_WAIT 0 @@ -89,45 +90,6 @@ #define __lll_compare_and_swap(futex, oldval, newval) \ __sync_val_compare_and_swap_si ((futex), (oldval), (newval)) -/* Add inc to *futex atomically and return the old value. */ -#define __lll_add(futex, inc) \ - ({ \ - int __val, __oldval; \ - int *__futex = (futex); \ - int __inc = inc; \ - \ - __val = *__futex; \ - do \ - { \ - __oldval = __val; \ - __val = __lll_compare_and_swap (__futex, __oldval, __oldval + __inc); \ - } \ - while (__builtin_expect (__val != __oldval, 0)); \ - __val; \ - }) - -/* Decrement *futex if it is > 0, and return the old value. */ -#define __lll_dec_if_positive(futex) \ - ({ \ - int __val, __oldval; \ - int *__futex = (futex); \ - \ - __val = *__futex; \ - do \ - { \ - if (__builtin_expect (__val <= 0, 0)) \ - break; \ - __oldval = __val; \ - __val = __lll_compare_and_swap (__futex, __oldval, __oldval - 1); \ - } \ - while (__builtin_expect (__val != __oldval, 0)); \ - __val; \ - }) - -/* Atomically store newval and return the old value. */ -#define __lll_test_and_set(futex, newval) \ - __sync_lock_test_and_set_si ((futex), (newval)) - static inline int __attribute__ ((always_inline)) __lll_mutex_trylock (int *futex) @@ -176,7 +138,7 @@ static inline void __attribute__ ((always_inline)) __lll_mutex_unlock (int *futex) { - int val = __lll_test_and_set (futex, 0); + int val = atomic_exchange (futex, 0); if (__builtin_expect (val > 1, 0)) lll_futex_wake (futex, 1); diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index 716949c9f3..a617917da7 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -23,6 +23,8 @@ #include <time.h> #include <sys/param.h> #include <bits/pthreadtypes.h> +#include <atomic.h> + #define __NR_futex 221 #define FUTEX_WAIT 0 @@ -84,32 +86,7 @@ __val; \ }) -#define lll_mutex_trylock(lock) __lll_trylock(&(lock)) - -/* Add inc to *futex atomically and return the old value. */ -#define __lll_add(futex, inc) \ - ({ int __val, __tmp; \ - __asm __volatile ("1: lwarx %0,0,%3\n" \ - " addi %1,%0,%4\n" \ - " stwcx. %1,0,%3\n" \ - " bne- 1b" \ - : "=&b" (__val), "=&r" (__tmp), "=m" (*futex) \ - : "r" (futex), "I" (inc), "2" (*futex) \ - : "cr0"); \ - __val; \ - }) - -/* Atomically store newval and return the old value. */ -#define __lll_test_and_set(futex, newval) \ - ({ int __val; \ - __asm __volatile (__lll_rel_instr "\n" \ - "1: lwarx %0,0,%2\n" \ - " stwcx. %3,0,%2\n" \ - " bne- 1b" \ - : "=&r" (__val), "=m" (*futex) \ - : "r" (futex), "r" (newval), "1" (*futex) \ - : "cr0", "memory"); \ - __val; }) +#define lll_mutex_trylock(lock) __lll_trylock (&(lock)) extern void __lll_lock_wait (int *futex, int val) attribute_hidden; @@ -117,7 +94,7 @@ extern void __lll_lock_wait (int *futex, int val) attribute_hidden; #define lll_mutex_lock(lock) \ (void) ({ \ int *__futex = &(lock); \ - int __val = __lll_add (__futex, 1); \ + int __val = atomic_exchange_and_add (__futex, 1); \ __asm __volatile (__lll_acq_instr ::: "memory"); \ if (__builtin_expect (__val != 0, 0)) \ __lll_lock_wait (__futex, __val); \ @@ -128,7 +105,7 @@ extern int __lll_timedlock_wait #define lll_mutex_timedlock(lock, abstime) \ ({ int *__futex = &(lock); \ - int __val = __lll_add (__futex, 1); \ + int __val = atomic_exchange_and_add (__futex, 1); \ __asm __volatile (__lll_acq_instr ::: "memory"); \ if (__builtin_expect (__val != 0, 0)) \ __val = __lll_timedlock_wait (__futex, __val, (abstime)); \ @@ -138,7 +115,7 @@ extern int __lll_timedlock_wait #define lll_mutex_unlock(lock) \ ((void) ({ \ int *__futex = &(lock); \ - int __val = __lll_test_and_set (__futex, 0); \ + int __val = atomic_exchange (__futex, 0); \ if (__builtin_expect (__val > 1, 0)) \ lll_futex_wake (__futex, 1); \ })) @@ -192,23 +169,6 @@ extern int __lll_timedwait_tid (int *, const struct timespec *) }) -/* Decrement *futex if it is > 0, and return the old value */ -#define __lll_dec_if_positive(futex) \ - ({ int __val, __tmp; \ - __asm __volatile ("1: lwarx %0,0,%3\n" \ - " cmpwi 0,%0,0\n" \ - " addi %1,%0,-1\n" \ - " ble 2f\n" \ - " stwcx. %1,0,%3\n" \ - " bne- 1b\n" \ - "2: " __lll_acq_instr \ - : "=&b" (__val), "=&r" (__tmp), "=m" (*futex) \ - : "r" (futex), "2" (*futex) \ - : "cr0"); \ - __val; \ - }) - - /* Conditional variable handling. */ extern void __lll_cond_wait (pthread_cond_t *cond) |