summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-06-05 19:31:57 +0000
committerUlrich Drepper <drepper@redhat.com>2003-06-05 19:31:57 +0000
commit4ad0bbf4fa2073b8b2cb81866f68ff3e8c503174 (patch)
tree3b1ca4ddea994a1978a4c1b1a791f8458cce706d
parentb558fd3ab7b8d9d98b7babc51da7de109f69a77e (diff)
downloadglibc-4ad0bbf4fa2073b8b2cb81866f68ff3e8c503174.tar.gz
glibc-4ad0bbf4fa2073b8b2cb81866f68ff3e8c503174.tar.xz
glibc-4ad0bbf4fa2073b8b2cb81866f68ff3e8c503174.zip
Update.
2003-06-05  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_rwlock_t):
	Change type of __writer element to int.
	* sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
	* sysdeps/i386/tcb-offsets.sym: Replace SELF entry with TID entry.
	* sysdeps/x86_64/tcb-offsets.sym: Likewise.
	* pthread_rwlock_trywrlock.c: Store TID not self pointer in __writer.
	Compare with TID to determine deadlocks.
	* sysdeps/pthread/pthread_rwlock_rdlock.c: Likewise.
	* sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
	* sysdeps/pthread/pthread_rwlock_timedwrlock.: Likewise.
	* sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
	* Makefile (tests): Add tst-rwlock12.
	* tst-rwlock12.c: New file.
-rw-r--r--nptl/ChangeLog32
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/pthread_rwlock_trywrlock.c2
-rw-r--r--nptl/sysdeps/i386/tcb-offsets.sym2
-rw-r--r--nptl/sysdeps/pthread/pthread_rwlock_rdlock.c5
-rw-r--r--nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c5
-rw-r--r--nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c7
-rw-r--r--nptl/sysdeps/pthread/pthread_rwlock_wrlock.c7
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h5
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h7
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h7
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h5
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S10
-rw-r--r--nptl/sysdeps/x86_64/tcb-offsets.sym2
22 files changed, 83 insertions, 51 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 659eabc943..6ee1faaa59 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,35 @@
+2003-06-05  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_rwlock_t):
+	Change type of __writer element to int.
+	* sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+	* sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+	* sysdeps/i386/tcb-offsets.sym: Replace SELF entry with TID entry.
+	* sysdeps/x86_64/tcb-offsets.sym: Likewise.
+	* pthread_rwlock_trywrlock.c: Store TID not self pointer in __writer.
+	Compare with TID to determine deadlocks.
+	* sysdeps/pthread/pthread_rwlock_rdlock.c: Likewise.
+	* sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
+	* sysdeps/pthread/pthread_rwlock_timedwrlock.: Likewise.
+	* sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
+	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+	Likewise.
+	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+	Likewise.
+	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+	Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+	Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+	* Makefile (tests): Add tst-rwlock12.
+	* tst-rwlock12.c: New file.
+
 2003-06-05  Jakub Jelinek  <jakub@redhat.com>
 
 	* sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait,
diff --git a/nptl/Makefile b/nptl/Makefile
index 85ba98ad20..bc17ba58ba 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -146,7 +146,7 @@ tests = tst-attr1 tst-attr2 \
 	tst-cond8 tst-cond9 tst-cond10 tst-cond11 \
 	tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \
 	tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \
-	tst-rwlock11 \
+	tst-rwlock11 tst-rwlock12 \
 	tst-once1 tst-once2 tst-once3 tst-once4 \
 	tst-key1 tst-key2 tst-key3 tst-key4 \
 	tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
diff --git a/nptl/pthread_rwlock_trywrlock.c b/nptl/pthread_rwlock_trywrlock.c
index 755af37330..b754a19565 100644
--- a/nptl/pthread_rwlock_trywrlock.c
+++ b/nptl/pthread_rwlock_trywrlock.c
@@ -32,7 +32,7 @@ __pthread_rwlock_trywrlock (rwlock)
 
   if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
     {
-      rwlock->__data.__writer = (pthread_t) THREAD_ID;
+      rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
       result = 0;
     }
 
