about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_timedwait.c3
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_wait.c6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h19
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S6
12 files changed, 42 insertions, 52 deletions
diff --git a/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/nptl/sysdeps/pthread/pthread_cond_timedwait.c
index 0635e6ed93..af9929c500 100644
--- a/nptl/sysdeps/pthread/pthread_cond_timedwait.c
+++ b/nptl/sysdeps/pthread/pthread_cond_timedwait.c
@@ -134,8 +134,7 @@ __pthread_cond_timedwait (cond, mutex, abstime)
 
       /* Check whether we are eligible for wakeup.  */
       val = cond->__data.__wakeup_seq;
-      if (cond->__data.__woken_seq >= seq
-	  && cond->__data.__woken_seq < val)
+      if (val > seq && cond->__data.__woken_seq < val)
 	break;
 
       /* Not woken yet.  Maybe the time expired?  */
diff --git a/nptl/sysdeps/pthread/pthread_cond_wait.c b/nptl/sysdeps/pthread/pthread_cond_wait.c
index b681ef26fd..412bca9c25 100644
--- a/nptl/sysdeps/pthread/pthread_cond_wait.c
+++ b/nptl/sysdeps/pthread/pthread_cond_wait.c
@@ -117,7 +117,7 @@ __pthread_cond_wait (cond, mutex)
 # error "No valid byte order"
 #endif
 
-  while (1)
+  do
     {
       /* Prepare to wait.  Release the condvar futex.  */
       lll_mutex_unlock (cond->__data.__lock);
@@ -137,10 +137,8 @@ __pthread_cond_wait (cond, mutex)
 
       /* Check whether we are eligible for wakeup.  */
       val = cond->__data.__wakeup_seq;
-      if (cond->__data.__woken_seq >= seq
-	  && cond->__data.__woken_seq < val)
-	break;
     }
+  while (! (val > seq && cond->__data.__woken_seq < val));
 
   /* Another thread woken up.  */
   ++cond->__data.__woken_seq;
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
index 9082fd5f4f..c1ce3bec17 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
@@ -164,11 +164,11 @@ __pthread_cond_timedwait:
 	movl	wakeup_seq(%ebx), %edi
 	movl	wakeup_seq+4(%ebx), %edx
 
-	cmpl	24(%esp), %ecx
+	cmpl	24(%esp), %edx
 	ja	7f
 	jb	15f
-	cmpl	20(%esp), %eax
-	jb	15f
+	cmpl	20(%esp), %edi
+	jbe	15f
 
 7:	cmpl	%ecx, %edx
 	ja	9f
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
index c13c38290e..68ce35e8d6 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
@@ -195,11 +195,11 @@ __pthread_cond_wait:
 	movl	wakeup_seq(%ebx), %edi
 	movl	wakeup_seq+4(%ebx), %edx
 
-	cmpl	16(%esp), %ecx
+	cmpl	16(%esp), %edx
 	ja	7f
 	jb	8b
-	cmpl	12(%esp), %eax
-	jb	8b
+	cmpl	12(%esp), %edi
+	jbe	8b
 
 7:	cmpl	%ecx, %edx
 	ja	9f
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
index 30a2e2c092..6c8dca55a2 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
@@ -77,12 +77,12 @@ __pthread_rwlock_rdlock:
 #endif
 	jne	10f
 
-11:	addl	$READERS_WAKEUP-MUTEX, %ebx
+11:	addl	$READERS_WAKEUP, %ebx
 	movl	%esi, %ecx	/* movl $FUTEX_WAIT, %ecx */
 	movl	$SYS_futex, %eax
 	ENTER_KERNEL
 
-	subl	$READERS_WAKEUP-MUTEX, %ebx
+	subl	$READERS_WAKEUP, %ebx
 
 	/* Reget the lock.  */
 	movl	$1, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
index 10b176edce..0b1cc28986 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
@@ -75,12 +75,12 @@ __pthread_rwlock_wrlock:
 #endif
 	jne	10f
 
-11:	addl	$WRITERS_WAKEUP-MUTEX, %ebx
+11:	addl	$WRITERS_WAKEUP, %ebx
 	movl	%esi, %ecx	/* movl $FUTEX_WAIT, %ecx */
 	movl	$SYS_futex, %eax
 	ENTER_KERNEL
 
