123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #include <unwindbuf.h>
- #include <sysdep.h>
- #include <bits/kernel-features.h>
- #include <lowlevellock.h>
- #include <tls.h>
- .comm __fork_generation, 4, 4
- .text
- .globl __pthread_once
- .type __pthread_once,@function
- .protected __pthread_once
- .align 16
- cfi_startproc
- __pthread_once:
- movl 4(%esp), %ecx
- testl $2, (%ecx)
- jz 1f
- xorl %eax, %eax
- ret
- 1: pushl %ebx
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (3, 0)
- pushl %esi
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (6, 0)
- movl %ecx, %ebx
- xorl %esi, %esi
-
- 6: movl (%ebx), %eax
- #ifdef __PIC__
- call __x86.get_pc_thunk.cx
- addl $_GLOBAL_OFFSET_TABLE_, %ecx
- #endif
- 5: movl %eax, %edx
- testl $2, %eax
- jnz 4f
- andl $3, %edx
- #ifdef __PIC__
- orl __fork_generation@GOTOFF(%ecx), %edx
- #else
- orl __fork_generation, %edx
- #endif
- orl $1, %edx
- LOCK
- cmpxchgl %edx, (%ebx)
- jnz 5b
-
- testl $1, %eax
- jz 3f
-
- xorl %edx, %eax
- testl $0xfffffffc, %eax
- jnz 3f
-
- #ifdef __ASSUME_PRIVATE_FUTEX
- movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %ecx
- #else
- # if FUTEX_WAIT == 0
- movl %gs:PRIVATE_FUTEX, %ecx
- # else
- movl $FUTEX_WAIT, %ecx
- orl %gs:PRIVATE_FUTEX, %ecx
- # endif
- #endif
- movl $SYS_futex, %eax
- ENTER_KERNEL
- jmp 6b
- 3:
- subl $UNWINDBUFSIZE+8, %esp
- cfi_adjust_cfa_offset (UNWINDBUFSIZE+8)
- movl %ecx, %ebx
- leal 8+UWJMPBUF(%esp), %eax
- movl $0, 4(%esp)
- movl %eax, (%esp)
- call __sigsetjmp@PLT
- testl %eax, %eax
- jne 7f
- leal 8(%esp), %eax
- call HIDDEN_JUMPTARGET(__pthread_register_cancel)
-
- call *24+UNWINDBUFSIZE(%esp)
-
- leal 8(%esp), %eax
- call HIDDEN_JUMPTARGET(__pthread_unregister_cancel)
- addl $UNWINDBUFSIZE+8, %esp
- cfi_adjust_cfa_offset (-UNWINDBUFSIZE-8)
-
- movl 12(%esp), %ebx
- LOCK
- addl $1, (%ebx)
-
- movl $0x7fffffff, %edx
- #ifdef __ASSUME_PRIVATE_FUTEX
- movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx
- #else
- movl $FUTEX_WAKE, %ecx
- orl %gs:PRIVATE_FUTEX, %ecx
- #endif
- movl $SYS_futex, %eax
- ENTER_KERNEL
- 4: popl %esi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (6)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (3)
- xorl %eax, %eax
- ret
- 7:
- movl 20+UNWINDBUFSIZE(%esp), %ebx
- cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
- cfi_offset (3, -8)
- cfi_offset (6, -12)
- movl $0, (%ebx)
- movl $0x7fffffff, %edx
- #ifdef __ASSUME_PRIVATE_FUTEX
- movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx
- #else
- movl $FUTEX_WAKE, %ecx
- orl %gs:PRIVATE_FUTEX, %ecx
- #endif
- movl $SYS_futex, %eax
- ENTER_KERNEL
- leal 8(%esp), %eax
- call HIDDEN_JUMPTARGET (__pthread_unwind_next)
-
- hlt
- cfi_endproc
- .size __pthread_once,.-__pthread_once
- .globl __pthread_once_internal
- __pthread_once_internal = __pthread_once
- .globl pthread_once
- pthread_once = __pthread_once
- #ifdef __PIC__
- .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
- .globl __x86.get_pc_thunk.cx
- .hidden __x86.get_pc_thunk.cx
- .type __x86.get_pc_thunk.cx,@function
- __x86.get_pc_thunk.cx:
- movl (%esp), %ecx;
- ret
- .size __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
- #endif
|