diff options
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h index e13358ffef..8df997a262 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -31,6 +31,11 @@ #define FUTEX_WAKE 1 #define FUTEX_REQUEUE 3 #define FUTEX_CMP_REQUEUE 4 +#define FUTEX_WAKE_OP 5 +#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1) +#define FUTEX_LOCK_PI 6 +#define FUTEX_UNLOCK_PI 7 +#define FUTEX_TRYLOCK_PI 8 /* Delay in spinlock loop. */ #define BUSY_WAIT_NOP asm ("hint @pause") @@ -53,6 +58,15 @@ _r10 == -1 ? -_retval : _retval; \ }) +#define lll_robust_mutex_dead(futexv) \ +do \ + { \ + int *__futexp = &(futexv); \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + DO_INLINE_SYSCALL(futex, 3, (long) __futexp, FUTEX_WAKE, 1); \ + } \ +while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \ ({ \ @@ -62,18 +76,34 @@ _r10 == -1; \ }) +/* Returns non-zero if error happened, zero if success. */ +#define lll_futex_wake_unlock(ftx, nr_wake, nr_wake2, ftx2) \ +({ \ + DO_INLINE_SYSCALL(futex, 6, (long) (ftx), FUTEX_WAKE_OP, \ + (int) (nr_wake), (int) (nr_wake2), (long) (ftx2), \ + FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \ + _r10 == -1; \ +}) + #define __lll_mutex_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0) #define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex)) +#define __lll_robust_mutex_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_mutex_cond_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0) #define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; #define __lll_mutex_lock(futex) \ @@ -85,6 +115,18 @@ extern void __lll_lock_wait (int *futex) attribute_hidden; #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_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) + + #define __lll_mutex_cond_lock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -94,8 +136,24 @@ extern void __lll_lock_wait (int *futex) attribute_hidden; #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_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_cond_lock (&(futex), id) + + 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; #define __lll_mutex_timedlock(futex, abstime) \ @@ -111,6 +169,19 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *) __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_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + + #define __lll_mutex_unlock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -123,6 +194,18 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *) __lll_mutex_unlock(&(futex)) +#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); \ + })) +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex)) + + #define __lll_mutex_unlock_force(futex) \ ((void) ({ \ int *__futex = (futex); \ |