summaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S55
1 files changed, 33 insertions, 22 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index 502f1d442f..6724ded762 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -31,23 +31,8 @@
#endif
#define SYS_futex 202
-#ifndef FUTEX_WAIT
-# define FUTEX_WAIT 0
-# define FUTEX_WAKE 1
-#endif
-
-#ifndef LOAD_FUTEX_WAIT
-# if FUTEX_WAIT == 0
-# define LOAD_FUTEX_WAIT(reg) \
- xorl reg, reg
-# else
-# define LOAD_FUTEX_WAIT(reg) \
- movl $FUTEX_WAIT, reg
-# endif
-# define LOAD_FUTEX_WAKE(reg) \
- movl $FUTEX_WAKE, reg
-#endif
-
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
/* For the calculation see asm/vsyscall.h. */
#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
@@ -67,7 +52,11 @@ __lll_mutex_lock_wait:
cfi_offset(%rdx, -24)
xorq %r10, %r10 /* No timeout. */
movl $2, %edx
- LOAD_FUTEX_WAIT (%esi)
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
cmpl %edx, %eax /* NB: %edx == 2 */
jne 2f
@@ -162,7 +151,11 @@ __lll_mutex_timedlock_wait:
je 8f
movq %rsp, %r10
- LOAD_FUTEX_WAIT (%esi)
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdi
movl $SYS_futex, %eax
syscall
@@ -220,6 +213,26 @@ __lll_mutex_timedlock_wait:
#endif
+#ifdef NOT_IN_libc
+ .globl lll_unlock_wake_cb
+ .type lll_unlock_wake_cb,@function
+ .hidden lll_unlock_wake_cb
+ .align 16
+lll_unlock_wake_cb:
+ pushq %rsi
+ pushq %rdx
+
+ LOCK
+ addl $1, (%rdi)
+ jng 1f
+
+ popq %rdx
+ popq %rsi
+ retq
+ .size lll_unlock_wake_cb,.-lll_unlock_wake_cb
+#endif
+
+
.globl __lll_mutex_unlock_wake
.type __lll_mutex_unlock_wake,@function
.hidden __lll_mutex_unlock_wake
@@ -234,7 +247,7 @@ __lll_mutex_unlock_wake:
cfi_offset(%rdx, -24)
movl $0, (%rdi)
- LOAD_FUTEX_WAKE (%esi)
+ movl $FUTEX_WAKE, %esi
movl $1, %edx /* Wake one thread. */
movl $SYS_futex, %eax
syscall
@@ -298,8 +311,6 @@ __lll_timedwait_tid:
jz 4f
movq %rsp, %r10
- /* XXX The kernel so far uses global futex for the wakeup at
- all times. */
#if FUTEX_WAIT == 0
xorl %esi, %esi
#else