1 /* Copyright (C) 2003, 2004 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 #include <unwindbuf.h>
21 #include "lowlevel-atomic.h"
27 .comm __fork_generation, 4, 4
31 .type __pthread_once,@function
43 cfi_adjust_cfa_offset (4)
44 cfi_rel_offset (r12, 0)
46 cfi_adjust_cfa_offset (4)
47 cfi_rel_offset (r9, 0)
49 cfi_adjust_cfa_offset (4)
50 cfi_rel_offset (r8, 0)
52 cfi_adjust_cfa_offset (4)
53 cfi_rel_offset (pr, 0)
57 /* Not yet initialized or initialization in progress.
58 Get the fork generation counter now. */
82 CMPXCHG (r5, @r4, r3, r2)
85 /* Check whether another thread already runs the initializer. */
88 bt 3f /* No -> do it. */
90 /* Check whether the initializer execution was interrupted
93 mov #-4, r1 /* -4 = 0xfffffffc */
95 bf 3f /* Different for generation -> run initializer. */
97 /* Somebody else got here first. Wait. */
110 .long _GLOBAL_OFFSET_TABLE_
113 .long __fork_generation@GOTOFF
116 .long __fork_generation
120 /* Call the initializer function after setting up the
121 cancellation handler. Note that it is not possible here
122 to use the unwind-based cleanup handling. This would require
123 that the user-provided function and all the code it calls
124 is compiled with exceptions. Unfortunately this cannot be
126 add #-UNWINDBUFSIZE, r15
127 cfi_adjust_cfa_offset (UNWINDBUFSIZE)
129 mov.l .Lsigsetjmp, r1
143 /* Call the user-provided initialization function. */
147 /* Pop the cleanup handler. */
153 add #UNWINDBUFSIZE, r15
154 cfi_adjust_cfa_offset (-UNWINDBUFSIZE)
156 /* Sucessful run of the initializer. Signal that we are done. */
158 /* Wake up all other threads. */
162 shlr r6 /* r6 = 0x7fffffff */
171 cfi_adjust_cfa_offset (-4)
174 cfi_adjust_cfa_offset (-4)
177 cfi_adjust_cfa_offset (-4)
180 cfi_adjust_cfa_offset (-4)
186 /* __sigsetjmp returned for the second time. */
187 cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
197 shlr r6 /* r6 = 0x7fffffff */
213 .long __sigsetjmp@PLT-(.Lsigsetjmp0-.)
215 .long HIDDEN_JUMPTARGET(__pthread_register_cancel)-.Lcpush0
217 .long HIDDEN_JUMPTARGET(__pthread_unregister_cancel)-.Lcpop0
219 .long HIDDEN_JUMPTARGET(__pthread_unwind_next)-.Lunext0
220 .size __pthread_once,.-__pthread_once
222 .globl __pthread_once_internal
223 __pthread_once_internal = __pthread_once
226 pthread_once = __pthread_once
229 .type clear_once_control,@function
237 shlr r6 /* r6 = 0x7fffffff */
246 .size clear_once_control,.-clear_once_control