diff --git a/nptl/sysdeps/i386/tcb-offsets.sym b/nptl/sysdeps/i386/tcb-offsets.sym
index 562ac70d4b..12cb6f00f9 100644
--- a/nptl/sysdeps/i386/tcb-offsets.sym
+++ b/nptl/sysdeps/i386/tcb-offsets.sym
@@ -1,7 +1,7 @@
 #include <sysdep.h>
 #include <tls.h>
 
-SELF			offsetof (tcbhead_t, self)
+TID			offsetof (struct pthread, tid)
 MULTIPLE_THREADS_OFFSET	offsetof (tcbhead_t, multiple_threads)
 SYSINFO_OFFSET		offsetof (tcbhead_t, sysinfo)
 CLEANUP			offsetof (struct pthread, cleanup)
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
index 7fb93df1de..f785bb7893 100644
--- a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
+++ b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
@@ -55,9 +55,8 @@ __pthread_rwlock_rdlock (rwlock)
 
       /* Make sure we are not holding the rwlock as a writer.  This is
 	 a deadlock situation we recognize and report.  */
-      if (rwlock->__data.__writer != 0
-	  && __builtin_expect (rwlock->__data.__writer
-			       == (pthread_t) THREAD_ID, 0))
+      if (__builtin_expect (rwlock->__data.__writer
+			    == THREAD_GETMEM (THREAD_SELF, tid), 0))
 	{
 	  result = EDEADLK;
 	  break;
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
index d5a75ba3b2..2cba0d3c88 100644
--- a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
+++ b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
@@ -58,9 +58,8 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
 
       /* Make sure we are not holding the rwlock as a writer.  This is
 	 a deadlock situation we recognize and report.  */
-      if (rwlock->__data.__writer != 0
-	  && __builtin_expect (rwlock->__data.__writer
-			       == (pthread_t) THREAD_ID, 0))
+      if (__builtin_expect (rwlock->__data.__writer
+			    == THREAD_GETMEM (THREAD_SELF, tid), 0))
 	{
 	  result = EDEADLK;
 	  break;
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
index 52308aff91..a3cdda30bb 100644
--- a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
+++ b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
@@ -43,15 +43,14 @@ pthread_rwlock_timedwrlock (rwlock, abstime)
       if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
 	{
 	  /* Mark self as writer.  */
-	  rwlock->__data.__writer = (pthread_t) THREAD_ID;
+	  rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
 	  break;
 	}
 
       /* Make sure we are not holding the rwlock as a writer.  This is
 	 a deadlock situation we recognize and report.  */
-      if (rwlock->__data.__writer != 0
-	  && __builtin_expect (rwlock->__data.__writer
-			       == (pthread_t) THREAD_ID, 0))
+      if (__builtin_expect (rwlock->__data.__writer
+			    == THREAD_GETMEM (THREAD_SELF, tid), 0))
 	{
 	  result = EDEADLK;
 	  break;
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
index 171a14adb1..822aeed79c 100644
--- a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
+++ b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
@@ -40,15 +40,14 @@ __pthread_rwlock_wrlock (rwlock)
       if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
 	{
 	  /* Mark self as writer.  */
-	  rwlock->__data.__writer = (pthread_t) THREAD_ID;
+	  rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
 	  break;
 	}
 
       /* Make sure we are not holding the rwlock as a writer.  This is
 	 a deadlock situation we recognize and report.  */
-      if (rwlock->__data.__writer != 0
-	  && __builtin_expect (rwlock->__data.__writer
-			       == (pthread_t) THREAD_ID, 0))
+      if (__builtin_expect (rwlock->__data.__writer
+			    == THREAD_GETMEM (THREAD_SELF, tid), 0))
 	{
 	  result = EDEADLK;
 	  break;
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
index 4b0f11adc5..256589da0d 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
@@ -115,7 +115,7 @@ typedef union
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
-    pthread_t __writer;
+    int __writer;
   } __data;
   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
   long int __align;
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 6c8dca55a2..81d9766056 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
@@ -124,7 +124,7 @@ __pthread_rwlock_rdlock:
 	call	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpl	%gs:SELF, %eax
+14:	cmpl	%gs:TID, %eax
 	jne	3b
 	/* Deadlock detected.  */
 	movl	$EDEADLK, %ecx
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
index 3ebe2a55f8..7d9aa93ebb 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
@@ -165,7 +165,7 @@ pthread_rwlock_timedrdlock:
 	call	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpl	%gs:SELF, %eax
+14:	cmpl	%gs:TID, %eax
 	jne	3b
 	movl	$EDEADLK, %ecx
 	jmp	9b
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
index 9614f24cb2..4a144453fa 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
@@ -135,7 +135,7 @@ pthread_rwlock_timedwrlock:
 
 
 5:	xorl	%ecx, %ecx
-	movl	%gs:SELF, %eax
+	movl	%gs:TID, %eax
 	movl	%eax, WRITER(%ebp)
 9:	LOCK
 #if MUTEX == 0
@@ -163,7 +163,7 @@ pthread_rwlock_timedwrlock:
 	call	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpl	%gs:SELF, %eax
+14:	cmpl	%gs:TID, %eax
 	jne	3b
 20:	movl	$EDEADLK, %ecx
 	jmp	9b
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 0b1cc28986..28c24bad65 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
@@ -97,7 +97,7 @@ __pthread_rwlock_wrlock:
 	jmp	2b
 
 5:	xorl	%ecx, %ecx
-	movl	%gs:SELF, %eax
+	movl	%gs:TID, %eax
 	movl	%eax, WRITER(%ebx)
 9:	LOCK
 #if MUTEX == 0
@@ -122,7 +122,7 @@ __pthread_rwlock_wrlock:
 	call	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpl	%gs:SELF, %eax
+14:	cmpl	%gs:TID	, %eax
 	jne	3b
 	movl	$EDEADLK, %ecx
 	jmp	9b
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
index e2391a7907..afd2f31465 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
@@ -112,9 +112,10 @@ typedef union
     unsigned int __writer_wakeup;
     unsigned int __nr_readers_queued;
     unsigned int __nr_writers_queued;
-    pthread_t __writer;
-    unsigned long int __pad1;
+    int __writer;
+    int __pad1;
     unsigned long int __pad2;
+    unsigned long int __pad3;
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
index 588f2a21b9..8f3e64d75b 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
@@ -128,9 +128,10 @@ typedef union
     unsigned int __writer_wakeup;
     unsigned int __nr_readers_queued;
     unsigned int __nr_writers_queued;
-    pthread_t __writer;
-    unsigned long int __pad1;
+    int __writer;
+    int __pad1;
     unsigned long int __pad2;
+    unsigned long int __pad3;
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
@@ -147,7 +148,7 @@ typedef union
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
-    pthread_t __writer;
+    int __writer;
   } __data;
 # endif
   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
index 855af4dcbd..e34875f996 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
@@ -127,9 +127,10 @@ typedef union
     unsigned int __writer_wakeup;
     unsigned int __nr_readers_queued;
     unsigned int __nr_writers_queued;
-    pthread_t __writer;
-    unsigned long int __pad1;
+    int __writer;
+    int __pad1;
     unsigned long int __pad2;
+    unsigned long int __pad3;
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
@@ -146,7 +147,7 @@ typedef union
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
-    pthread_t __writer;
+    int __writer;
   } __data;
 # endif
   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
index 7c12db6fc6..b2919ab4c6 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
@@ -112,9 +112,10 @@ typedef union
     unsigned int __writer_wakeup;
     unsigned int __nr_readers_queued;
     unsigned int __nr_writers_queued;
-    pthread_t __writer;
-    unsigned long int __pad1;
+    int __writer;
+    int __pad1;
     unsigned long int __pad2;
+    unsigned long int __pad3;
     /* FLAGS must stay at this position in the structure to maintain
        binary compatibility.  */
     unsigned int __flags;
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 0b0ccf7027..0fd093e7dd 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
@@ -52,8 +52,8 @@ __pthread_rwlock_rdlock:
 	testl	%esi, %esi
 	jne	1f
 
-2:	movq	WRITER(%rdi), %rax
-	testq	%rax, %rax
+2:	movl	WRITER(%rdi), %eax
+	testl	%eax, %eax
 	jne	14f
 	cmpl	$0, WRITERS_QUEUED(%rdi)
 	je	5f
@@ -119,7 +119,7 @@ __pthread_rwlock_rdlock:
 #endif
 	jmp	2b
 
-14:	cmpq	%fs:SELF, %rax
+14:	cmpl	%fs:TID, %eax
 	jne	3b
 	/* Deadlock detected.  */
 	movq	$EDEADLK, %rdx
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
index b522f3c07e..582e030abc 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
@@ -62,8 +62,8 @@ pthread_rwlock_timedrdlock:
 	testl	%esi, %esi
 	jne	1f
 
-2:	movq	WRITER(%r12), %rax
-	testq	%rax, %rax
+2:	movl	WRITER(%r12), %eax
+	testl	%eax, %eax
 	jne	14f
 	cmpl	$0, WRITERS_QUEUED(%r12)
 	je	5f
@@ -166,7 +166,7 @@ pthread_rwlock_timedrdlock:
 	callq	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpq	%fs:SELF, %rax
+14:	cmpl	%fs:TID, %eax
 	jne	3b
 	movq	$EDEADLK, %rdx
 	jmp	9b
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
index 6cbadabb07..e7acab538a 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
@@ -61,8 +61,8 @@ pthread_rwlock_timedwrlock:
 	testl	%esi, %esi
 	jne	1f
 
-2:	movq	WRITER(%r12), %rax
-	testq	%rax, %rax
+2:	movl	WRITER(%r12), %eax
+	testl	%eax, %eax
 	jne	14f
 	cmpl	$0, NR_READERS(%r12)
 	je	5f
@@ -137,8 +137,8 @@ pthread_rwlock_timedwrlock:
 
 
 5:	xorq	%rdx, %rdx
-	movq	%fs:SELF, %rax
-	movq	%rax, WRITER(%r12)
+	movl	%fs:TID, %eax
+	movl	%eax, WRITER(%r12)
 9:	LOCK
 #if MUTEX == 0
 	decl	(%r12)
@@ -162,7 +162,7 @@ pthread_rwlock_timedwrlock:
 	callq	__lll_mutex_lock_wait
 	jmp	2b
 
-14:	cmpq	%fs:SELF, %rax
+14:	cmpl	%fs:TID, %eax
 	jne	3b
 20:	movq	$EDEADLK, %rdx
 	jmp	9b
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 9e7336b20e..f866d2e271 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
@@ -52,8 +52,8 @@ __pthread_rwlock_wrlock:
 	testl	%esi, %esi
 	jne	1f
 
-2:	movq	WRITER(%rdi), %rax
-	testq	%rax, %rax
+2:	movl	WRITER(%rdi), %eax
+	testl	%eax, %eax
 	jne	14f
 	cmpl	$0, NR_READERS(%rdi)
 	je	5f
@@ -93,8 +93,8 @@ __pthread_rwlock_wrlock:
 	jmp	2b
 
 5:	xorq	%rdx, %rdx
-	movq	%fs:SELF, %rax
-	movq	%rax, WRITER(%rdi)
+	movl	%fs:TID, %eax
+	movl	%eax, WRITER(%rdi)
 9:	LOCK
 #if MUTEX == 0
 	decl	(%rdi)
@@ -117,7 +117,7 @@ __pthread_rwlock_wrlock:
 #endif
 	jmp	2b
 
-14:	cmpq	%fs:SELF, %rax
+14:	cmpl	%fs:TID, %eax
 	jne	3b
 	movq	$EDEADLK, %rdx
 	jmp	9b
diff --git a/nptl/sysdeps/x86_64/tcb-offsets.sym b/nptl/sysdeps/x86_64/tcb-offsets.sym
index e2abc02647..e230e3dfb3 100644
--- a/nptl/sysdeps/x86_64/tcb-offsets.sym
+++ b/nptl/sysdeps/x86_64/tcb-offsets.sym
@@ -1,7 +1,7 @@
 #include <sysdep.h>
 #include <tls.h>
 
-SELF			offsetof (tcbhead_t, self)
+TID			offsetof (struct pthread, tid)
 CLEANUP			offsetof (struct pthread, cleanup)
 CLEANUP_PREV		offsetof (struct _pthread_cleanup_buffer, __prev)
 MUTEX_FUTEX		offsetof (pthread_mutex_t, __data.__lock)