summaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-06-08 02:50:59 +0000
committerUlrich Drepper <drepper@redhat.com>2007-06-08 02:50:59 +0000
commit835abc5c0dfd1ba8aabeb52d46793b13702c708b (patch)
tree8863a99b99c334da2e2fe77459acca76dbac5ef0 /nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
parent43b768284325b7e7d2ec3fc3dcac13a35c378c95 (diff)
[BZ #4586]
2007-06-06 Jakub Jelinek <jakub@redhat.com> BZ #4586 * sysdeps/i386/ldbl2mpn.c (__mpn_extract_long_double): Treat pseudo-zeros as zero. * sysdeps/x86_64/ldbl2mpn.c: New file. * sysdeps/ia64/ldbl2mpn.c: New file.
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h80
1 files changed, 71 insertions, 9 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index d3055cbb23..b86d95e93d 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -23,6 +23,8 @@
#include <time.h>
#include <sys/param.h>
#include <bits/pthreadtypes.h>
+#include <kernel-features.h>
+#include <tcb-offsets.h>
#ifndef LOCK_INSTR
# ifdef UP
@@ -42,6 +44,13 @@
#define FUTEX_PRIVATE_FLAG 128
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
#define LLL_MUTEX_LOCK_INITIALIZER_LOCKED (1)
@@ -149,44 +158,97 @@ LLL_STUB_UNWIND_INFO_START \
LLL_STUB_UNWIND_INFO_END
-#define lll_futex_wait(futex, val) \
+#define lll_futex_wait(futex, val, private) \
+ lll_futex_timed_wait(futex, val, NULL, private)
+
+
+#define lll_futex_timed_wait(futex, val, timeout, private) \
({ \
+ register const struct timespec *__to __asm ("r10") = timeout; \
int __status; \
register __typeof (val) _val __asm ("edx") = (val); \
- __asm __volatile ("xorq %%r10, %%r10\n\t" \
- "syscall" \
+ __asm __volatile ("syscall" \
: "=a" (__status) \
: "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \
- "d" (_val) \
- : "memory", "cc", "r10", "r11", "cx"); \
+ "d" (_val), "r" (__to) \
+ : "memory", "cc", "r11", "cx"); \
__status; \
})
-#define lll_futex_timed_wait(futex, val, timeout) \
+#define lll_futex_wake(futex, nr, private) \
+ do { \
+ int __ignore; \
+ register __typeof (nr) _nr __asm ("edx") = (nr); \
+ __asm __volatile ("syscall" \
+ : "=a" (__ignore) \
+ : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \
+ "d" (_nr) \
+ : "memory", "cc", "r10", "r11", "cx"); \
+ } while (0)
+
+
+#define lll_private_futex_wait(futex, val) \
+ lll_private_futex_timed_wait (futex, val, NULL)
+
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define lll_private_futex_timed_wait(futex, val, timeout) \
({ \
register const struct timespec *__to __asm ("r10") = timeout; \
int __status; \
register __typeof (val) _val __asm ("edx") = (val); \
__asm __volatile ("syscall" \
: "=a" (__status) \
- : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (FUTEX_WAIT | FUTEX_PRIVATE_FLAG), \
"d" (_val), "r" (__to) \
: "memory", "cc", "r11", "cx"); \
__status; \
})
-#define lll_futex_wake(futex, nr) \
+# define lll_private_futex_wake(futex, nr) \
do { \
int __ignore; \
register __typeof (nr) _nr __asm ("edx") = (nr); \
__asm __volatile ("syscall" \
: "=a" (__ignore) \
- : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (FUTEX_WAKE | FUTEX_PRIVATE_FLAG), \
"d" (_nr) \
: "memory", "cc", "r10", "r11", "cx"); \
} while (0)
+#else
+# define lll_private_futex_timed_wait(futex, val, timeout) \
+ ({ \
+ register const struct timespec *__to __asm ("r10") = timeout; \
+ int __status; \
+ int __ignore; \
+ register __typeof (val) _val __asm ("edx") = (val); \
+ __asm __volatile ("movl %%fs:%P3, %%esi\n\t" \
+ "syscall" \
+ : "=a" (__status), "=S" (__ignore) \
+ : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \
+ "d" (_val), "r" (__to) \
+ : "memory", "cc", "r11", "cx"); \
+ __status; \
+ })
+
+
+# define lll_private_futex_wake(futex, nr) \
+ do { \
+ int __ignore; \
+ int __ignore2; \
+ register __typeof (nr) _nr __asm ("edx") = (nr); \
+ __asm __volatile ("orl %%fs:%P3, %%esi\n\t" \
+ "syscall" \
+ : "=a" (__ignore), "=S" (__ignore2) \
+ : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \
+ "1" (FUTEX_WAKE), "d" (_nr) \
+ : "memory", "cc", "r10", "r11", "cx"); \
+ } while (0)
+#endif
/* Does not preserve %eax and %ecx. */