1 /* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include <shlib-compat.h>
22 #include <pthread-errnos.h>
32 /* For the calculation see asm/vsyscall.h. */
33 #define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
39 .type sem_timedwait,@function
55 /* Check whether the timeout value is valid. */
57 cfi_adjust_cfa_offset(8)
59 cfi_adjust_cfa_offset(8)
61 cfi_adjust_cfa_offset(8)
63 cfi_adjust_cfa_offset(24)
66 cfi_offset(12, -16) /* %r12 */
68 cfi_offset(13, -24) /* %r13 */
70 /* Check for invalid nanosecond field. */
71 cmpq $1000000000, 8(%r13)
73 cfi_offset(14, -24) /* %r14 */
78 movq $VSYSCALL_ADDR_vgettimeofday, %rax
81 /* Compute relative timeout. */
84 mul %rdi /* Milli seconds to nano seconds. */
90 addq $1000000000, %rsi
93 movl $ETIMEDOUT, %r14d
94 js 6f /* Time is already up. */
96 movq %rdi, (%rsp) /* Store relative timeout. */
99 call __pthread_enable_asynccancel
105 movl $SYS_futex, %eax
111 call __pthread_disable_asynccancel
115 cmpq $-EWOULDBLOCK, %r14
124 cmpxchgl %ecx, (%r12)
129 cfi_adjust_cfa_offset(-24)
131 cfi_adjust_cfa_offset(-8)
134 cfi_adjust_cfa_offset(-8)
137 cfi_adjust_cfa_offset(-8)
141 cfi_adjust_cfa_offset(48)
142 cfi_offset(12, -16) /* %r12 */
143 cfi_offset(13, -24) /* %r13 */
144 cfi_offset(14, -32) /* %r14 */
148 movq errno@gottpoff(%rip), %rdx
149 movl %r14d, %fs:(%rdx)
151 callq __errno_location@plt
158 .size sem_timedwait,.-sem_timedwait