1 /* Copyright (C) 2003-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <unwindbuf.h>
20 #include <kernel-features.h>
21 #include <lowlevellock.h>
22 #include "lowlevel-atomic.h"
25 .comm __fork_generation, 4, 4
29 .type __pthread_once,@function
41 cfi_adjust_cfa_offset (4)
42 cfi_rel_offset (r12, 0)
44 cfi_adjust_cfa_offset (4)
45 cfi_rel_offset (r9, 0)
47 cfi_adjust_cfa_offset (4)
48 cfi_rel_offset (r8, 0)
50 cfi_adjust_cfa_offset (4)
51 cfi_rel_offset (pr, 0)
55 /* Not yet initialized or initialization in progress.
56 Get the fork generation counter now. */
80 CMPXCHG (r5, @r4, r3, r2)
83 /* Check whether another thread already runs the initializer. */
86 bt 3f /* No -> do it. */
88 /* Check whether the initializer execution was interrupted
91 mov #-4, r1 /* -4 = 0xfffffffc */
93 bf 3f /* Different for generation -> run initializer. */
95 /* Somebody else got here first. Wait. */
96 #ifdef __ASSUME_PRIVATE_FUTEX
97 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r5
120 .long _GLOBAL_OFFSET_TABLE_
123 .long __fork_generation@GOTOFF
126 .long __fork_generation
130 /* Call the initializer function after setting up the
131 cancellation handler. Note that it is not possible here
132 to use the unwind-based cleanup handling. This would require
133 that the user-provided function and all the code it calls
134 is compiled with exceptions. Unfortunately this cannot be
136 add #-UNWINDBUFSIZE, r15
137 cfi_adjust_cfa_offset (UNWINDBUFSIZE)
139 mov.l .Lsigsetjmp, r1
153 /* Call the user-provided initialization function. */
157 /* Pop the cleanup handler. */
163 add #UNWINDBUFSIZE, r15
164 cfi_adjust_cfa_offset (-UNWINDBUFSIZE)
166 /* Sucessful run of the initializer. Signal that we are done. */
168 /* Wake up all other threads. */
170 #ifdef __ASSUME_PRIVATE_FUTEX
171 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
182 shlr r6 /* r6 = 0x7fffffff */
191 cfi_adjust_cfa_offset (-4)
194 cfi_adjust_cfa_offset (-4)
197 cfi_adjust_cfa_offset (-4)
200 cfi_adjust_cfa_offset (-4)
206 /* __sigsetjmp returned for the second time. */
207 cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
215 #ifdef __ASSUME_PRIVATE_FUTEX
216 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
227 shlr r6 /* r6 = 0x7fffffff */
241 #ifndef __ASSUME_PRIVATE_FUTEX
243 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
247 .long __sigsetjmp@PLT-(.Lsigsetjmp0-.)
249 .long HIDDEN_JUMPTARGET(__pthread_register_cancel)-.Lcpush0
251 .long HIDDEN_JUMPTARGET(__pthread_unregister_cancel)-.Lcpop0
253 .long HIDDEN_JUMPTARGET(__pthread_unwind_next)-.Lunext0
254 .size __pthread_once,.-__pthread_once
256 hidden_def (__pthread_once)
257 strong_alias (__pthread_once, pthread_once)