+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,
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 \
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;
}
#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)
/* 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;
/* 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;
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;
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;
/* 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;
call __lll_mutex_lock_wait
jmp 2b
-14: cmpl %gs:SELF, %eax
+14: cmpl %gs:TID, %eax
jne 3b
/* Deadlock detected. */
movl $EDEADLK, %ecx
call __lll_mutex_lock_wait
jmp 2b
-14: cmpl %gs:SELF, %eax
+14: cmpl %gs:TID, %eax
jne 3b
movl $EDEADLK, %ecx
jmp 9b
5: xorl %ecx, %ecx
- movl %gs:SELF, %eax
+ movl %gs:TID, %eax
movl %eax, WRITER(%ebp)
9: LOCK
#if MUTEX == 0
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
jmp 2b
5: xorl %ecx, %ecx
- movl %gs:SELF, %eax
+ movl %gs:TID, %eax
movl %eax, WRITER(%ebx)
9: LOCK
#if MUTEX == 0
call __lll_mutex_lock_wait
jmp 2b
-14: cmpl %gs:SELF, %eax
+14: cmpl %gs:TID , %eax
jne 3b
movl $EDEADLK, %ecx
jmp 9b
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;
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;
/* 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];
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;
/* 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];
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;
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
#endif
jmp 2b
-14: cmpq %fs:SELF, %rax
+14: cmpl %fs:TID, %eax
jne 3b
/* Deadlock detected. */
movq $EDEADLK, %rdx
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
callq __lll_mutex_lock_wait
jmp 2b
-14: cmpq %fs:SELF, %rax
+14: cmpl %fs:TID, %eax
jne 3b
movq $EDEADLK, %rdx
jmp 9b
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
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)
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
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
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)
#endif
jmp 2b
-14: cmpq %fs:SELF, %rax
+14: cmpl %fs:TID, %eax
jne 3b
movq $EDEADLK, %rdx
jmp 9b
#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)