From 7726edc27354afe163f492c0e6a8d4354fddb494 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 8 Jun 2003 05:28:14 +0000 Subject: Update. 2003-06-07 Ulrich Drepper * cleanup_routine.c: New file. * Versions (libpthread) [GLIBC_2.3.3]: Add __pthread_cleanup_routine. * sysdeps/pthread/pthread.h: Add support for fully exception-based cleanup handling. * Makefile (libpthread-routines): Add cleanup_routine. Add more CFLAGS variables to compile with exceptions. Add comments why which file needs unwind tables. (tests) [have-forced-unwind==yes]: Add tst-cancelx* and tst-cleanupx* tests. * tst-cancelx1.c: New file. * tst-cancelx2.c: New file. * tst-cancelx3.c: New file. * tst-cancelx4.c: New file. * tst-cancelx5.c: New file. * tst-cancelx6.c: New file. * tst-cancelx7.c: New file. * tst-cancelx8.c: New file. * tst-cancelx9.c: New file. * tst-cancelx10.c: New file. * tst-cancelx11.c: New file. * tst-cancelx12.c: New file. * tst-cancelx13.c: New file. * tst-cancelx14.c: New file. * tst-cancelx15.c: New file. * tst-cleanupx0.c: New file. * tst-cleanupx0.expect: New file. * tst-cleanupx1.c: New file. * tst-cleanupx2.c: New file. * tst-cleanupx3.c: New file. * tst-cleanup0.c: Make standard compliant. * tst-cleanup1.c: Likewise. * sysdeps/unix/sysv/linux/sem_timedwait.c: Add cancellation support. * sysdeps/unix/sysv/linux/sem_wait.c: Likewise. * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise. * sysdeps/i386/tcb-offsets.sym: Add RESULT, CANCELHANDLING, and CLEANUP_JMP_BUF. * sysdeps/x86_64/tcb-offsets.sym: Likewise. * tst-cancel12.c: New file. * tst-cancel13.c: New file. * tst-cancel14.c: New file. * tst-cancel15.c: New file. * Makefile (tests): Add tst-cancel12, tst-cancel13, tst-cancel14, and tst-cancel15. * tst-cancel1.c: Add some comments. * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Compute relative timeout correctly. --- .../sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S | 75 +++++++++++++++++----- 1 file changed, 60 insertions(+), 15 deletions(-) (limited to 'nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S') 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 29bc1bcf46..7626d7b250 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -38,7 +38,14 @@ .globl sem_timedwait .type sem_timedwait,@function .align 16 + cfi_startproc sem_timedwait: + /* First check for cancellation. */ + movl %fs:CANCELHANDLING, %eax + andl $0xfffffff9, %eax + cmpl $8, %eax + je 11f + movl (%rdi), %eax 2: testl %eax, %eax je 1f @@ -53,18 +60,29 @@ sem_timedwait: /* Check whether the timeout value is valid. */ 1: pushq %r12 + cfi_adjust_cfa_offset(8) pushq %r13 - subq $16, %rsp + cfi_adjust_cfa_offset(8) + pushq %r14 + cfi_adjust_cfa_offset(8) + subq $24, %rsp + cfi_adjust_cfa_offset(24) movq %rdi, %r12 + cfi_offset(12, -16) /* %r12 */ movq %rsi, %r13 + cfi_offset(13, -24) /* %r13 */ /* Check for invalid nanosecond field. */ cmpq $1000000000, 8(%r13) - movl $EINVAL, %eax + movl $EINVAL, %r14d + cfi_offset(14, -24) /* %r14 */ jae 6f -7: xorq %rsi, %rsi +7: call __pthread_enable_asynccancel + movl %eax, 16(%rsp) + + xorq %rsi, %rsi movq %rsp, %rdi movq $VSYSCALL_ADDR_vgettimeofday, %rax callq *%rax @@ -74,14 +92,14 @@ sem_timedwait: movq $1000, %rdi mul %rdi /* Milli seconds to nano seconds. */ movq (%r13), %rdi - movq 8(%r13), %rdi + movq 8(%r13), %rsi subq (%rsp), %rdi - subq %rax, %rdi + subq %rax, %rsi jns 5f addq $1000000000, %rsi decq %rdi 5: testq %rdi, %rdi - movl $ETIMEDOUT, %eax + movl $ETIMEDOUT, %r14d js 6f /* Time is already up. */ movq %rdi, (%rsp) /* Store relative timeout. */ @@ -93,38 +111,65 @@ sem_timedwait: movq $SYS_futex, %rax xorl %edx, %edx syscall + movq %rax, %r14 - testq %rax, %rax + movl 16(%rsp), %edi + call __pthread_disable_asynccancel + + testq %r14, %r14 je 9f - cmpq $-EWOULDBLOCK, %rax + cmpq $-EWOULDBLOCK, %r14 jne 3f -9: movl (%rdi), %eax +9: movl (%r12), %eax 8: testl %eax, %eax je 7b leaq -1(%rax), %rcx LOCK - cmpxchgl %ecx, (%rdi) + cmpxchgl %ecx, (%r12) jne 8b xorl %eax, %eax -10: addq $16, %rsp +10: addq $24, %rsp + cfi_adjust_cfa_offset(-24) + popq %r14 + cfi_adjust_cfa_offset(-8) + cfi_restore(14) popq %r13 + cfi_adjust_cfa_offset(-8) + cfi_restore(13) popq %r12 + cfi_adjust_cfa_offset(-8) + cfi_restore(12) retq -3: negq %rax + cfi_adjust_cfa_offset(48) + cfi_offset(12, -16) /* %r12 */ + cfi_offset(13, -24) /* %r13 */ + cfi_offset(14, -32) /* %r14 */ +3: negq %r14 6: #if USE___THREAD movq errno@gottpoff(%rip), %rdx - movl %eax, %fs:(%rdx) + movl %r14d, %fs:(%rdx) #else - movl %eax, %edx callq __errno_location@plt - movl %edx, (%rax) + movl %r14d, (%rax) #endif orl $-1, %eax jmp 10b + cfi_adjust_cfa_offset(-48) + cfi_restore(14) + cfi_restore(13) + cfi_restore(12) + +11: /* Canceled. */ + movq $0xffffffffffffffff, %fs:RESULT + LOCK + orl $0x10, %fs:CANCELHANDLING + movq %fs:CLEANUP_JMP_BUF, %rdi + jmp __pthread_unwind + cfi_endproc .size sem_timedwait,.-sem_timedwait -- cgit 1.4.1