]> sourceware.org Git - glibc.git/blob - 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
1 /* Copyright (C) 2002-2005, 2007, 2009, 2011-2012 Free Software Foundation, Inc.
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>
22 #include <pthread-errnos.h>
23 #include <structsem.h>
24 #include <lowlevellock.h>
25
26
27 #if VALUE != 0
28 # error "code needs to be rewritten for VALUE != 0"
29 #endif
30
31
32 .text
33
34 .globl sem_timedwait
35 .type sem_timedwait,@function
36 .align 16
37 sem_timedwait:
38 .LSTARTCODE:
39 movl 4(%esp), %ecx
40
41 movl (%ecx), %eax
42 2: testl %eax, %eax
43 je 1f
44
45 leal -1(%eax), %edx
46 LOCK
47 cmpxchgl %edx, (%ecx)
48 jne 2b
49
50 xorl %eax, %eax
51 ret
52
53 /* Check whether the timeout value is valid. */
54 1: pushl %esi
55 .Lpush_esi:
56 pushl %edi
57 .Lpush_edi:
58 pushl %ebx
59 .Lpush_ebx:
60 subl $12, %esp
61 .Lsub_esp:
62
63 movl 32(%esp), %edi
64
65 /* Check for invalid nanosecond field. */
66 cmpl $1000000000, 4(%edi)
67 movl $EINVAL, %esi
68 jae 6f
69
70 LOCK
71 incl NWAITERS(%ecx)
72
73 7: xorl %ecx, %ecx
74 movl %esp, %ebx
75 movl %ecx, %edx
76 movl $__NR_gettimeofday, %eax
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
89 subl $1, %ecx
90 5: testl %ecx, %ecx
91 movl $ETIMEDOUT, %esi
92 js 6f /* Time is already up. */
93
94 movl %ecx, (%esp) /* Store relative timeout. */
95 movl %edx, 4(%esp)
96
97 .LcleanupSTART:
98 call __pthread_enable_asynccancel
99 movl %eax, 8(%esp)
100
101 movl 28(%esp), %ebx /* Load semaphore address. */
102 #if FUTEX_WAIT == 0
103 movl PRIVATE(%ebx), %ecx
104 #else
105 movl $FUTEX_WAIT, %ecx
106 orl PRIVATE(%ebx), %ecx
107 #endif
108 movl %esp, %esi
109 xorl %edx, %edx
110 movl $SYS_futex, %eax
111 ENTER_KERNEL
112 movl %eax, %esi
113
114 movl 8(%esp), %eax
115 call __pthread_disable_asynccancel
116 .LcleanupEND:
117
118 testl %esi, %esi
119 je 9f
120 cmpl $-EWOULDBLOCK, %esi
121 jne 3f
122
123 9: movl (%ebx), %eax
124 8: testl %eax, %eax
125 je 7b
126
127 leal -1(%eax), %ecx
128 LOCK
129 cmpxchgl %ecx, (%ebx)
130 jne 8b
131
132 xorl %eax, %eax
133
134 LOCK
135 decl NWAITERS(%ebx)
136
137 10: addl $12, %esp
138 .Ladd_esp:
139 popl %ebx
140 .Lpop_ebx:
141 popl %edi
142 .Lpop_edi:
143 popl %esi
144 .Lpop_esi:
145 ret
146
147 .Lafter_ret:
148 3: negl %esi
149 6:
150 #ifdef PIC
151 SETUP_PIC_REG(bx)
152 #else
153 movl $4f, %ebx
154 4:
155 #endif
156 addl $_GLOBAL_OFFSET_TABLE_, %ebx
157 #ifdef NO_TLS_DIRECT_SEG_REFS
158 movl errno@gotntpoff(%ebx), %edx
159 addl %gs:0, %edx
160 movl %esi, (%edx)
161 #else
162 movl errno@gotntpoff(%ebx), %edx
163 movl %esi, %gs:(%edx)
164 #endif
165
166 movl 28(%esp), %ebx /* Load semaphore address. */
167 orl $-1, %eax
168 jmp 10b
169 .size sem_timedwait,.-sem_timedwait
170
171
172 .type sem_wait_cleanup,@function
173 sem_wait_cleanup:
174 LOCK
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
266 .uleb128 2
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
272 .uleb128 3
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
278 .uleb128 4
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
307 .uleb128 2
308 .byte 0x87 # DW_CFA_offset %edi
309 .uleb128 3
310 .byte 0x83 # DW_CFA_offset %ebx
311 .uleb128 4
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
323 DW.ref.__gcc_personality_v0:
324 .long __gcc_personality_v0
325 #endif
This page took 0.052399 seconds and 5 git commands to generate.