diff options
-rw-r--r-- | nptl/ChangeLog | 3 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S | 34 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S | 37 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S | 22 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S | 2 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S | 20 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S | 85 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S | 74 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S | 6 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S | 16 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S | 21 | ||||
-rw-r--r-- | nptl/tst-basic1.c | 4 | ||||
-rw-r--r-- | nptl/tst-basic2.c | 2 |
15 files changed, 183 insertions, 147 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 9a132757ca..d7e2c4c67b 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,5 +1,8 @@ 2003-03-14 Ulrich Drepper <drepper@redhat.com> + * tst-basic1.c (do_test): Add cast to avoid warning. + * tst-basic2.c (do_test): Likewise. + * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Use correct amount of stack correction. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S index 9068f3ba46..755bb25896 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S @@ -30,11 +30,13 @@ # endif #endif -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + /* Modified: %rax, %rsi. */ .globl __lll_lock_wait @@ -49,7 +51,7 @@ __lll_lock_wait: 1: leaq -1(%rsi), %rdx /* account for the preceeded xadd. */ - movq %r10, %rsi /* movl $FUTEX_WAIT, %ecx */ + movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */ movq $SYS_futex, %rax syscall @@ -112,23 +114,26 @@ __lll_unlock_wake: .hidden __lll_timedwait_tid .align 16 __lll_timedwait_tid: - movq %rdi, %r8 - movq %rsi, %r9 + pushq %r12 + pushq %r13 + + movq %rdi, %r12 + movq %rsi, %r13 subq $16, %rsp /* Get current time. */ 2: movq %rsp, %rdi xorq %rsi, %rsi - movq $SYS_gettimeofday, %rax - syscall + movq $VSYSCALL_ADDR_vgettimeofday, %rax + callq *%rax /* Compute relative timeout. */ movq 8(%rsp), %rax movq $1000, %rdi mul %rdi /* Milli seconds to nano seconds. */ - movq (%r9), %rdi - movq 8(%r9), %rsi + movq (%r13), %rdi + movq 8(%r13), %rsi subq (%rsp), %rdi subq %rax, %rsi jns 5f @@ -140,13 +145,13 @@ __lll_timedwait_tid: movq %rdi, (%rsp) /* Store relative timeout. */ movq %rsi, 8(%rsp) - movl (%r8), %edx + movl (%r12), %edx testl %edx, %edx jz 4f movq %rsp, %r10 - xorq %rsi, %rsi /* movl $FUTEX_WAIT, %ecx */ - movq %r8, %rdi + xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */ + movq %r12, %rdi movq $SYS_futex, %rax syscall @@ -154,14 +159,15 @@ __lll_timedwait_tid: jne 1f 4: xorl %eax, %eax - addq $16, %rsp +8: addq $16, %rsp + popq %r13 + popq %r12 retq 1: cmpq $-ETIMEDOUT, %rax jne 2b 6: movl $ETIMEDOUT, %eax - addq $16, %rsp - retq + jmp 8b .size __lll_timedwait_tid,.-__lll_timedwait_tid #endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S index 4612ba6ccf..b6dc9b57ba 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S @@ -30,11 +30,13 @@ # endif #endif -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + .globl __lll_mutex_lock_wait .type __lll_mutex_lock_wait,@function @@ -48,7 +50,7 @@ __lll_mutex_lock_wait: 1: leaq 1(%rsi), %rdx /* account for the preceeded xadd. */ - movq %r10, %rsi /* movl $FUTEX_WAIT, %ecx */ + movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */ movq $SYS_futex, %rax syscall @@ -73,29 +75,33 @@ __lll_mutex_lock_wait: .align 16 __lll_mutex_timedlock_wait: /* Check for a valid timeout value. */ - cmpq $1000000000, 4(%rdx) + cmpq $1000000000, 8(%rdx) jae 3f + pushq %r12 + pushq %r13 + /* Stack frame for the timespec and timeval structs. */ subq $16, %rsp - movq %rdi, %r8 - movq %rdx, %r9 + movq %rdi, %r12 + movq %rdx, %r13 leaq 1(%rax), %rdx /* Get current time. */ -1: - movq %rsp, %rdi +1: movq %rsp, %rdi xorq %rsi, %rsi - movq $SYS_gettimeofday, %rax - syscall + movq $VSYSCALL_ADDR_vgettimeofday, %rax + /* This is a regular function call, all calleer-save registers + might be clobbered. */ + callq *%rax /* Compute relative timeout. */ movq 8(%rsp), %rax movq $1000, %rdi mul %rdi /* Milli seconds to nano seconds. */ - movq (%r9), %rdi - movq 8(%r9), %rsi + movq (%r13), %rdi + movq 8(%r13), %rsi subq (%rsp), %rdi subq %rax, %rsi jns 4f @@ -110,7 +116,7 @@ __lll_mutex_timedlock_wait: movq %rsp, %r10 xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */ - movq %r8, %rdi + movq %r12, %rdi movq $SYS_futex, %rax syscall @@ -123,7 +129,9 @@ __lll_mutex_timedlock_wait: movl $2, (%rdi) xorl %eax, %eax - addq $16, %rsp +8: addq $16, %rsp + popq %r13 + popq %r12 retq /* Check whether the time expired. */ @@ -135,8 +143,7 @@ __lll_mutex_timedlock_wait: retq 5: movl $ETIMEDOUT, %eax - addq $16, %rsp - retq + jmp 8b .size __lll_mutex_timedlock_wait,.-__lll_mutex_timedlock_wait #endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S index 036da43944..fdd2958130 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S @@ -62,7 +62,7 @@ pthread_barrier_wait: /* Wait for the remaining threads. The call will return immediately if the CURR_EVENT memory has meanwhile been changed. */ -7: xorq %rsi, %rsi /* movl $FUTEX_WAIT, %ecx */ +7: xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */ xorq %r10, %r10 8: movq $SYS_futex, %rax syscall 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 a293c52a9d..2198c3a140 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 @@ -28,11 +28,13 @@ # define LOCK lock #endif -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + .text @@ -98,13 +100,13 @@ __pthread_cond_timedwait: jne 3f 4: movq %rsp, %rdi - call __pthread_enable_asynccancel_2 + callq __pthread_enable_asynccancel_2 /* Get the current time. */ leaq 24(%rsp), %rdi - xorq %rcx, %rcx - movq $SYS_gettimeofday, %rax - syscall + xorq %rsi, %rsi + movq $VSYSCALL_ADDR_vgettimeofday, %rax + callq *%rax /* Compute relative timeout. */ movq 32(%rsp), %rax @@ -198,7 +200,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait jmp 2b /* Unlock in loop requires waekup. */ @@ -206,7 +208,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake jmp 4b /* Locking in loop failed. */ @@ -214,7 +216,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if cond_lock != 0 subq $cond_lock, %rdi #endif @@ -225,7 +227,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake jmp 11b /* The initial unlocking of the mutex failed. */ @@ -242,7 +244,7 @@ __pthread_cond_timedwait: #if cond_lock != 0 addq $cond_lock, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake 17: movq (%rsp), %rax jmp 18b 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 5b6f1ea0a7..3bebbd3e49 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 @@ -161,7 +161,7 @@ __pthread_cond_wait: movq %r12, %rdx addq $wakeup_seq-cond_lock, %rdi movq $SYS_futex, %rax - movq %r10, %rsi /* movl $FUTEX_WAIT, %ecx */ + movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */ syscall movq (%rsp), %rdi diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S index 66f8b182fe..4f9ecc713f 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S @@ -72,7 +72,7 @@ __pthread_once: jnz 3f /* Different for generation -> run initializer. */ /* Somebody else got here first. Wait. */ - movq %r10, %rsi /* movl $FUTEX_WAIT, %ecx */ + movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */ movq $SYS_futex, %rax syscall jmp 6b 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 03897e3690..e31d4bb705 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 @@ -74,7 +74,7 @@ __pthread_rwlock_rdlock: jne 10f 11: addq $READERS_WAKEUP-MUTEX, %rdi - movq %r10, %rsi /* movl $FUTEX_WAIT, %ecx */ + movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */ movq $SYS_futex, %rax syscall @@ -94,7 +94,7 @@ __pthread_rwlock_rdlock: 13: decl READERS_QUEUED(%rdi) jmp 2b -5: xorq %rcx, %rcx +5: xorq %rdx, %rdx incl NR_READERS(%rdi) je 8f 9: LOCK @@ -106,14 +106,14 @@ __pthread_rwlock_rdlock: jne 6f 7: - movq %rcx, %rax + movq %rdx, %rax retq 1: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -122,14 +122,14 @@ __pthread_rwlock_rdlock: 14: cmpq %fs:SELF, %rax jne 3b /* Deadlock detected. */ - movq $EDEADLK, %rcx + movq $EDEADLK, %rdx jmp 9b 6: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -137,19 +137,19 @@ __pthread_rwlock_rdlock: /* Overflow. */ 8: decl NR_READERS(%rdi) - movq $EAGAIN, %rcx + movq $EAGAIN, %rdx jmp 9b /* Overflow. */ 4: decl READERS_QUEUED(%rdi) - movq $EAGAIN, %rcx + movq $EAGAIN, %rdx jmp 9b 10: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -159,7 +159,7 @@ __pthread_rwlock_rdlock: #if MUTEX == 0 addq $MUTEX, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if MUTEX != 0 subq $MUTEX, %rdi #endif 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 4df136f939..fd04e116c7 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 @@ -22,11 +22,14 @@ #include <pthread-errnos.h> -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + + #ifndef UP # define LOCK lock #else @@ -40,11 +43,12 @@ .type pthread_rwlock_timedrdlock,@function .align 16 pthread_rwlock_timedrdlock: + pushq %r12 + pushq %r13 subq $16, %rsp - movq %rdi, %r8 - movq %rsi, %r9 - xorq %r10, %r10 + movq %rdi, %r12 + movq %rsi, %r13 /* Get the lock. */ movl $1, %esi @@ -57,44 +61,44 @@ pthread_rwlock_timedrdlock: testl %esi, %esi jne 1f -2: movq WRITER(%r8), %rax +2: movq WRITER(%r12), %rax testq %rax, %rax jne 14f - cmpl $0, WRITERS_QUEUED(%r8) + cmpl $0, WRITERS_QUEUED(%r12) je 5f - cmpl $0, FLAGS(%r8) + cmpl $0, FLAGS(%r12) je 5f /* Check the value of the timeout parameter. */ -3: cmpl $1000000000, 8(%r9) +3: cmpl $1000000000, 8(%r13) jae 19f - incl READERS_QUEUED(%r8) + incl READERS_QUEUED(%r12) je 4f - movl READERS_WAKEUP(%r8), %edx + movl READERS_WAKEUP(%r12), %edx /* Unlock. */ LOCK #if MUTEX == 0 - subl $1, (%r8) + subl $1, (%r12) #else - subl $1, MUTEX(%r8) + subl $1, MUTEX(%r12) #endif jne 10f /* Get current time. */ 11: movq %rsp, %rdi xorq %rsi, %rsi - movq $SYS_gettimeofday, %rax - syscall + movq $VSYSCALL_ADDR_vgettimeofday, %rax + callq *%rax /* Compute relative timeout. */ movq 8(%rsp), %rax movq $1000, %rdi mul %rdi /* Milli seconds to nano seconds. */ - movq (%r9), %rcx - movq 8(%r9), %rdi + movq (%r13), %rcx + movq 8(%r13), %rdi subq (%rsp), %rcx subq %rax, %rdi jns 15f @@ -108,7 +112,8 @@ pthread_rwlock_timedrdlock: movq %rdi, 8(%rsp) xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */ - leaq READERS_WAKEUP(%r8), %rdi + xorq %r10, %r10 + leaq READERS_WAKEUP(%r12), %rdi movq $SYS_futex, %rax syscall movq %rax, %rdx @@ -118,35 +123,37 @@ pthread_rwlock_timedrdlock: movl $1, %esi LOCK #if MUTEX == 0 - xaddl %esi, (%r8) + xaddl %esi, (%r12) #else - xaddl %esi, MUTEX(%r8) + xaddl %esi, MUTEX(%r12) #endif testl %esi, %esi jne 12f -13: decl READERS_QUEUED(%r8) +13: decl READERS_QUEUED(%r12) cmpq $-ETIMEDOUT, %rdx jne 2b -18: movq $ETIMEDOUT, %rcx +18: movq $ETIMEDOUT, %rdx jmp 9f -5: xorq %rcx, %rcx - incl NR_READERS(%r8) +5: xorq %rdx, %rdx + incl NR_READERS(%r12) je 8f 9: LOCK #if MUTEX == 0 - decl (%r8) + decl (%r12) #else - decl MUTEX(%r8) + decl MUTEX(%r12) #endif jne 6f -7: movq %rcx, %rax +7: movq %rdx, %rax addq $16, %rsp + popq %r13 + popq %r12 retq 1: @@ -158,49 +165,49 @@ pthread_rwlock_timedrdlock: 14: cmpq %fs:SELF, %rax jne 3b - movq $EDEADLK, %rcx + movq $EDEADLK, %rdx jmp 9b 6: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leal MUTEX(%r8), %rdi + leal MUTEX(%r12), %rdi #endif callq __lll_mutex_unlock_wake jmp 7b /* Overflow. */ -8: decl NR_READERS(%r8) - movq $EAGAIN, %rcx +8: decl NR_READERS(%r12) + movq $EAGAIN, %rdx jmp 9b /* Overflow. */ -4: decl READERS_QUEUED(%r8) - movq $EAGAIN, %rcx +4: decl READERS_QUEUED(%r12) + movq $EAGAIN, %rdx jmp 9b 10: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leaq MUTEX(%r8), %rdi + leaq MUTEX(%r12), %rdi #endif callq __lll_mutex_unlock_wake jmp 11b 12: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leaq MUTEX(%r8), %rdi + leaq MUTEX(%r12), %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait jmp 13b 16: movq $-ETIMEDOUT, %rdx jmp 17b -19: movq $EINVAL, %rcx +19: movq $EINVAL, %rdx jmp 9b .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock 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 a6a02a98a5..75c6cc42b4 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 @@ -22,11 +22,13 @@ #include <pthread-errnos.h> -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + #ifndef UP # define LOCK lock #else @@ -40,10 +42,12 @@ .type pthread_rwlock_timedwrlock,@function .align 16 pthread_rwlock_timedwrlock: + pushq %r12 + pushq %r13 subq $16, %rsp - movq %rdi, %r8 - movq %rsi, %r9 + movq %rdi, %r12 + movq %rsi, %r13 /* Get the lock. */ movl $1, %esi @@ -56,41 +60,41 @@ pthread_rwlock_timedwrlock: testl %esi, %esi jne 1f -2: movq WRITER(%r8), %rax +2: movq WRITER(%r12), %rax testq %rax, %rax jne 14f - cmpl $0, NR_READERS(%r8) + cmpl $0, NR_READERS(%r12) je 5f /* Check the value of the timeout parameter. */ -3: cmpq $1000000000, 8(%r9) +3: cmpq $1000000000, 8(%r13) jae 19f - incl WRITERS_QUEUED(%r8) + incl WRITERS_QUEUED(%r12) je 4f - movl WRITERS_WAKEUP(%r8), %edx + movl WRITERS_WAKEUP(%r12), %edx LOCK #if MUTEX == 0 - decl (%r8) + decl (%r12) #else - decl MUTEX(%r8) + decl MUTEX(%r12) #endif jne 10f /* Get current time. */ 11: movq %rsp, %rdi xorq %rsi, %rsi - movq $SYS_gettimeofday, %rax - syscall + movq $VSYSCALL_ADDR_vgettimeofday, %rax + callq *%rax /* Compute relative timeout. */ movq 8(%rsp), %rax movq $1000, %rdi mul %rdi /* Milli seconds to nano seconds. */ - movq (%r9), %rcx - movq 8(%r9), %rdi + movq (%r13), %rcx + movq 8(%r13), %rdi subq (%rsp), %rcx subq %rax, %rdi jns 15f @@ -105,7 +109,7 @@ pthread_rwlock_timedwrlock: xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */ movq %rsp, %r10 - leaq WRITERS_WAKEUP(%r8), %rdi + leaq WRITERS_WAKEUP(%r12), %rdi movq $SYS_futex, %rax syscall movq %rax, %rdx @@ -115,35 +119,37 @@ pthread_rwlock_timedwrlock: movl $1, %esi LOCK #if MUTEX == 0 - xaddl %esi, (%r8) + xaddl %esi, (%r12) #else - xaddl %esi, MUTEX(%r8) + xaddl %esi, MUTEX(%r12) #endif testl %esi, %esi jne 12f -13: decl WRITERS_QUEUED(%r8) +13: decl WRITERS_QUEUED(%r12) cmpq $-ETIMEDOUT, %rdx jne 2b -18: movq $ETIMEDOUT, %rcx +18: movq $ETIMEDOUT, %rdx jmp 9f -5: xorq %rcx, %rcx +5: xorq %rcx, %rdx movq %fs:SELF, %rax - movq %rax, WRITER(%r8) + movq %rax, WRITER(%r12) 9: LOCK #if MUTEX == 0 - decl (%r8) + decl (%r12) #else - decl MUTEX(%r8) + decl MUTEX(%r12) #endif jne 6f -7: movq %rcx, %rax +7: movq %rdx, %rax addq $16, %rsp + popq %r13 + popq %r12 retq 1: @@ -155,37 +161,37 @@ pthread_rwlock_timedwrlock: 14: cmpq %fs:SELF, %rax jne 3b -20: movq $EDEADLK, %rcx +20: movq $EDEADLK, %rdx jmp 9b 6: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leal MUTEX(%r8), %rdi + leal MUTEX(%r12), %rdi #endif callq __lll_mutex_unlock_wake jmp 7b /* Overflow. */ -4: decl WRITERS_QUEUED(%r8) - movq $EAGAIN, %rcx +4: decl WRITERS_QUEUED(%r12) + movq $EAGAIN, %rdx jmp 9b 10: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leaq MUTEX(%r8), %rdi + leaq MUTEX(%r12), %rdi #endif callq __lll_mutex_unlock_wake jmp 11b 12: #if MUTEX == 0 - movq %r8, %rdi + movq %r12, %rdi #else - leaq MUTEX(%r8), %rdi + leaq MUTEX(%r12), %rdi #endif callq __lll_mutex_lock_wait jmp 13b @@ -193,6 +199,6 @@ pthread_rwlock_timedwrlock: 16: movq $-ETIMEDOUT, %rdx jmp 17b -19: movq $EINVAL, %rcx +19: movq $EINVAL, %rdx jmp 9b .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock 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 233f609b1e..4f487fb8df 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 @@ -101,7 +101,7 @@ __pthread_rwlock_unlock: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -111,7 +111,7 @@ __pthread_rwlock_unlock: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -121,7 +121,7 @@ __pthread_rwlock_unlock: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake #if MUTEX != 0 subq $MUTEX, %rdi #endif 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 5d63df8e84..0afe46a246 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 @@ -92,7 +92,7 @@ __pthread_rwlock_wrlock: 13: decl WRITERS_QUEUED(%rdi) jmp 2b -5: xorq %rcx, %rcx +5: xorq %rdx, %rdx movq %fs:SELF, %rax movq %rax, WRITER(%rdi) 9: LOCK @@ -104,14 +104,14 @@ __pthread_rwlock_wrlock: jne 6f 7: - movq %rcx, %rax + movq %rdx, %rax retq 1: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -119,25 +119,25 @@ __pthread_rwlock_wrlock: 14: cmpq %fs:SELF, %rax jne 3b - movq $EDEADLK, %rcx + movq $EDEADLK, %rdx jmp 9b 6: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake jmp 7b 4: decl WRITERS_QUEUED(%rdi) - movl $EAGAIN, %ecx + movl $EAGAIN, %edx jmp 9b 10: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_unlock_wake + callq __lll_mutex_unlock_wake #if MUTEX != 0 subq $MUTEX, %rdi #endif @@ -147,7 +147,7 @@ __pthread_rwlock_wrlock: #if MUTEX != 0 addq $MUTEX, %rdi #endif - call __lll_mutex_lock_wait + callq __lll_mutex_lock_wait #if MUTEX != 0 subq $MUTEX, %rdi #endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S index af52f2a670..21eae3a14c 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -27,9 +27,11 @@ # define #endif -#define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 202 +/* For the calculation see asm/vsyscall.h. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + .text @@ -50,9 +52,10 @@ sem_timedwait: retq /* Check whether the timeout value is valid. */ -1: subq $16, %rsp +1: pushq %r12 + pushq %r13 + subq $16, %rsp - movq %rsp, %r10 movq %rdi, %r8 movq %rsi, %r9 @@ -63,8 +66,8 @@ sem_timedwait: 7: xorq %rsi, %rsi movq %rsp, %rdi - movq $SYS_gettimeofday, %rax - syscall + movq $VSYSCALL_ADDR_vgettimeofday, %rax + callq *%rax /* Compute relative timeout. */ movq 8(%rsp), %rax @@ -84,6 +87,7 @@ sem_timedwait: movq %rdi, (%rsp) /* Store relative timeout. */ movq %rsi, 8(%rsp) + movq %rsp, %r10 movq %r8, %rdi xorq %rsi, %rsi movq $SYS_futex, %rax @@ -104,8 +108,10 @@ sem_timedwait: cmpxchgl %ecx, (%rdi) jne 8b - addq $16, %rsp xorl %eax, %eax +10: addq $16, %rsp + popq %r13 + popq %r12 retq 3: negq %rax @@ -119,7 +125,6 @@ sem_timedwait: movl %edx, (%rax) #endif - addq $16, %rsp orl $-1, %eax - retq + jmp 10b .size sem_timedwait,.-sem_timedwait diff --git a/nptl/tst-basic1.c b/nptl/tst-basic1.c index 8bb736ec6f..7637c8e497 100644 --- a/nptl/tst-basic1.c +++ b/nptl/tst-basic1.c @@ -48,7 +48,7 @@ do_test (void) int i; for (i = 0; i < N; ++i) - if (pthread_create (&t[i], NULL, tf, (void *) (i + 1)) != 0) + if (pthread_create (&t[i], NULL, tf, (void *) (long int) (i + 1)) != 0) { write (2, "create failed\n", 14); _exit (1); @@ -65,7 +65,7 @@ do_test (void) printf ("join failed: %d\n", e); _exit (1); } - else if (r != (void *) (i + 1)) + else if (r != (void *) (long int) (i + 1)) { write (2, "result wrong\n", 13); _exit (1); diff --git a/nptl/tst-basic2.c b/nptl/tst-basic2.c index 9bc20602d6..b9478c0812 100644 --- a/nptl/tst-basic2.c +++ b/nptl/tst-basic2.c @@ -64,7 +64,7 @@ do_test (void) exit (1); } - if (pthread_create (&th[i], NULL, tf, (void *) i) != 0) + if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0) { puts ("create failed"); exit (1); |