From 6162364368b2092b2bd7b1ba26366ba9a841787a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 22 Jun 2003 23:55:27 +0000 Subject: Update. 2003-06-22 Ulrich Drepper * pthreadP.h (__pthread_mutex_init_internal): Mark hidden. (__pthread_mutex_lock_internal): Likewise. (__pthread_mutex_unlock_internal): Likewise. (__pthread_mutex_unlock_usercnt): Declare. * pthread_mutex_destroy.c: Always fail if used in any way. * pthread_mutex_init.c: Update comment. * pthread_mutex_lock.c: If NO_INCR is not defined adjust __nusers. * pthread_mutex_timedlock.c: Adjust __nusers. * pthread_mutex_trylock.c: Adjust __nusers. * pthread_mutex_unlock.c: Old code is in __pthread_mutex_unlock_usercnt and public interfaces are wrapper with pass additional parameter. __pthread_mutex_unlock_usercnt does not adjust __nusers if second parameter zero. * tst-mutex8.c: New file. * Makefile (tests): Add tst-mutex8. * sysdeps/pthread/pthread_cond_timedwait.c: Call __pthread_mutex_unlock_usercnt. * sysdeps/pthread/pthread_cond_wait.c: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Define NO_INCR. * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t): Add __nusers. * sysdeps/unix/sysv/linux/ia64/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/sh/bits/pthreadtypes.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise. * pthread_mutex_lock.c: Don't store THREAD_ID in __owner, use TID. * pthread_mutex_timedlock.c: Likewise. * pthread_mutex_trylock.c: Adjust __nusers. * pthread_mutex_unlock.c: Compare with TID not THREAD_ID. * tst-mutex9.c: New file. * Makefile (tests): Add tst-mutex9. * sysdeps/i386/tls.h: Remove THREAD_ID definition. * sysdeps/ia64/tls.h: Likewise. * sysdeps/powerpc/tls.h: Likewise. * sysdeps/s390/tls.h: Likewise. * sysdeps/sh/tls.h: Likewise. * sysdeps/x86_64/tls.h: Likewise. * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t): Change type of __owner. * sysdeps/unix/sysv/linux/ia64/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/sh/bits/pthreadtypes.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise. --- nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h | 3 ++- .../sysv/linux/i386/i486/pthread_cond_timedwait.S | 19 ++++++++----------- .../unix/sysv/linux/i386/i486/pthread_cond_wait.S | 19 ++++++++----------- nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h | 3 ++- .../unix/sysv/linux/powerpc/bits/pthreadtypes.h | 8 +++++++- .../sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c | 1 + nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h | 8 +++++++- nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h | 3 ++- .../unix/sysv/linux/x86_64/bits/pthreadtypes.h | 3 ++- .../unix/sysv/linux/x86_64/pthread_cond_timedwait.S | 3 ++- .../unix/sysv/linux/x86_64/pthread_cond_wait.S | 3 ++- 11 files changed, 43 insertions(+), 30 deletions(-) (limited to 'nptl/sysdeps/unix') diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h index 256589da0d..a098106629 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h @@ -51,10 +51,11 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; + unsigned int __nusers; } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; 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 5eec268b29..2f598980e5 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 @@ -72,9 +72,8 @@ __pthread_cond_timedwait: movl %eax, dep_mutex(%ebx) /* Unlock the mutex. */ - pushl %eax -.Lpush4: - call __pthread_mutex_unlock_internal + xorl %edx, %edx + call __pthread_mutex_unlock_usercnt testl %eax, %eax jne 16f @@ -90,7 +89,7 @@ __pthread_cond_timedwait: #else leal __condvar_cleanup, %eax #endif - subl $40, %esp + subl $44, %esp .Lsubl: leal 28(%esp), %edx movl %esp, 8(%esp) @@ -299,15 +298,15 @@ __pthread_cond_timedwait: /* The initial unlocking of the mutex failed. */ 16: .LSbl3: - movl %eax, (%esp) LOCK #if cond_lock == 0 subl $1, (%ebx) #else subl $1, cond_lock(%ebx) #endif - jne 17f + jne 18b + movl %eax, %esi #if cond_lock == 0 movl %ebx, %eax #else @@ -315,7 +314,7 @@ __pthread_cond_timedwait: #endif call __lll_mutex_unlock_wake -17: popl %eax + movl %esi, %eax jmp 18b #if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS @@ -411,10 +410,8 @@ versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait, .uleb128 20 .byte 0x83 # DW_CFA_offset %ebx .uleb128 5 - .byte 0x40+.Lpush4-.Lpush_ebx # DW_CFA_advance_loc+N - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 24 - .byte 0x40+.Lsubl-.Lpush4 # DW_CFA_advance_loc+N + .byte 2 # DW_CFA_advance_loc1 + .byte .Lsubl-.Lpush_ebx .byte 14 # DW_CFA_def_cfa_offset .uleb128 64 .byte 3 # DW_CFA_advance_loc2 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 61d3d8d225..c98899ab05 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 @@ -127,9 +127,8 @@ __pthread_cond_wait: movl %eax, dep_mutex(%ebx) /* Unlock the mutex. */ - pushl %eax -.Lpush4: - call __pthread_mutex_unlock_internal + xorl %edx, %edx + call __pthread_mutex_unlock_usercnt testl %eax, %eax jne 12f @@ -145,7 +144,7 @@ __pthread_cond_wait: #else leal __condvar_cleanup, %eax #endif - subl $32, %esp + subl $36, %esp .Lsubl: leal 20(%esp), %edx movl %esp, 8(%esp) @@ -289,15 +288,15 @@ __pthread_cond_wait: /* The initial unlocking of the mutex failed. */ 12: .LSbl3: - movl %eax, (%esp) LOCK #if cond_lock == 0 subl $1, (%ebx) #else subl $1, cond_lock(%ebx) #endif - jne 13f + jne 14b + movl %eax, %esi #if cond_lock == 0 movl %ebx, %eax #else @@ -305,7 +304,7 @@ __pthread_cond_wait: #endif call __lll_mutex_unlock_wake -13: popl %eax + movl %esi, %eax jmp 14b .LENDCODE: .size __pthread_cond_wait, .-__pthread_cond_wait @@ -371,10 +370,8 @@ versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, .uleb128 16 .byte 0x83 # DW_CFA_offset %ebx .uleb128 4 - .byte 0x40+.Lpush4-.Lpush_ebx # DW_CFA_advance_loc+N - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 20 - .byte 0x40+.Lsubl-.Lpush4 # DW_CFA_advance_loc+N + .byte 2 # DW_CFA_advance_loc1 + .byte .Lsubl-.Lpush_ebx .byte 14 # DW_CFA_def_cfa_offset .uleb128 52 .byte 2 # DW_CFA_advance_loc1 diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h index afd2f31465..c1eca62be7 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h @@ -51,7 +51,8 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; + unsigned int __nusers; /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h index 8f3e64d75b..f827b3098d 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h @@ -66,10 +66,16 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; +#if __WORDSIZE != 64 + unsigned int __nusers; +#endif } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c b/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c index 893a5e932d..d253c72ea4 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c +++ b/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c @@ -2,5 +2,6 @@ #define LLL_MUTEX_LOCK(mutex) lll_mutex_cond_lock(mutex) #define __pthread_mutex_lock __pthread_mutex_cond_lock +#define NO_INCR #include diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h index e34875f996..2d37683ee2 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h @@ -65,10 +65,16 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; +#if __WORDSIZE != 64 + unsigned int __nusers; +#endif } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; diff --git a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h index 1eeae708e1..8236fd724a 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h @@ -52,10 +52,11 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; + unsigned int __nusers; } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; 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 b2919ab4c6..ed3050e636 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h @@ -51,7 +51,8 @@ typedef union { int __lock; unsigned int __count; - struct pthread *__owner; + int __owner; + unsigned int __nusers; /* KIND must stay at this position in the structure to maintain binary compatibility. */ int __kind; 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 b64953ba83..b2b4449554 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 @@ -91,7 +91,8 @@ __pthread_cond_timedwait: /* Unlock the mutex. */ 2: movq 16(%rsp), %rdi - callq __pthread_mutex_unlock_internal + xorq %rsi, %rsi + callq __pthread_mutex_unlock_usercnt testl %eax, %eax jne 16f 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 2c6c6ce338..3942faf1ad 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 @@ -136,7 +136,8 @@ __pthread_cond_wait: /* Unlock the mutex. */ 2: movq 16(%rsp), %rdi - callq __pthread_mutex_unlock_internal + xorq %rsi, %rsi + callq __pthread_mutex_unlock_usercnt testl %eax, %eax jne 12f -- cgit 1.4.1