]> sourceware.org Git - glibc.git/blame - nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S
Consistently use macros for x86 PIC thunks.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / i386 / i486 / sem_timedwait.S
CommitLineData
9a1d9254 1/* Copyright (C) 2002-2005, 2007, 2009, 2011-2012 Free Software Foundation, Inc.
1d087a7e
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
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.
9
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.
14
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
18 02111-1307 USA. */
19
20#include <sysdep.h>
21#include <shlib-compat.h>
326132db 22#include <pthread-errnos.h>
3d2dd6ca 23#include <structsem.h>
e51deae7 24#include <lowlevellock.h>
1d087a7e 25
1d087a7e 26
3d2dd6ca
UD
27#if VALUE != 0
28# error "code needs to be rewritten for VALUE != 0"
29#endif
30
31
1d087a7e
UD
32 .text
33
34 .globl sem_timedwait
35 .type sem_timedwait,@function
36 .align 16
37sem_timedwait:
3d2dd6ca 38.LSTARTCODE:
1d087a7e
UD
39 movl 4(%esp), %ecx
40
41 movl (%ecx), %eax
422: testl %eax, %eax
ab9a9ff8 43 je 1f
1d087a7e
UD
44
45 leal -1(%eax), %edx
46 LOCK
47 cmpxchgl %edx, (%ecx)
ab9a9ff8 48 jne 2b
1d087a7e
UD
49
50 xorl %eax, %eax
51 ret
52
53 /* Check whether the timeout value is valid. */
541: pushl %esi
3d2dd6ca 55.Lpush_esi:
1d087a7e 56 pushl %edi
3d2dd6ca 57.Lpush_edi:
1d087a7e 58 pushl %ebx
3d2dd6ca 59.Lpush_ebx:
7726edc2 60 subl $12, %esp
3d2dd6ca 61.Lsub_esp:
1d087a7e 62
7726edc2 63 movl 32(%esp), %edi
1d087a7e
UD
64
65 /* Check for invalid nanosecond field. */
66 cmpl $1000000000, 4(%edi)
7726edc2 67 movl $EINVAL, %esi
1d087a7e
UD
68 jae 6f
69
3d2dd6ca
UD
70 LOCK
71 incl NWAITERS(%ecx)
72
20a4d722 737: xorl %ecx, %ecx
1d087a7e
UD
74 movl %esp, %ebx
75 movl %ecx, %edx
e51deae7 76 movl $__NR_gettimeofday, %eax
1d087a7e
UD
77 ENTER_KERNEL
78
79 /* Compute relative timeout. */
80 movl 4(%esp), %eax
81 movl $1000, %edx
82 mul %edx /* Milli seconds to nano seconds. */
83 movl (%edi), %ecx
84 movl 4(%edi), %edx
85 subl (%esp), %ecx
86 subl %eax, %edx
87 jns 5f
88 addl $1000000000, %edx
ccf1d573 89 subl $1, %ecx
1d087a7e 905: testl %ecx, %ecx
7726edc2 91 movl $ETIMEDOUT, %esi
1d087a7e
UD
92 js 6f /* Time is already up. */
93
94 movl %ecx, (%esp) /* Store relative timeout. */
95 movl %edx, 4(%esp)
20a4d722 96
3d2dd6ca 97.LcleanupSTART:
20a4d722
JJ
98 call __pthread_enable_asynccancel
99 movl %eax, 8(%esp)
100
3d2dd6ca 101 movl 28(%esp), %ebx /* Load semaphore address. */
42e6c665
UD
102#if FUTEX_WAIT == 0
103 movl PRIVATE(%ebx), %ecx
104#else
105 movl $FUTEX_WAIT, %ecx
106 orl PRIVATE(%ebx), %ecx
107#endif
7726edc2 108 movl %esp, %esi
1d087a7e 109 xorl %edx, %edx
42e6c665 110 movl $SYS_futex, %eax
1d087a7e 111 ENTER_KERNEL
7726edc2
UD
112 movl %eax, %esi
113
114 movl 8(%esp), %eax
115 call __pthread_disable_asynccancel
3d2dd6ca 116.LcleanupEND:
1d087a7e 117
7726edc2 118 testl %esi, %esi
ab9a9ff8 119 je 9f
7726edc2 120 cmpl $-EWOULDBLOCK, %esi
1d087a7e
UD
121 jne 3f
122
1239: movl (%ebx), %eax
1248: testl %eax, %eax
125 je 7b
126
127 leal -1(%eax), %ecx
128 LOCK
129 cmpxchgl %ecx, (%ebx)
ab9a9ff8 130 jne 8b
1d087a7e 131
1d087a7e 132 xorl %eax, %eax
3d2dd6ca 133
9554ebf2 134 LOCK
3d2dd6ca
UD
135 decl NWAITERS(%ebx)
136
9554ebf2 13710: addl $12, %esp
3d2dd6ca 138.Ladd_esp:
1d087a7e 139 popl %ebx
3d2dd6ca 140.Lpop_ebx:
1d087a7e 141 popl %edi
3d2dd6ca 142.Lpop_edi:
1d087a7e 143 popl %esi
3d2dd6ca 144.Lpop_esi:
1d087a7e
UD
145 ret
146
3d2dd6ca 147.Lafter_ret:
7726edc2 1483: negl %esi
1d087a7e
UD
1496:
150#ifdef PIC
9a1d9254 151 SETUP_PIC_REG(bx)
1d087a7e
UD
152#else
153 movl $4f, %ebx
1544:
155#endif
156 addl $_GLOBAL_OFFSET_TABLE_, %ebx
d063d164 157#ifdef NO_TLS_DIRECT_SEG_REFS
ea9c93cc
UD
158 movl errno@gotntpoff(%ebx), %edx
159 addl %gs:0, %edx
7726edc2 160 movl %esi, (%edx)
d063d164 161#else
ea9c93cc
UD
162 movl errno@gotntpoff(%ebx), %edx
163 movl %esi, %gs:(%edx)
1d087a7e
UD
164#endif
165
3d2dd6ca 166 movl 28(%esp), %ebx /* Load semaphore address. */
1d087a7e 167 orl $-1, %eax
3d2dd6ca
UD
168 jmp 10b
169 .size sem_timedwait,.-sem_timedwait
7726edc2 170
3d2dd6ca
UD
171
172 .type sem_wait_cleanup,@function
173sem_wait_cleanup:
7726edc2 174 LOCK
3d2dd6ca
UD
175 decl NWAITERS(%ebx)
176 movl %eax, (%esp)
177.LcallUR:
178 call _Unwind_Resume@PLT
179 hlt
180.LENDCODE:
181 .size sem_wait_cleanup,.-sem_wait_cleanup
182
183
184 .section .gcc_except_table,"a",@progbits
185.LexceptSTART:
186 .byte 0xff # @LPStart format (omit)
187 .byte 0xff # @TType format (omit)
188 .byte 0x01 # call-site format
189 # DW_EH_PE_uleb128
190 .uleb128 .Lcstend-.Lcstbegin
191.Lcstbegin:
192 .uleb128 .LcleanupSTART-.LSTARTCODE
193 .uleb128 .LcleanupEND-.LcleanupSTART
194 .uleb128 sem_wait_cleanup-.LSTARTCODE
195 .uleb128 0
196 .uleb128 .LcallUR-.LSTARTCODE
197 .uleb128 .LENDCODE-.LcallUR
198 .uleb128 0
199 .uleb128 0
200.Lcstend:
201
202
203 .section .eh_frame,"a",@progbits
204.LSTARTFRAME:
205 .long .LENDCIE-.LSTARTCIE # Length of the CIE.
206.LSTARTCIE:
207 .long 0 # CIE ID.
208 .byte 1 # Version number.
209#ifdef SHARED
210 .string "zPLR" # NUL-terminated augmentation
211 # string.
212#else
213 .string "zPL" # NUL-terminated augmentation
214 # string.
215#endif
216 .uleb128 1 # Code alignment factor.
217 .sleb128 -4 # Data alignment factor.
218 .byte 8 # Return address register
219 # column.
220#ifdef SHARED
221 .uleb128 7 # Augmentation value length.
222 .byte 0x9b # Personality: DW_EH_PE_pcrel
223 # + DW_EH_PE_sdata4
224 # + DW_EH_PE_indirect
225 .long DW.ref.__gcc_personality_v0-.
226 .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel
227 # + DW_EH_PE_sdata4.
228 .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel
229 # + DW_EH_PE_sdata4.
230#else
231 .uleb128 6 # Augmentation value length.
232 .byte 0x0 # Personality: absolute
233 .long __gcc_personality_v0
234 .byte 0x0 # LSDA Encoding: absolute
235#endif
236 .byte 0x0c # DW_CFA_def_cfa
237 .uleb128 4
238 .uleb128 4
239 .byte 0x88 # DW_CFA_offset, column 0x10
240 .uleb128 1
241 .align 4
242.LENDCIE:
243
244 .long .LENDFDE-.LSTARTFDE # Length of the FDE.
245.LSTARTFDE:
246 .long .LSTARTFDE-.LSTARTFRAME # CIE pointer.
247#ifdef SHARED
248 .long .LSTARTCODE-. # PC-relative start address
249 # of the code.
250#else
251 .long .LSTARTCODE # Start address of the code.
252#endif
253 .long .LENDCODE-.LSTARTCODE # Length of the code.
254 .uleb128 4 # Augmentation size
255#ifdef SHARED
256 .long .LexceptSTART-.
257#else
258 .long .LexceptSTART
259#endif
260
261 .byte 4 # DW_CFA_advance_loc4
262 .long .Lpush_esi-.LSTARTCODE
263 .byte 14 # DW_CFA_def_cfa_offset
264 .uleb128 8
265 .byte 0x86 # DW_CFA_offset %esi
9554ebf2 266 .uleb128 2
3d2dd6ca
UD
267 .byte 4 # DW_CFA_advance_loc4
268 .long .Lpush_edi-.Lpush_esi
269 .byte 14 # DW_CFA_def_cfa_offset
270 .uleb128 12
271 .byte 0x87 # DW_CFA_offset %edi
9554ebf2 272 .uleb128 3
3d2dd6ca
UD
273 .byte 4 # DW_CFA_advance_loc4
274 .long .Lpush_ebx-.Lpush_edi
275 .byte 14 # DW_CFA_def_cfa_offset
276 .uleb128 16
277 .byte 0x83 # DW_CFA_offset %ebx
9554ebf2 278 .uleb128 4
3d2dd6ca
UD
279 .byte 4 # DW_CFA_advance_loc4
280 .long .Lsub_esp-.Lpush_ebx
281 .byte 14 # DW_CFA_def_cfa_offset
282 .uleb128 28
283 .byte 4 # DW_CFA_advance_loc4
284 .long .Ladd_esp-.Lsub_esp
285 .byte 14 # DW_CFA_def_cfa_offset
286 .uleb128 16
287 .byte 4 # DW_CFA_advance_loc4
288 .long .Lpop_ebx-.Ladd_esp
289 .byte 14 # DW_CFA_def_cfa_offset
290 .uleb128 12
291 .byte 0xc3 # DW_CFA_restore %ebx
292 .byte 4 # DW_CFA_advance_loc4
293 .long .Lpop_edi-.Lpop_ebx
294 .byte 14 # DW_CFA_def_cfa_offset
295 .uleb128 8
296 .byte 0xc7 # DW_CFA_restore %edi
297 .byte 4 # DW_CFA_advance_loc4
298 .long .Lpop_esi-.Lpop_edi
299 .byte 14 # DW_CFA_def_cfa_offset
300 .uleb128 4
301 .byte 0xc6 # DW_CFA_restore %esi
302 .byte 4 # DW_CFA_advance_loc4
303 .long .Lafter_ret-.Lpop_esi
304 .byte 14 # DW_CFA_def_cfa_offset
305 .uleb128 28
306 .byte 0x86 # DW_CFA_offset %esi
9554ebf2 307 .uleb128 2
3d2dd6ca 308 .byte 0x87 # DW_CFA_offset %edi
9554ebf2 309 .uleb128 3
3d2dd6ca 310 .byte 0x83 # DW_CFA_offset %ebx
9554ebf2 311 .uleb128 4
3d2dd6ca
UD
312 .align 4
313.LENDFDE:
314
315
316#ifdef SHARED
317 .hidden DW.ref.__gcc_personality_v0
318 .weak DW.ref.__gcc_personality_v0
319 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
320 .align 4
321 .type DW.ref.__gcc_personality_v0, @object
322 .size DW.ref.__gcc_personality_v0, 4
323DW.ref.__gcc_personality_v0:
324 .long __gcc_personality_v0
325#endif
This page took 0.295879 seconds and 5 git commands to generate.