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/linux/powerpc/lowlevellock.h | |
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/linux/powerpc/lowlevellock.h')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h | 52 |
1 files changed, 6 insertions, 46 deletions
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) |