-	subl	$WRITERS_WAKEUP-MUTEX, %ebx
+	subl	$WRITERS_WAKEUP, %ebx
 
 	/* Reget the lock.  */
 	movl	$1, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index c593f6ac66..daece67eab 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -66,7 +66,7 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
 			      "testl %0, %0\n\t"			      \
 			      "jne 1f\n\t"				      \
 			      ".subsection 1\n"				      \
-			      "1:\tleaq %2, %%rsi\n\t"			      \
+			      "1:\tleaq %2, %%rdi\n\t"			      \
 			      "subq $128, %%rsp\n\t"			      \
 			      "callq __lll_mutex_lock_wait\n\t"		      \
 			      "addq $128, %%rsp\n\t"			      \
@@ -75,8 +75,7 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=S" (ignore1), "=&D" (ignore2), "=m" (futex) \
 			      : "0" (1), "2" (futex)			      \
-			      : "memory"); })
-
+			      : "cx", "r11", "cc", "memory"); })
 
 #define lll_mutex_timedlock(futex, timeout) \
   ({ int result, ignore1, ignore2, ignore3;				      \
@@ -95,7 +94,7 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
 		       : "=a" (result), "=&D" (ignore1), "=&S" (ignore2),     \
 			 "=&d" (ignore3), "=m" (futex)			      \
 		       : "0" (1), "4" (futex), "m" (timeout)		      \
-		       : "memory", "cx", "cc", "r10");			      \
+		       : "memory", "cx", "cc", "r10", "r11");		      \
      result; })
 
 
@@ -113,7 +112,7 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=m" (futex), "=&D" (ignore)		      \
 			      : "0" (futex)				      \
-			      : "memory"); })
+			      : "cx", "r11", "cc", "memory"); })
 
 
 #define lll_mutex_islocked(futex) \
@@ -166,7 +165,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=S" (ignore1), "=&D" (ignore2), "=m" (futex) \
 			      : "0" (-1), "2" (futex)			      \
-			      : "memory"); })
+			      : "cx", "r11", "cc", "memory"); })
 
 
 # define lll_unlock(futex) \
@@ -183,7 +182,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=m" (futex), "=&D" (ignore)		      \
 			      : "0" (futex)				      \
-			      : "memory"); })
+			      : "cx", "r11", "cc", "memory"); })
 #else
 /* Special versions of the macros for use in libc itself.  They avoid
    the lock prefix when the thread library is not used.
@@ -219,7 +218,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=S" (ignore1), "=&D" (ignore2), "=m" (futex) \
 			      : "0" (-1), "2" (futex)			      \
-			      : "memory"); })
+			      : "cx", "r11", "cc", "memory"); })
 
 
 # define lll_unlock(futex) \
@@ -239,7 +238,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
 			      "2:"					      \
 			      : "=m" (futex), "=&D" (ignore)		      \
 			      : "0" (futex)				      \
-			      : "memory"); })
+			      : "cx", "r11", "cc", "memory"); })
 #endif
 
 
@@ -259,7 +258,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
     register __typeof (tid) _tid asm ("edx") = (tid);			      \
     if (_tid != 0)							      \
       __asm __volatile ("xorq %%r10, %%r10\n\t"				      \
-			"1:\tmovq %3, %%rax\n\t"			      \
+			"1:\tmovq %2, %%rax\n\t"			      \
 			"syscall\n\t"					      \
 			"cmpl $0, (%%rdi)\n\t"				      \
 			"jne 1b"					      \
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
index 3c8acc1c25..9da9af8d01 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -171,8 +171,8 @@ __pthread_cond_timedwait:
 
 	movq	wakeup_seq(%rdi), %r12
 
-	cmpq	40(%rsp), %rax
-	jb	15f
+	cmpq	40(%rsp), %r12
+	jbe	15f
 
 	cmpq	%rax, %r12
 	ja	9f
@@ -181,10 +181,10 @@ __pthread_cond_timedwait:
 	jne	8b
 
 13:	incq	wakeup_seq(%rdi)
-	movq	$ETIMEDOUT, %rsi
+	movq	$ETIMEDOUT, %r14
 	jmp	14f
 
-9:	xorq	%rsi, %rsi
+9:	xorq	%r14, %r14
 14:	incq	woken_seq(%rdi)
 
 	LOCK
@@ -203,7 +203,7 @@ __pthread_cond_timedwait:
 	callq	__pthread_mutex_lock_internal
 
 	testq	%rax, %rax
-	cmoveq	%rsi, %rax
+	cmoveq	%r14, %rax
 
 18:	addq	$80, %rsp
 	popq	%r14
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
index 4a0e3cce55..835486a8a1 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
@@ -198,8 +198,8 @@ __pthread_cond_wait:
 
 	movq	wakeup_seq(%rdi), %r12
 
-	cmpq	24(%rsp), %rax
-	jb	8b
+	cmpq	24(%rsp), %r12
+	jbe	8b
 
 	cmpq	%rax, %r12
 	jna	8b
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
index e31d4bb705..0b0ccf7027 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
@@ -67,18 +67,18 @@ __pthread_rwlock_rdlock:
 
 	LOCK
 #if MUTEX == 0
-	incl	(%rdi)
+	decl	(%rdi)
 #else
-	incl	MUTEX(%rdi)
+	decl	MUTEX(%rdi)
 #endif
 	jne	10f
 
-11:	addq	$READERS_WAKEUP-MUTEX, %rdi
+11:	addq	$READERS_WAKEUP, %rdi
 	movq	%r10, %rsi	/* movq $FUTEX_WAIT, %rsi */
 	movq	$SYS_futex, %rax
 	syscall
 
