diff options
Diffstat (limited to 'nptl/sysdeps/unix/sysv')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c | 16 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h | 13 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h | 20 |
3 files changed, 48 insertions, 1 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c index 7b4e84343c..9a9e67303b 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2006-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2006. @@ -70,8 +70,15 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, if (oldval == 0) goto try; + /* Work around the fact that the kernel rejects negative timeout values + despite them being valid. */ + if (__builtin_expect (abstime->tv_sec < 0, 0)) + return ETIMEDOUT; + do { +#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \ + || !defined lll_futex_timed_wait_bitset) struct timeval tv; struct timespec rt; @@ -90,6 +97,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, /* Already timed out? */ if (rt.tv_sec < 0) return ETIMEDOUT; +#endif /* Wait. */ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) @@ -100,7 +108,13 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) continue; +#if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \ + || !defined lll_futex_timed_wait_bitset) lll_futex_timed_wait (futex, newval, &rt, private); +#else + lll_futex_timed_wait_bitset (futex, newval, abstime, + FUTEX_CLOCK_REALTIME, private); +#endif try: ; diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index 406c290d71..17e63c6901 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -88,6 +88,19 @@ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ }) +#define lll_futex_timed_wait_bitset(futexp, val, timespec, clockbit, private) \ + ({ \ + INTERNAL_SYSCALL_DECL (__err); \ + long int __ret; \ + int __op = FUTEX_WAIT_BITSET | clockbit; \ + \ + __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \ + __lll_private_flag (__op, private), \ + (val), (timespec), NULL /* Unused. */, \ + FUTEX_BITSET_MATCH_ANY); \ + INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ + }) + #define lll_futex_wake(futexp, nr, private) \ ({ \ INTERNAL_SYSCALL_DECL (__err); \ diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h index 97092823df..0b7110f11b 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h @@ -93,6 +93,26 @@ __result; \ }) +#define lll_futex_timed_wait_bitset(futexp, val, timespec, clockbit, private) \ + ({ \ + register unsigned long int __r2 asm ("2") = (unsigned long int) (futexp); \ + register unsigned long int __r3 asm ("3") \ + = __lll_private_flag ((FUTEX_WAIT_BITSET | clockbit), private); \ + register unsigned long int __r4 asm ("4") = (long int) (val); \ + register unsigned long int __r5 asm ("5") = (long int) (timespec); \ + register unsigned long int __r6 asm ("6") = (unsigned long int) (NULL); \ + register unsigned long int __r7 asm ("7") \ + = (unsigned int) (FUTEX_BITSET_MATCH_ANY); \ + register unsigned long __result asm ("2"); \ + \ + __asm __volatile ("svc %b1" \ + : "=d" (__result) \ + : "i" (SYS_futex), "0" (__r2), "d" (__r3), \ + "d" (__r4), "d" (__r5), "d" (__r6), "d" (__r7) \ + : "cc", "memory" ); \ + __result; \ + }) + #define lll_futex_wake(futex, nr, private) \ ({ \ |