1 /* Copyright (C) 2003 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
20 #include "lowlevel-atomic.h"
26 .comm __fork_generation, 4, 4
30 .type __pthread_once,@function
46 /* Not yet initialized or initialization in progress.
47 Get the fork generation counter now. */
73 CMPXCHG (r5, @r4, r3, r2)
76 /* Check whether another thread already runs the initializer. */
79 bt 3f /* No -> do it. */
81 /* Check whether the initializer execution was interrupted
84 mov #-4, r1 /* -4 = 0xfffffffc */
86 bf 3f /* Different for generation -> run initializer. */
88 /* Somebody else got here first. Wait. */
102 .long _GLOBAL_OFFSET_TABLE_
104 .long __fork_generation@GOTOFF
107 .long __fork_generation
111 /* Call the initializer function after setting up the
112 cancellation handler. */
113 /* Allocate a _pthread_cleanup_buffer on stack. */
116 /* Push the cleanup handler. */
130 /* Pop the cleanup handler. */
138 /* Sucessful run of the initializer. Signal that we are done. */
140 /* Wake up all other threads. */
144 shlr r6 /* r6 = 0x7fffffff */
162 .long clear_once_control@GOTOFF
164 .long clear_once_control
167 .long __pthread_cleanup_push - .Lcpush0 /* Note: no @PLT. */
169 .long __pthread_cleanup_pop - .Lcpop0 /* Note: no @PLT. */
171 .size __pthread_once,.-__pthread_once
173 .globl __pthread_once_internal
174 __pthread_once_internal = __pthread_once
177 pthread_once = __pthread_once
180 .type clear_once_control,@function
188 shlr r6 /* r6 = 0x7fffffff */
197 .size clear_once_control,.-clear_once_control