-	subq	$READERS_WAKEUP-MUTEX, %rdi
+	subq	$READERS_WAKEUP, %rdi
 
 	/* Reget the lock.  */
 	movl	$1, %esi
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
index 4f487fb8df..a3d2351b68 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
@@ -21,7 +21,7 @@
 #include <lowlevelrwlock.h>
 
 
-#define SYS_futex		240
+#define SYS_futex		202
 #define FUTEX_WAIT		0
 #define FUTEX_WAKE		1
 
@@ -57,7 +57,7 @@ __pthread_rwlock_unlock:
 5:	movq	$0, WRITER(%rdi)
 
 	movq	$1, %rsi
-	leaq	WRITERS_WAKEUP(%rdi), %r11
+	leaq	WRITERS_WAKEUP(%rdi), %r10
 	movq	%rsi, %rdx
 	cmpl	$0, WRITERS_QUEUED(%rdi)
 	jne	0f
@@ -66,10 +66,10 @@ __pthread_rwlock_unlock:
 	cmpl	$0, READERS_QUEUED(%rdi)
 	je	6f
 
-	movq	$0x7fffffff, %rdx
-	leaq	READERS_WAKEUP(%rdi), %r11
+	movl	$0x7fffffff, %edx
+	leaq	READERS_WAKEUP(%rdi), %r10
 
-0:	incl	(%r11)
+0:	incl	(%r10)
 	LOCK
 #if MUTEX == 0
 	decl	(%rdi)
@@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
 	jne	7f
 
 8:	movq	$SYS_futex, %rax
-	movq	%r11, %rdi
+	movq	%r10, %rdi
 	syscall
 
 	xorq	%rax, %rax
@@ -112,9 +112,6 @@ __pthread_rwlock_unlock:
 	addq	$MUTEX, %rdi
 #endif
 	callq	__lll_mutex_unlock_wake
-#if MUTEX != 0
-	subq	$MUTEX, %rdi
-#endif
 	jmp	4b
 
 7:
@@ -122,9 +119,6 @@ __pthread_rwlock_unlock:
 	addq	$MUTEX, %rdi
 #endif
 	callq	__lll_mutex_unlock_wake
-#if MUTEX != 0
-	subq	$MUTEX, %rdi
-#endif
 	jmp	8b
 
 	.size	__pthread_rwlock_unlock,.-__pthread_rwlock_unlock
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
index 0afe46a246..9e7336b20e 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
@@ -71,12 +71,12 @@ __pthread_rwlock_wrlock:
 #endif
 	jne	10f
 
-11:	addq	$WRITERS_WAKEUP-MUTEX, %rdi
+11:	addq	$WRITERS_WAKEUP, %rdi
 	movq	%r10, %rsi	/* movq $FUTEX_WAIT, %rsi */
 	movq	$SYS_futex, %rax
 	syscall
 
-	subq	$WRITERS_WAKEUP-MUTEX, %rdi
+	subq	$WRITERS_WAKEUP, %rdi
 
 	/* Reget the lock.  */
 	movl	$1, %esi
@@ -99,7 +99,7 @@ __pthread_rwlock_wrlock:
 #if MUTEX == 0
 	decl	(%rdi)
 #else
-	decl	$MUTEX(%rdi)
+	decl	MUTEX(%rdi)
 #endif
 	jne	6f
 7: