]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 2002-2014 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 | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
1d087a7e UD |
18 | |
19 | #include <sysdep.h> | |
20 | #include <shlib-compat.h> | |
326132db | 21 | #include <pthread-errnos.h> |
3d2dd6ca | 22 | #include <structsem.h> |
e51deae7 | 23 | #include <lowlevellock.h> |
1d087a7e | 24 | |
1d087a7e | 25 | |
3d2dd6ca UD |
26 | #if VALUE != 0 |
27 | # error "code needs to be rewritten for VALUE != 0" | |
28 | #endif | |
29 | ||
1d087a7e UD |
30 | .text |
31 | ||
32 | .globl __new_sem_wait | |
33 | .type __new_sem_wait,@function | |
34 | .align 16 | |
35 | __new_sem_wait: | |
3d2dd6ca UD |
36 | .LSTARTCODE: |
37 | pushl %ebx | |
38 | .Lpush_ebx: | |
39 | pushl %esi | |
40 | .Lpush_esi: | |
41 | subl $4, %esp | |
42 | .Lsub_esp: | |
43 | ||
44 | movl 16(%esp), %ebx | |
45 | ||
46 | movl (%ebx), %eax | |
47 | 2: testl %eax, %eax | |
48 | je 1f | |
49 | ||
50 | leal -1(%eax), %edx | |
51 | LOCK | |
52 | cmpxchgl %edx, (%ebx) | |
53 | jne 2b | |
54 | 7: xorl %eax, %eax | |
55 | ||
56 | 9: movl 4(%esp), %esi | |
57 | movl 8(%esp), %ebx | |
58 | addl $12, %esp | |
59 | .Ladd_esp: | |
60 | ret | |
61 | ||
62 | .Lafter_ret: | |
63 | 1: LOCK | |
64 | incl NWAITERS(%ebx) | |
65 | ||
66 | .LcleanupSTART: | |
67 | 6: call __pthread_enable_asynccancel | |
68 | movl %eax, (%esp) | |
69 | ||
42e6c665 UD |
70 | #if FUTEX_WAIT == 0 |
71 | movl PRIVATE(%ebx), %ecx | |
72 | #else | |
73 | movl $FUTEX_WAIT, %ecx | |
74 | orl PRIVATE(%ebx), %ecx | |
75 | #endif | |
3d2dd6ca | 76 | xorl %esi, %esi |
42e6c665 | 77 | xorl %edx, %edx |
3d2dd6ca | 78 | movl $SYS_futex, %eax |
3d2dd6ca UD |
79 | ENTER_KERNEL |
80 | movl %eax, %esi | |
81 | ||
82 | movl (%esp), %eax | |
83 | call __pthread_disable_asynccancel | |
84 | .LcleanupEND: | |
85 | ||
86 | testl %esi, %esi | |
87 | je 3f | |
88 | cmpl $-EWOULDBLOCK, %esi | |
89 | jne 4f | |
90 | ||
91 | 3: | |
92 | movl (%ebx), %eax | |
93 | 5: testl %eax, %eax | |
94 | je 6b | |
95 | ||
96 | leal -1(%eax), %edx | |
97 | LOCK | |
98 | cmpxchgl %edx, (%ebx) | |
99 | jne 5b | |
100 | ||
101 | LOCK | |
102 | decl NWAITERS(%ebx) | |
103 | jmp 7b | |
104 | ||
105 | 4: LOCK | |
106 | decl NWAITERS(%ebx) | |
107 | ||
108 | negl %esi | |
109 | #ifdef PIC | |
9a1d9254 | 110 | SETUP_PIC_REG(bx) |
3d2dd6ca UD |
111 | #else |
112 | movl $8f, %ebx | |
113 | 8: | |
114 | #endif | |
115 | addl $_GLOBAL_OFFSET_TABLE_, %ebx | |
d063d164 | 116 | #ifdef NO_TLS_DIRECT_SEG_REFS |
3d2dd6ca UD |
117 | movl errno@gotntpoff(%ebx), %edx |
118 | addl %gs:0, %edx | |
119 | movl %esi, (%edx) | |
d063d164 | 120 | #else |
3d2dd6ca UD |
121 | movl errno@gotntpoff(%ebx), %edx |
122 | movl %esi, %gs:(%edx) | |
3d2dd6ca UD |
123 | #endif |
124 | orl $-1, %eax | |
125 | ||
126 | jmp 9b | |
127 | .size __new_sem_wait,.-__new_sem_wait | |
128 | versioned_symbol(libpthread, __new_sem_wait, sem_wait, GLIBC_2_1) | |
129 | ||
130 | ||
131 | .type sem_wait_cleanup,@function | |
132 | sem_wait_cleanup: | |
133 | LOCK | |
134 | decl NWAITERS(%ebx) | |
135 | movl %eax, (%esp) | |
136 | .LcallUR: | |
137 | call _Unwind_Resume@PLT | |
138 | hlt | |
139 | .LENDCODE: | |
140 | .size sem_wait_cleanup,.-sem_wait_cleanup | |
141 | ||
142 | ||
143 | .section .gcc_except_table,"a",@progbits | |
144 | .LexceptSTART: | |
145 | .byte 0xff # @LPStart format (omit) | |
146 | .byte 0xff # @TType format (omit) | |
147 | .byte 0x01 # call-site format | |
148 | # DW_EH_PE_uleb128 | |
149 | .uleb128 .Lcstend-.Lcstbegin | |
150 | .Lcstbegin: | |
151 | .uleb128 .LcleanupSTART-.LSTARTCODE | |
152 | .uleb128 .LcleanupEND-.LcleanupSTART | |
153 | .uleb128 sem_wait_cleanup-.LSTARTCODE | |
154 | .uleb128 0 | |
155 | .uleb128 .LcallUR-.LSTARTCODE | |
156 | .uleb128 .LENDCODE-.LcallUR | |
157 | .uleb128 0 | |
158 | .uleb128 0 | |
159 | .Lcstend: | |
160 | ||
161 | ||
162 | .section .eh_frame,"a",@progbits | |
163 | .LSTARTFRAME: | |
164 | .long .LENDCIE-.LSTARTCIE # Length of the CIE. | |
165 | .LSTARTCIE: | |
166 | .long 0 # CIE ID. | |
167 | .byte 1 # Version number. | |
168 | #ifdef SHARED | |
169 | .string "zPLR" # NUL-terminated augmentation | |
170 | # string. | |
171 | #else | |
172 | .string "zPL" # NUL-terminated augmentation | |
173 | # string. | |
174 | #endif | |
175 | .uleb128 1 # Code alignment factor. | |
176 | .sleb128 -4 # Data alignment factor. | |
177 | .byte 8 # Return address register | |
178 | # column. | |
179 | #ifdef SHARED | |
180 | .uleb128 7 # Augmentation value length. | |
181 | .byte 0x9b # Personality: DW_EH_PE_pcrel | |
182 | # + DW_EH_PE_sdata4 | |
183 | # + DW_EH_PE_indirect | |
184 | .long DW.ref.__gcc_personality_v0-. | |
185 | .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel | |
186 | # + DW_EH_PE_sdata4. | |
187 | .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel | |
188 | # + DW_EH_PE_sdata4. | |
189 | #else | |
190 | .uleb128 6 # Augmentation value length. | |
191 | .byte 0x0 # Personality: absolute | |
192 | .long __gcc_personality_v0 | |
193 | .byte 0x0 # LSDA Encoding: absolute | |
194 | #endif | |
195 | .byte 0x0c # DW_CFA_def_cfa | |
196 | .uleb128 4 | |
197 | .uleb128 4 | |
198 | .byte 0x88 # DW_CFA_offset, column 0x10 | |
199 | .uleb128 1 | |
200 | .align 4 | |
201 | .LENDCIE: | |
202 | ||
203 | .long .LENDFDE-.LSTARTFDE # Length of the FDE. | |
204 | .LSTARTFDE: | |
205 | .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. | |
206 | #ifdef SHARED | |
207 | .long .LSTARTCODE-. # PC-relative start address | |
208 | # of the code. | |
209 | #else | |
210 | .long .LSTARTCODE # Start address of the code. | |
211 | #endif | |
212 | .long .LENDCODE-.LSTARTCODE # Length of the code. | |
213 | .uleb128 4 # Augmentation size | |
214 | #ifdef SHARED | |
215 | .long .LexceptSTART-. | |
216 | #else | |
217 | .long .LexceptSTART | |
218 | #endif | |
7726edc2 | 219 | |
3d2dd6ca UD |
220 | .byte 4 # DW_CFA_advance_loc4 |
221 | .long .Lpush_ebx-.LSTARTCODE | |
222 | .byte 14 # DW_CFA_def_cfa_offset | |
223 | .uleb128 8 | |
224 | .byte 0x83 # DW_CFA_offset %ebx | |
d063d164 | 225 | .uleb128 2 |
3d2dd6ca UD |
226 | .byte 4 # DW_CFA_advance_loc4 |
227 | .long .Lpush_esi-.Lpush_ebx | |
228 | .byte 14 # DW_CFA_def_cfa_offset | |
229 | .uleb128 12 | |
230 | .byte 0x86 # DW_CFA_offset %esi | |
d063d164 | 231 | .uleb128 3 |
3d2dd6ca UD |
232 | .byte 4 # DW_CFA_advance_loc4 |
233 | .long .Lsub_esp-.Lpush_esi | |
234 | .byte 14 # DW_CFA_def_cfa_offset | |
235 | .uleb128 16 | |
236 | .byte 4 # DW_CFA_advance_loc4 | |
237 | .long .Ladd_esp-.Lsub_esp | |
238 | .byte 14 # DW_CFA_def_cfa_offset | |
239 | .uleb128 4 | |
240 | .byte 0xc3 # DW_CFA_restore %ebx | |
241 | .byte 0xc6 # DW_CFA_restore %esi | |
242 | .byte 4 # DW_CFA_advance_loc4 | |
243 | .long .Lafter_ret-.Ladd_esp | |
244 | .byte 14 # DW_CFA_def_cfa_offset | |
245 | .uleb128 16 | |
246 | .byte 0x83 # DW_CFA_offset %ebx | |
d063d164 | 247 | .uleb128 2 |
3d2dd6ca | 248 | .byte 0x86 # DW_CFA_offset %esi |
d063d164 | 249 | .uleb128 3 |
3d2dd6ca UD |
250 | .align 4 |
251 | .LENDFDE: | |
252 | ||
253 | ||
254 | #ifdef SHARED | |
255 | .hidden DW.ref.__gcc_personality_v0 | |
256 | .weak DW.ref.__gcc_personality_v0 | |
257 | .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits | |
258 | .align 4 | |
259 | .type DW.ref.__gcc_personality_v0, @object | |
260 | .size DW.ref.__gcc_personality_v0, 4 | |
261 | DW.ref.__gcc_personality_v0: | |
262 | .long __gcc_personality_v0 | |
263 | #endif | |
264 | ||
265 | ||
266 | #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) | |
267 | .section ".text.compat", "ax" | |
268 | .global __old_sem_wait | |
269 | .type __old_sem_wait,@function | |
270 | .align 16 | |
271 | cfi_startproc | |
272 | __old_sem_wait: | |
1d087a7e | 273 | pushl %ebx |
7726edc2 | 274 | cfi_adjust_cfa_offset(4) |
1d087a7e | 275 | pushl %esi |
7726edc2 UD |
276 | cfi_adjust_cfa_offset(4) |
277 | subl $4, %esp | |
278 | cfi_adjust_cfa_offset(4) | |
1d087a7e | 279 | |
7726edc2 | 280 | movl 16(%esp), %ebx |
3d2dd6ca | 281 | cfi_offset(ebx, -8) |
1d087a7e | 282 | |
3d2dd6ca | 283 | cfi_offset(esi, -12) |
1d087a7e UD |
284 | 3: movl (%ebx), %eax |
285 | 2: testl %eax, %eax | |
077a0da7 | 286 | je 1f |
1d087a7e UD |
287 | |
288 | leal -1(%eax), %edx | |
289 | LOCK | |
290 | cmpxchgl %edx, (%ebx) | |
ab9a9ff8 | 291 | jne 2b |
1d087a7e UD |
292 | xorl %eax, %eax |
293 | ||
3d2dd6ca | 294 | 5: movl 4(%esp), %esi |
7726edc2 | 295 | movl 8(%esp), %ebx |
7726edc2 | 296 | addl $12, %esp |
3d2dd6ca UD |
297 | cfi_restore(ebx) |
298 | cfi_restore(esi) | |
7726edc2 | 299 | cfi_adjust_cfa_offset(-12) |
1d087a7e UD |
300 | ret |
301 | ||
077a0da7 | 302 | cfi_adjust_cfa_offset(12) |
3d2dd6ca UD |
303 | cfi_offset(ebx, -8) |
304 | cfi_offset(esi, -12) | |
7726edc2 UD |
305 | 1: call __pthread_enable_asynccancel |
306 | movl %eax, (%esp) | |
307 | ||
308 | xorl %esi, %esi | |
1d087a7e UD |
309 | movl $SYS_futex, %eax |
310 | movl %esi, %ecx | |
311 | movl %esi, %edx | |
312 | ENTER_KERNEL | |
7726edc2 UD |
313 | movl %eax, %esi |
314 | ||
315 | movl (%esp), %eax | |
316 | call __pthread_disable_asynccancel | |
1d087a7e | 317 | |
7726edc2 | 318 | testl %esi, %esi |
1d087a7e | 319 | je 3b |
7726edc2 | 320 | cmpl $-EWOULDBLOCK, %esi |
1d087a7e | 321 | je 3b |
7726edc2 | 322 | negl %esi |
1d087a7e | 323 | #ifdef PIC |
9a1d9254 | 324 | SETUP_PIC_REG(bx) |
1d087a7e UD |
325 | #else |
326 | movl $4f, %ebx | |
327 | 4: | |
328 | #endif | |
329 | addl $_GLOBAL_OFFSET_TABLE_, %ebx | |
d063d164 | 330 | #ifdef NO_TLS_DIRECT_SEG_REFS |
ea9c93cc UD |
331 | movl errno@gotntpoff(%ebx), %edx |
332 | addl %gs:0, %edx | |
7726edc2 | 333 | movl %esi, (%edx) |
d063d164 | 334 | #else |
ea9c93cc UD |
335 | movl errno@gotntpoff(%ebx), %edx |
336 | movl %esi, %gs:(%edx) | |
1d087a7e UD |
337 | #endif |
338 | orl $-1, %eax | |
3d2dd6ca | 339 | jmp 5b |
7726edc2 | 340 | cfi_endproc |
3d2dd6ca | 341 | .size __old_sem_wait,.-__old_sem_wait |
959c5bbf | 342 | compat_symbol(libpthread, __old_sem_wait, sem_wait, GLIBC_2_0) |
1d087a7e | 343 | #endif |