clarify the purpose of this project
[nyanglibc.git] / nptl / sem_open.s
bloba9f2e2b5e78778c8e542a2f1cea39abdb2f04710
1 .text
2 .p2align 4,,15
3 .type check_add_mapping, @function
4 check_add_mapping:
5 pushq %rbp
6 movq %rsp, %rbp
7 pushq %r15
8 pushq %r14
9 pushq %r13
10 pushq %r12
11 movq %rsi, %r12
12 pushq %rbx
13 leaq -192(%rbp), %rsi
14 movq %rdi, %r14
15 movl %edx, %edi
16 movl %edx, %r13d
17 movq %rcx, %rbx
18 subq $168, %rsp
19 call __fstat64@PLT
20 testl %eax, %eax
21 jne .L20
22 movl $1, %edx
23 lock cmpxchgl %edx, __sem_mappings_lock(%rip)
24 jne .L21
25 .L4:
26 leaq 32(%r12), %rax
27 movq %r12, %rdx
28 movq %r14, %rsi
29 movq %rax, -200(%rbp)
30 leaq 62(%r12), %rax
31 andq $-16, %rax
32 subq %rax, %rsp
33 leaq 15(%rsp), %rcx
34 andq $-16, %rcx
35 leaq 32(%rcx), %rdi
36 movq %rcx, %r15
37 call memcpy@PLT
38 movq -192(%rbp), %rax
39 leaq __sem_search(%rip), %rdx
40 leaq __sem_mappings(%rip), %rsi
41 movq %r15, %rdi
42 movq %rax, (%r15)
43 movq -184(%rbp), %rax
44 movq %rax, 8(%r15)
45 call __tfind@PLT
46 testq %rax, %rax
47 je .L5
48 movq (%rax), %rax
49 movq 24(%rax), %r12
50 addl $1, 16(%rax)
51 leaq -1(%rbx), %rax
52 cmpq $-3, %rax
53 setbe %r8b
54 cmpq %r12, %rbx
55 setne %al
56 andl %eax, %r8d
57 .L6:
58 xorl %eax, %eax
59 #APP
60 # 124 "../sysdeps/pthread/sem_open.c" 1
61 xchgl %eax, __sem_mappings_lock(%rip)
62 # 0 "" 2
63 #NO_APP
64 cmpl $1, %eax
65 jg .L22
66 .L3:
67 testb %r8b, %r8b
68 jne .L23
69 .L1:
70 leaq -40(%rbp), %rsp
71 movq %r12, %rax
72 popq %rbx
73 popq %r12
74 popq %r13
75 popq %r14
76 popq %r15
77 popq %rbp
78 ret
79 .p2align 4,,10
80 .p2align 3
81 .L23:
82 movq errno@gottpoff(%rip), %r13
83 movl $32, %esi
84 movq %rbx, %rdi
85 movl %fs:0(%r13), %r14d
86 call munmap@PLT
87 movl %r14d, %fs:0(%r13)
88 jmp .L1
89 .p2align 4,,10
90 .p2align 3
91 .L20:
92 leaq -1(%rbx), %rax
93 cmpq $-3, %rax
94 setbe %r8b
95 testq %rbx, %rbx
96 setne %al
97 xorl %r12d, %r12d
98 andl %eax, %r8d
99 jmp .L3
100 .p2align 4,,10
101 .p2align 3
102 .L5:
103 leaq 32(%r12), %rdi
104 call malloc@PLT
105 testq %rax, %rax
106 movq %rax, %r15
107 je .L24
108 testq %rbx, %rbx
109 je .L25
110 .L8:
111 movq -192(%rbp), %rax
112 leaq 32(%r15), %rdi
113 movq %r12, %rdx
114 movl $1, 16(%r15)
115 movq %rbx, 24(%r15)
116 movq %r14, %rsi
117 movq %rax, (%r15)
118 movq -184(%rbp), %rax
119 movq %rax, 8(%r15)
120 call memcpy@PLT
121 leaq -1(%rbx), %rax
122 cmpq $-3, %rax
123 setbe %r12b
124 cmpq $-1, %rbx
125 je .L10
126 leaq __sem_search(%rip), %rdx
127 leaq __sem_mappings(%rip), %rsi
128 movq %r15, %rdi
129 call __tsearch@PLT
130 testq %rax, %rax
131 je .L10
132 movq %rbx, %r12
133 xorl %r8d, %r8d
134 jmp .L6
135 .p2align 4,,10
136 .p2align 3
137 .L10:
138 movq %r15, %rdi
139 call free@PLT
140 testq %rbx, %rbx
141 setne %r8b
142 andl %r12d, %r8d
143 xorl %r12d, %r12d
144 jmp .L6
145 .p2align 4,,10
146 .p2align 3
147 .L22:
148 xorl %r10d, %r10d
149 movl $1, %edx
150 movl $129, %esi
151 leaq __sem_mappings_lock(%rip), %rdi
152 movl $202, %eax
153 #APP
154 # 124 "../sysdeps/pthread/sem_open.c" 1
155 syscall
157 # 0 "" 2
158 #NO_APP
159 jmp .L3
160 .p2align 4,,10
161 .p2align 3
162 .L21:
163 leaq __sem_mappings_lock(%rip), %rdi
164 call __lll_lock_wait_private@PLT
165 jmp .L4
166 .p2align 4,,10
167 .p2align 3
168 .L24:
169 leaq -1(%rbx), %rax
170 cmpq $-3, %rax
171 setbe %r8b
172 testq %rbx, %rbx
173 setne %al
174 xorl %r12d, %r12d
175 andl %eax, %r8d
176 jmp .L6
177 .p2align 4,,10
178 .p2align 3
179 .L25:
180 xorl %r9d, %r9d
181 movl %r13d, %r8d
182 movl $1, %ecx
183 movl $3, %edx
184 movl $32, %esi
185 xorl %edi, %edi
186 call mmap@PLT
187 movq %rax, %rbx
188 jmp .L8
189 .size check_add_mapping, .-check_add_mapping
190 .p2align 4,,15
191 .globl __sem_search
192 .type __sem_search, @function
193 __sem_search:
194 movq 8(%rsi), %rax
195 cmpq %rax, 8(%rdi)
196 je .L27
197 .L32:
198 sbbl %eax, %eax
199 orl $1, %eax
201 .p2align 4,,10
202 .p2align 3
203 .L27:
204 movq (%rsi), %rax
205 cmpq %rax, (%rdi)
206 jne .L32
207 addq $32, %rsi
208 addq $32, %rdi
209 jmp strcmp@PLT
210 .size __sem_search, .-__sem_search
211 .p2align 4,,15
212 .globl sem_open
213 .type sem_open, @function
214 sem_open:
215 pushq %rbp
216 movq %rsp, %rbp
217 pushq %r15
218 pushq %r14
219 pushq %r13
220 pushq %r12
221 movl %esi, %r15d
222 pushq %rbx
223 movq %rdi, %rbx
224 leaq -160(%rbp), %rdi
225 subq $168, %rsp
226 movq %rdx, -80(%rbp)
227 movq %rcx, -72(%rbp)
228 call __shm_directory@PLT
229 testq %rax, %rax
230 je .L34
231 cmpb $47, (%rbx)
232 movq %rax, %r13
233 jne .L36
234 .p2align 4,,10
235 .p2align 3
236 .L35:
237 addq $1, %rbx
238 cmpb $47, (%rbx)
239 je .L35
240 .L36:
241 movq %rbx, %rdi
242 call strlen@PLT
243 leaq 1(%rax), %r12
244 cmpq $1, %r12
245 je .L38
246 cmpq $254, %r12
247 ja .L38
248 movl $47, %esi
249 movq %rbx, %rdi
250 call strchr@PLT
251 testq %rax, %rax
252 jne .L38
253 movq -160(%rbp), %rdx
254 movq %r13, %rsi
255 leaq 34(%rdx,%r12), %rax
256 andq $-16, %rax
257 subq %rax, %rsp
258 leaq 15(%rsp), %rax
259 andq $-16, %rax
260 movq %rax, %rdi
261 movq %rax, -200(%rbp)
262 call __mempcpy@PLT
263 leaq 4(%rax), %rdi
264 movq %r12, %rdx
265 movq %rbx, %rsi
266 movl $778921331, (%rax)
267 call memcpy@PLT
268 leaq -164(%rbp), %rsi
269 movl $1, %edi
270 call __pthread_setcancelstate@PLT
271 movl %r15d, %eax
272 andl $192, %eax
273 cmpl $192, %eax
274 je .L40
275 .L41:
276 movl %r15d, %esi
277 movq -200(%rbp), %rdi
278 xorl %eax, %eax
279 andl $-131140, %esi
280 orl $131074, %esi
281 call __libc_open@PLT
282 cmpl $-1, %eax
283 jne .L42
284 xorl %r14d, %r14d
285 testb $64, %r15b
286 je .L43
287 movq errno@gottpoff(%rip), %r11
288 cmpl $2, %fs:(%r11)
289 je .L40
290 .p2align 4,,10
291 .p2align 3
292 .L43:
293 movl -164(%rbp), %edi
294 xorl %esi, %esi
295 call __pthread_setcancelstate@PLT
296 jmp .L33
297 .p2align 4,,10
298 .p2align 3
299 .L40:
300 leaq 16(%rbp), %rax
301 movl $24, -152(%rbp)
302 movq %rax, -144(%rbp)
303 leaq -96(%rbp), %rax
304 movl 16(%rax), %ecx
305 movq %rax, -136(%rbp)
306 movl 24(%rax), %eax
307 movl %ecx, -188(%rbp)
308 testl %eax, %eax
309 jns .L49
310 movq errno@gottpoff(%rip), %rax
311 movl $22, %fs:(%rax)
312 .L50:
313 xorl %r14d, %r14d
314 jmp .L43
315 .p2align 4,,10
316 .p2align 3
317 .L38:
318 movq errno@gottpoff(%rip), %rax
319 xorl %r14d, %r14d
320 movl $22, %fs:(%rax)
321 .L33:
322 leaq -40(%rbp), %rsp
323 movq %r14, %rax
324 popq %rbx
325 popq %r12
326 popq %r13
327 popq %r14
328 popq %r15
329 popq %rbp
331 .p2align 4,,10
332 .p2align 3
333 .L42:
334 xorl %ecx, %ecx
335 movl %eax, %edx
336 movq %r12, %rsi
337 movq %rbx, %rdi
338 movl %eax, -184(%rbp)
339 call check_add_mapping
340 movq errno@gottpoff(%rip), %r11
341 movl -184(%rbp), %r10d
342 movq %rax, %r14
343 .L44:
344 cmpq $-1, %r14
345 movl $0, %eax
346 cmove %rax, %r14
347 .L57:
348 movl %r10d, %edi
349 movl %fs:(%r11), %ebx
350 movq %r11, -184(%rbp)
351 call __libc_close@PLT
352 movq -184(%rbp), %r11
353 movl %ebx, %fs:(%r11)
354 jmp .L43
355 .p2align 4,,10
356 .p2align 3
357 .L49:
358 movq -160(%rbp), %rdx
359 movq %rax, -128(%rbp)
360 movq %r13, %rsi
361 pxor %xmm0, %xmm0
362 movq $128, -120(%rbp)
363 leaq 41(%rdx), %rax
364 movaps %xmm0, -112(%rbp)
365 andq $-16, %rax
366 subq %rax, %rsp
367 leaq 15(%rsp), %rax
368 andq $-16, %rax
369 movq %rax, %rdi
370 movq %rax, -184(%rbp)
371 call __mempcpy@PLT
372 movl $50, -208(%rbp)
373 movq %rax, %r14
374 jmp .L53
375 .p2align 4,,10
376 .p2align 3
377 .L76:
378 cmpl $17, %fs:(%r11)
379 jne .L50
380 subl $1, -208(%rbp)
381 je .L80
382 .L53:
383 movq -184(%rbp), %rdi
384 movl $22616, %eax
385 movl $1482184792, (%r14)
386 movw %ax, 4(%r14)
387 movb $0, 6(%r14)
388 call __mktemp@PLT
389 testq %rax, %rax
390 je .L50
391 movl -188(%rbp), %edx
392 movq -184(%rbp), %rdi
393 xorl %eax, %eax
394 movl $194, %esi
395 call __libc_open@PLT
396 cmpl $-1, %eax
397 movl %eax, %r10d
398 movq errno@gottpoff(%rip), %r11
399 je .L76
400 leaq -128(%rbp), %r14
401 jmp .L52
402 .p2align 4,,10
403 .p2align 3
404 .L81:
405 cmpl $4, %fs:(%r11)
406 jne .L55
407 .L52:
408 movl %r10d, %edi
409 movl $32, %edx
410 movq %r14, %rsi
411 movq %r11, -208(%rbp)
412 movl %r10d, -188(%rbp)
413 call __libc_write@PLT
414 cmpq $-1, %rax
415 movl -188(%rbp), %r10d
416 movq -208(%rbp), %r11
417 je .L81
418 cmpq $32, %rax
419 jne .L55
420 xorl %r9d, %r9d
421 movl %r10d, %r8d
422 xorl %edi, %edi
423 movl $1, %ecx
424 movl $3, %edx
425 movl $32, %esi
426 movq %r11, -208(%rbp)
427 movl %r10d, -188(%rbp)
428 call mmap@PLT
429 cmpq $-1, %rax
430 movq %rax, %r14
431 movl -188(%rbp), %r10d
432 movq -208(%rbp), %r11
433 je .L78
434 movq -200(%rbp), %rsi
435 movq -184(%rbp), %rdi
436 movq %r11, -208(%rbp)
437 movl %r10d, -188(%rbp)
438 call link@PLT
439 testl %eax, %eax
440 movl -188(%rbp), %r10d
441 movq -208(%rbp), %r11
442 je .L59
443 movl $32, %esi
444 movq %r14, %rdi
445 call munmap@PLT
446 testb $-128, %r15b
447 movl -188(%rbp), %r10d
448 movq -208(%rbp), %r11
449 jne .L78
450 cmpl $17, %fs:(%r11)
451 movq %r11, -208(%rbp)
452 movl %r10d, -188(%rbp)
453 movq -184(%rbp), %rdi
454 je .L61
455 call unlink@PLT
456 xorl %r14d, %r14d
457 movl -188(%rbp), %r10d
458 movq -208(%rbp), %r11
459 jmp .L57
460 .p2align 4,,10
461 .p2align 3
462 .L34:
463 movq errno@gottpoff(%rip), %rax
464 xorl %r14d, %r14d
465 movl $38, %fs:(%rax)
466 jmp .L33
467 .L55:
468 movq %r11, -200(%rbp)
469 movl %r10d, -188(%rbp)
470 .L79:
471 movq -184(%rbp), %rdi
472 xorl %r14d, %r14d
473 call unlink@PLT
474 movl -188(%rbp), %r10d
475 movq -200(%rbp), %r11
476 jmp .L57
477 .L80:
478 movl $11, %fs:(%r11)
479 jmp .L50
480 .L78:
481 movq %r11, -200(%rbp)
482 jmp .L79
483 .L59:
484 movq %r14, %rcx
485 movl %r10d, %edx
486 movq %r12, %rsi
487 movq %rbx, %rdi
488 movq %r11, -200(%rbp)
489 movl %r10d, -188(%rbp)
490 call check_add_mapping
491 movq -184(%rbp), %rdi
492 movq %rax, %r14
493 call unlink@PLT
494 movl -188(%rbp), %r10d
495 movq -200(%rbp), %r11
496 jmp .L44
497 .L61:
498 call unlink@PLT
499 movl -188(%rbp), %r10d
500 movl %r10d, %edi
501 call __libc_close@PLT
502 jmp .L41
503 .size sem_open, .-sem_open
504 .globl __sem_mappings_lock
505 .bss
506 .align 4
507 .type __sem_mappings_lock, @object
508 .size __sem_mappings_lock, 4
509 __sem_mappings_lock:
510 .zero 4
511 .comm __sem_mappings,8,8
512 .weak __pthread_setcancelstate