diff options
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h | 244 |
1 files changed, 104 insertions, 140 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h index 095f0e8aca..3c28a397ea 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h @@ -73,9 +73,6 @@ /* Delay in spinlock loop. */ #define BUSY_WAIT_NOP asm ("hint @pause") -/* Initializer for compatibility lock. */ -#define LLL_MUTEX_LOCK_INITIALIZER (0) - #define lll_futex_wait(futex, val, private) \ lll_futex_timed_wait (futex, val, NULL, private) @@ -95,12 +92,13 @@ _r10 == -1 ? -_retval : _retval; \ }) -#define lll_robust_mutex_dead(futexv) \ +#define lll_robust_dead(futexv, private) \ do \ { \ int *__futexp = &(futexv); \ atomic_or (__futexp, FUTEX_OWNER_DIED); \ - DO_INLINE_SYSCALL(futex, 3, (long) __futexp, FUTEX_WAKE, 1); \ + DO_INLINE_SYSCALL(futex, 3, (long) __futexp, \ + __lll_private_flag (FUTEX_WAKE, private), 1); \ } \ while (0) @@ -123,156 +121,144 @@ while (0) }) -#define __lll_mutex_trylock(futex) \ +#define __lll_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0) -#define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex)) +#define lll_trylock(futex) __lll_trylock (&(futex)) -#define __lll_robust_mutex_trylock(futex, id) \ +#define __lll_robust_trylock(futex, id) \ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0) -#define lll_robust_mutex_trylock(futex, id) \ - __lll_robust_mutex_trylock (&(futex), id) +#define lll_robust_trylock(futex, id) \ + __lll_robust_trylock (&(futex), id) -#define __lll_mutex_cond_trylock(futex) \ +#define __lll_cond_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0) -#define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) +#define lll_cond_trylock(futex) __lll_cond_trylock (&(futex)) -extern void __lll_lock_wait (int *futex) attribute_hidden; -extern int __lll_robust_lock_wait (int *futex) attribute_hidden; +extern void __lll_lock_wait_private (int *futex) attribute_hidden; +extern void __lll_lock_wait (int *futex, int private) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden; -#define __lll_mutex_lock(futex) \ - ((void) ({ \ - int *__futex = (futex); \ - if (atomic_compare_and_exchange_bool_acq (__futex, 1, 0) != 0) \ - __lll_lock_wait (__futex); \ +#define __lll_lock(futex, private) \ + ((void) ({ \ + int *__futex = (futex); \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, \ + 1, 0), 0)) \ + { \ + if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \ + __lll_lock_wait_private (__futex); \ + else \ + __lll_lock_wait (__futex, private); \ })) -#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) - - -#define __lll_robust_mutex_lock(futex, id) \ - ({ \ - int *__futex = (futex); \ - int __val = 0; \ - \ - if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ - __val = __lll_robust_lock_wait (__futex); \ - __val; \ +#define lll_lock(futex, private) __lll_lock (&(futex), private) + + +#define __lll_robust_lock(futex, id, private) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_lock_wait (__futex, private); \ + __val; \ }) -#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) +#define lll_robust_lock(futex, id, private) \ + __lll_robust_lock (&(futex), id, private) -#define __lll_mutex_cond_lock(futex) \ - ((void) ({ \ - int *__futex = (futex); \ - if (atomic_compare_and_exchange_bool_acq (__futex, 2, 0) != 0) \ - __lll_lock_wait (__futex); \ +#define __lll_cond_lock(futex, private) \ + ((void) ({ \ + int *__futex = (futex); \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, 2, \ + 0), 0)) \ + __lll_lock_wait (__futex, private); \ })) -#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) - - -#define __lll_robust_mutex_cond_lock(futex, id) \ - ({ \ - int *__futex = (futex); \ - int __val = 0; \ - int __id = (id) | FUTEX_WAITERS; \ - \ - if (atomic_compare_and_exchange_bool_acq (__futex, __id, 0) != 0) \ - __val = __lll_robust_lock_wait (__futex); \ - __val; \ +#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private) + + +#define __lll_robust_cond_lock(futex, id, private) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + int __id = (id) | FUTEX_WAITERS; \ + \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, \ + __id, 0), 0)) \ + __val = __lll_robust_lock_wait (__futex, private); \ + __val; \ }) -#define lll_robust_mutex_cond_lock(futex, id) \ - __lll_robust_mutex_cond_lock (&(futex), id) +#define lll_robust_cond_lock(futex, id, private) \ + __lll_robust_cond_lock (&(futex), id, private) -extern int __lll_timedlock_wait (int *futex, const struct timespec *) - attribute_hidden; -extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) - attribute_hidden; +extern int __lll_timedlock_wait (int *futex, const struct timespec *, + int private) attribute_hidden; +extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *, + int private) attribute_hidden; -#define __lll_mutex_timedlock(futex, abstime) \ - ({ \ - int *__futex = (futex); \ - int __val = 0; \ - \ - if (atomic_compare_and_exchange_bool_acq (__futex, 1, 0) != 0) \ - __val = __lll_timedlock_wait (__futex, abstime); \ - __val; \ +#define __lll_timedlock(futex, abstime, private) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, 1, \ + 0), 0)) \ + __val = __lll_timedlock_wait (__futex, abstime, private); \ + __val; \ }) -#define lll_mutex_timedlock(futex, abstime) \ - __lll_mutex_timedlock (&(futex), abstime) - - -#define __lll_robust_mutex_timedlock(futex, abstime, id) \ - ({ \ - int *__futex = (futex); \ - int __val = 0; \ - \ - if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ - __val = __lll_robust_timedlock_wait (__futex, abstime); \ - __val; \ +#define lll_timedlock(futex, abstime, private) \ + __lll_timedlock (&(futex), abstime, private) + + +#define __lll_robust_timedlock(futex, abstime, id, private) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_timedlock_wait (__futex, abstime, private); \ + __val; \ }) -#define lll_robust_mutex_timedlock(futex, abstime, id) \ - __lll_robust_mutex_timedlock (&(futex), abstime, id) +#define lll_robust_timedlock(futex, abstime, id, private) \ + __lll_robust_timedlock (&(futex), abstime, id, private) -#define __lll_mutex_unlock(futex) \ - ((void) ({ \ - int *__futex = (futex); \ - int __val = atomic_exchange_rel (__futex, 0); \ - \ - if (__builtin_expect (__val > 1, 0)) \ - lll_futex_wake (__futex, 1, LLL_SHARED); \ +#define __lll_unlock(futex, private) \ + ((void) ({ \ + int *__futex = (futex); \ + int __val = atomic_exchange_rel (__futex, 0); \ + \ + if (__builtin_expect (__val > 1, 0)) \ + lll_futex_wake (__futex, 1, private); \ })) -#define lll_mutex_unlock(futex) \ - __lll_mutex_unlock(&(futex)) +#define lll_unlock(futex, private) __lll_unlock(&(futex), private) -#define __lll_robust_mutex_unlock(futex) \ - ((void) ({ \ - int *__futex = (futex); \ - int __val = atomic_exchange_rel (__futex, 0); \ - \ - if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ - lll_futex_wake (__futex, 1, LLL_SHARED); \ +#define __lll_robust_unlock(futex, private) \ + ((void) ({ \ + int *__futex = (futex); \ + int __val = atomic_exchange_rel (__futex, 0); \ + \ + if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + lll_futex_wake (__futex, 1, private); \ })) -#define lll_robust_mutex_unlock(futex) \ - __lll_robust_mutex_unlock(&(futex)) +#define lll_robust_unlock(futex, private) \ + __lll_robust_unlock(&(futex), private) -#define __lll_mutex_unlock_force(futex) \ - ((void) ({ \ - int *__futex = (futex); \ - (void) atomic_exchange_rel (__futex, 0); \ - lll_futex_wake (__futex, 1, LLL_SHARED); \ - })) -#define lll_mutex_unlock_force(futex) \ - __lll_mutex_unlock_force(&(futex)) - - -#define lll_mutex_islocked(futex) \ +#define lll_islocked(futex) \ (futex != 0) - -/* We have a separate internal lock implementation which is not tied - to binary compatibility. We can use the lll_mutex_*. */ - -/* Type for lock object. */ -typedef int lll_lock_t; - /* Initializers for lock. */ #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) -#define lll_trylock(futex) lll_mutex_trylock (futex) -#define lll_lock(futex) lll_mutex_lock (futex) -#define lll_unlock(futex) lll_mutex_unlock (futex) -#define lll_islocked(futex) lll_mutex_islocked (futex) - - /* The kernel notifies a process with uses CLONE_CLEARTID via futex wakeup when the clone terminates. The memory location contains the thread ID while the clone is running and is reset to zero @@ -297,26 +283,4 @@ extern int __lll_timedwait_tid (int *, const struct timespec *) __res; \ }) - -/* Conditional variable handling. */ - -extern void __lll_cond_wait (pthread_cond_t *cond) - attribute_hidden; -extern int __lll_cond_timedwait (pthread_cond_t *cond, - const struct timespec *abstime) - attribute_hidden; -extern void __lll_cond_wake (pthread_cond_t *cond) - attribute_hidden; -extern void __lll_cond_broadcast (pthread_cond_t *cond) - attribute_hidden; - -#define lll_cond_wait(cond) \ - __lll_cond_wait (cond) -#define lll_cond_timedwait(cond, abstime) \ - __lll_cond_timedwait (cond, abstime) -#define lll_cond_wake(cond) \ - __lll_cond_wake (cond) -#define lll_cond_broadcast(cond) \ - __lll_cond_broadcast (cond) - #endif /* lowlevellock.h */ |