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 <lowlevellock.h>
22 #include <shlib-compat.h>
23 #include <pthread-errnos.h>
24 #include <structsem.h>
27 /* For the calculation see asm/vsyscall.h. */
28 #define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
33 .type sem_timedwait,@function
40 movl VALUE(%rdi), %eax
50 cmpxchgl %edx, VALUE(%rdi)
57 /* Check whether the timeout value is valid. */
70 /* Check for invalid nanosecond field. */
71 cmpq $1000000000, 8(%r13)
76 addq $1, NWAITERS(%r12)
80 movq $VSYSCALL_ADDR_vgettimeofday, %rax
83 /* Compute relative timeout. */
86 mul %rdi /* Milli seconds to nano seconds. */
92 addq $1000000000, %rsi
95 movl $ETIMEDOUT, %r14d
96 js 6f /* Time is already up. */
98 movq %rdi, (%rsp) /* Store relative timeout. */
102 call __pthread_enable_asynccancel
109 leaq VALUE(%r12), %rdi
112 movl PRIVATE(%rdi), %esi
114 movl $FUTEX_WAIT, %esi
115 orl PRIVATE(%rdi), %esi
117 movl $SYS_futex, %eax
123 call __pthread_disable_asynccancel
128 cmpq $-EWOULDBLOCK, %r14
135 movl VALUE(%r12), %eax
143 cmpxchgl %ecx, (%r12)
145 cmpxchgl %ecx, VALUE(%r12)
152 subq $1, NWAITERS(%r12)
168 movq errno@gottpoff(%rip), %rdx
169 movl %r14d, %fs:(%rdx)
171 callq __errno_location@plt
177 .size sem_timedwait,.-sem_timedwait
180 .type sem_timedwait_cleanup,@function
181 sem_timedwait_cleanup:
183 subq $1, NWAITERS(%r12)
186 call _Unwind_Resume@PLT
189 .size sem_timedwait_cleanup,.-sem_timedwait_cleanup
192 .section .gcc_except_table,"a",@progbits
194 .byte 0xff # @LPStart format (omit)
195 .byte 0xff # @TType format (omit)
196 .byte 0x01 # call-site format
198 .uleb128 .Lcstend-.Lcstbegin
200 .uleb128 .LcleanupSTART-.LSTARTCODE
201 .uleb128 .LcleanupEND-.LcleanupSTART
202 .uleb128 sem_timedwait_cleanup-.LSTARTCODE
204 .uleb128 .LcallUR-.LSTARTCODE
205 .uleb128 .LENDCODE-.LcallUR
211 .section .eh_frame,"a",@progbits
213 .long .LENDCIE-.LSTARTCIE # Length of the CIE.
216 .byte 1 # Version number.
218 .string "zPLR" # NUL-terminated augmentation
221 .string "zPL" # NUL-terminated augmentation
224 .uleb128 1 # Code alignment factor.
225 .sleb128 -8 # Data alignment factor.
226 .byte 16 # Return address register
229 .uleb128 7 # Augmentation value length.
230 .byte 0x9b # Personality: DW_EH_PE_pcrel
232 # + DW_EH_PE_indirect
233 .long DW.ref.__gcc_personality_v0-.
234 .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel
236 .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel
239 .uleb128 10 # Augmentation value length.
240 .byte 0x0 # Personality: absolute
241 .quad __gcc_personality_v0
242 .byte 0x0 # LSDA Encoding: absolute
244 .byte 0x0c # DW_CFA_def_cfa
247 .byte 0x90 # DW_CFA_offset, column 0x10
252 .long .LENDFDE-.LSTARTFDE # Length of the FDE.
254 .long .LSTARTFDE-.LSTARTFRAME # CIE pointer.
256 .long .LSTARTCODE-. # PC-relative start address
258 .long .LENDCODE-.LSTARTCODE # Length of the code.
259 .uleb128 4 # Augmentation size
260 .long .LexceptSTART-.
262 .quad .LSTARTCODE # Start address of the code.
263 .quad .LENDCODE-.LSTARTCODE # Length of the code.
264 .uleb128 8 # Augmentation size
268 .byte 4 # DW_CFA_advance_loc4
269 .long .Lpush_r12-.LSTARTCODE
270 .byte 14 # DW_CFA_def_cfa_offset
272 .byte 0x8c # DW_CFA_offset %r12
274 .byte 4 # DW_CFA_advance_loc4
275 .long .Lpush_r13-.Lpush_r12
276 .byte 14 # DW_CFA_def_cfa_offset
278 .byte 0x8d # DW_CFA_offset %r13
280 .byte 4 # DW_CFA_advance_loc4
281 .long .Lpush_r14-.Lpush_r13
282 .byte 14 # DW_CFA_def_cfa_offset
284 .byte 0x8e # DW_CFA_offset %r14
286 .byte 4 # DW_CFA_advance_loc4
287 .long .Lsubq-.Lpush_r14
288 .byte 14 # DW_CFA_def_cfa_offset
290 .byte 4 # DW_CFA_advance_loc4
292 .byte 14 # DW_CFA_def_cfa_offset
294 .byte 4 # DW_CFA_advance_loc4
295 .long .Lpop_r14-.Laddq
296 .byte 14 # DW_CFA_def_cfa_offset
298 .byte 0xce # DW_CFA_restore %r14
299 .byte 4 # DW_CFA_advance_loc4
300 .long .Lpop_r13-.Lpop_r14
301 .byte 14 # DW_CFA_def_cfa_offset
303 .byte 0xcd # DW_CFA_restore %r13
304 .byte 4 # DW_CFA_advance_loc4
305 .long .Lpop_r12-.Lpop_r13
306 .byte 14 # DW_CFA_def_cfa_offset
308 .byte 0xcc # DW_CFA_restore %r12
309 .byte 4 # DW_CFA_advance_loc4
310 .long .Lafter_retq-.Lpop_r12
311 .byte 14 # DW_CFA_def_cfa_offset
313 .byte 0x8c # DW_CFA_offset %r12
315 .byte 0x8d # DW_CFA_offset %r13
317 .byte 0x8e # DW_CFA_offset %r14
324 .hidden DW.ref.__gcc_personality_v0
325 .weak DW.ref.__gcc_personality_v0
326 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
328 .type DW.ref.__gcc_personality_v0, @object
329 .size DW.ref.__gcc_personality_v0, 8
330 DW.ref.__gcc_personality_v0:
331 .quad __gcc_personality_v0