1 /* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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.
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.
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
21 #include <kernel-features.h>
22 #include <tcb-offsets.h>
23 #include <lowlevellock.h>
26 .comm __fork_generation, 4, 4
32 .type __pthread_once,@function
38 cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect,
39 DW.ref.__gcc_personality_v0)
40 cfi_lsda(DW_EH_PE_pcrel | DW_EH_PE_sdata4, .LexceptSTART)
42 cfi_personality(DW_EH_PE_udata4, __gcc_personality_v0)
43 cfi_lsda(DW_EH_PE_udata4, .LexceptSTART)
50 /* Preserve the function pointer. */
52 cfi_adjust_cfa_offset(8)
55 /* Not yet initialized or initialization in progress.
56 Get the fork generation counter now. */
65 orl __fork_generation(%rip), %edx
72 /* Check whether another thread already runs the initializer. */
74 jz 3f /* No -> do it. */
76 /* Check whether the initializer execution was interrupted
79 testl $0xfffffffc, %eax
80 jnz 3f /* Different for generation -> run initializer. */
82 /* Somebody else got here first. Wait. */
83 #ifdef __ASSUME_PRIVATE_FUTEX
84 movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %esi
87 movl %fs:PRIVATE_FUTEX, %esi
89 movl $FUTEX_WAIT, %esi
90 orl %fs:PRIVATE_FUTEX, %esi
97 /* Preserve the pointer to the control variable. */
99 cfi_adjust_cfa_offset(8)
101 cfi_adjust_cfa_offset(8)
107 /* Get the control variable address back. */
109 cfi_adjust_cfa_offset(-8)
111 /* Sucessful run of the initializer. Signal that we are done. */
116 cfi_adjust_cfa_offset(-8)
118 /* Wake up all other threads. */
119 movl $0x7fffffff, %edx
120 #ifdef __ASSUME_PRIVATE_FUTEX
121 movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi
123 movl $FUTEX_WAKE, %esi
124 orl %fs:PRIVATE_FUTEX, %esi
126 movl $SYS_futex, %eax
130 cfi_adjust_cfa_offset(-8)
133 .size __pthread_once,.-__pthread_once
136 .globl __pthread_once_internal
137 __pthread_once_internal = __pthread_once
140 pthread_once = __pthread_once
143 .type clear_once_control,@function
146 cfi_adjust_cfa_offset(3 * 8)
151 movl $0x7fffffff, %edx
152 #ifdef __ASSUME_PRIVATE_FUTEX
153 movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi
155 movl $FUTEX_WAKE, %esi
156 orl %fs:PRIVATE_FUTEX, %esi
158 movl $SYS_futex, %eax
163 call _Unwind_Resume@PLT
167 .size clear_once_control,.-clear_once_control
170 .section .gcc_except_table,"a",@progbits
172 .byte DW_EH_PE_omit # @LPStart format
173 .byte DW_EH_PE_omit # @TType format
174 .byte DW_EH_PE_uleb128 # call-site format
175 .uleb128 .Lcstend-.Lcstbegin
177 .uleb128 .LcleanupSTART-.LSTARTCODE
178 .uleb128 .LcleanupEND-.LcleanupSTART
179 .uleb128 clear_once_control-.LSTARTCODE
181 .uleb128 .LcallUR-.LSTARTCODE
182 .uleb128 .LENDCODE-.LcallUR
189 .hidden DW.ref.__gcc_personality_v0
190 .weak DW.ref.__gcc_personality_v0
191 .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
193 .type DW.ref.__gcc_personality_v0, @object
194 .size DW.ref.__gcc_personality_v0, 8
195 DW.ref.__gcc_personality_v0:
196 .quad __gcc_personality_v0