Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
	* tst-basic1.c (do_test): Add cast to avoid warning.
	* tst-basic2.c (do_test): Likewise.
  • Loading branch information
Ulrich Drepper committed Mar 15, 2003
1 parent 9b89567 commit 92ed3da
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 147 deletions.
3 changes: 3 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
34 changes: 20 additions & 14 deletions nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -140,28 +145,29 @@ __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

cmpl $0, (%rdi)
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
37 changes: 22 additions & 15 deletions nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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. */
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -198,23 +200,23 @@ __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. */
3:
#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. */
5:
#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
Expand All @@ -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. */
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -122,34 +122,34 @@ __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
jmp 7b

/* 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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 92ed3da

Please sign in to comment.