1 /* Copyright (C) 2002, 2003 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
29 .comm __fork_generation, 4, 4
35 .type __pthread_once,@function
45 /* Not yet initialized or initialization in progress.
46 Get the fork generation counter now. */
55 orl __fork_generation(%rip), %edx
62 /* Check whether another thread already runs the initializer. */
64 jz 3f /* No -> do it. */
66 /* Check whether the initializer execution was interrupted
69 testl $0xfffffffc, %eax
70 jnz 3f /* Different for generation -> run initializer. */
72 /* Somebody else got here first. Wait. */
73 movq %rsi, %rcx /* movl $FUTEX_WAIT, %ecx */
78 /* Preserve the pointer to the control variable. */
81 /* Call the initializer function after setting up the
82 cancellation handler. */
85 /* Push the cleanup handler. */
86 leaq clear_once_control(%rip), %rsi
89 call __pthread_cleanup_push /* Note: no @PLT. */
94 /* Pop the cleanup handler. This code depends on the once
95 handler and _pthread_cleanup_push not touch the content
96 of the stack. Otherwise the first parameter would have
99 call __pthread_cleanup_pop /* Note: no @PLT. */
103 /* Get the control variable address back. */
106 /* Sucessful run of the initializer. Signal that we are done. */
110 /* Wake up all other threads. */
111 movl $0x7fffffff, %edx
112 movl $FUTEX_WAKE, %esi
114 movl $SYS_futex, %eax
120 .size __pthread_once,.-__pthread_once
123 pthread_once = __pthread_once
126 .type clear_once_control,@function
132 movl $0x7fffffff, %edx
133 movl $FUTEX_WAKE, %esi
134 movl $SYS_futex, %eax
138 .size clear_once_control,.-clear_once_control