|
|
978e96 |
This patch removes the following remaining architecture specific
|
|
|
978e96 |
pthread_once implementations:
|
|
|
978e96 |
|
|
|
978e96 |
- alpha, hppa, sh: Not used in RHEL.
|
|
|
978e96 |
|
|
|
978e96 |
- s390: Was first moved, then renamed upstream by the following commits:
|
|
|
978e96 |
|
|
|
978e96 |
commit 52ae23b4bfa09fa1f42e3f659aaa057d1176d06b
|
|
|
978e96 |
Author: Roland McGrath <roland@hack.frob.com>
|
|
|
978e96 |
Date: Thu Jun 26 09:31:11 2014 -0700
|
|
|
978e96 |
|
|
|
978e96 |
Move remaining S390 code out of nptl/.
|
|
|
978e96 |
|
|
|
978e96 |
commit bc89c0fc70ba952f78fc27fc261ec209be0a6732
|
|
|
978e96 |
Author: Torvald Riegel <triegel@redhat.com>
|
|
|
978e96 |
Date: Mon Dec 8 18:32:14 2014 +0100
|
|
|
978e96 |
|
|
|
978e96 |
Remove custom pthread_once implementation on s390.
|
|
|
978e96 |
|
|
|
978e96 |
- powerpc: Was removed upstream by the following commit:
|
|
|
978e96 |
|
|
|
978e96 |
commit 75ffb047f6ee2a545da8cf69dba9a979ca6271ce
|
|
|
978e96 |
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
|
|
|
978e96 |
Date: Sun Apr 13 18:13:42 2014 -0500
|
|
|
978e96 |
|
|
|
978e96 |
PowerPC: Sync pthread_once with default implementation
|
|
|
978e96 |
|
|
|
978e96 |
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
|
|
|
978e96 |
deleted file mode 100644
|
|
|
978e96 |
index 52ab53f0a912d107..0000000000000000
|
|
|
978e96 |
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
|
|
|
978e96 |
+++ /dev/null
|
|
|
978e96 |
@@ -1,110 +0,0 @@
|
|
|
978e96 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
978e96 |
- This file is part of the GNU C Library.
|
|
|
978e96 |
- Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
978e96 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
978e96 |
- License as published by the Free Software Foundation; either
|
|
|
978e96 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
978e96 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
978e96 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
978e96 |
- Lesser General Public License for more details.
|
|
|
978e96 |
-
|
|
|
978e96 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
978e96 |
- License along with the GNU C Library; if not, see
|
|
|
978e96 |
- <http://www.gnu.org/licenses/>. */
|
|
|
978e96 |
-
|
|
|
978e96 |
-#include "pthreadP.h"
|
|
|
978e96 |
-#include <lowlevellock.h>
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-unsigned long int __fork_generation attribute_hidden;
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-static void
|
|
|
978e96 |
-clear_once_control (void *arg)
|
|
|
978e96 |
-{
|
|
|
978e96 |
- pthread_once_t *once_control = (pthread_once_t *) arg;
|
|
|
978e96 |
-
|
|
|
978e96 |
- __asm __volatile (__lll_rel_instr);
|
|
|
978e96 |
- *once_control = 0;
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
-}
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-int
|
|
|
978e96 |
-__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|
|
978e96 |
-{
|
|
|
978e96 |
- for (;;)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- int oldval;
|
|
|
978e96 |
- int newval;
|
|
|
978e96 |
- int tmp;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Pseudo code:
|
|
|
978e96 |
- newval = __fork_generation | 1;
|
|
|
978e96 |
- oldval = *once_control;
|
|
|
978e96 |
- if ((oldval & 2) == 0)
|
|
|
978e96 |
- *once_control = newval;
|
|
|
978e96 |
- Do this atomically with an acquire barrier.
|
|
|
978e96 |
- */
|
|
|
978e96 |
- newval = __fork_generation | 1;
|
|
|
978e96 |
- __asm __volatile ("1: lwarx %0,0,%3" MUTEX_HINT_ACQ "\n"
|
|
|
978e96 |
- " andi. %1,%0,2\n"
|
|
|
978e96 |
- " bne 2f\n"
|
|
|
978e96 |
- " stwcx. %4,0,%3\n"
|
|
|
978e96 |
- " bne 1b\n"
|
|
|
978e96 |
- "2: " __lll_acq_instr
|
|
|
978e96 |
- : "=&r" (oldval), "=&r" (tmp), "=m" (*once_control)
|
|
|
978e96 |
- : "r" (once_control), "r" (newval), "m" (*once_control)
|
|
|
978e96 |
- : "cr0");
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check if the initializer has already been done. */
|
|
|
978e96 |
- if ((oldval & 2) != 0)
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check if another thread already runs the initializer. */
|
|
|
978e96 |
- if ((oldval & 1) == 0)
|
|
|
978e96 |
- break;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check whether the initializer execution was interrupted by a fork. */
|
|
|
978e96 |
- if (oldval != newval)
|
|
|
978e96 |
- break;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Same generation, some other thread was faster. Wait. */
|
|
|
978e96 |
- lll_futex_wait (once_control, oldval, LLL_PRIVATE);
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* This thread is the first here. Do the initialization.
|
|
|
978e96 |
- Register a cleanup handler so that in case the thread gets
|
|
|
978e96 |
- interrupted the initialization can be restarted. */
|
|
|
978e96 |
- pthread_cleanup_push (clear_once_control, once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- init_routine ();
|
|
|
978e96 |
-
|
|
|
978e96 |
- pthread_cleanup_pop (0);
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Add one to *once_control to take the bottom 2 bits from 01 to 10.
|
|
|
978e96 |
- A release barrier is needed to ensure memory written by init_routine
|
|
|
978e96 |
- is seen in other threads before *once_control changes. */
|
|
|
978e96 |
- int tmp;
|
|
|
978e96 |
- __asm __volatile (__lll_rel_instr "\n"
|
|
|
978e96 |
- "1: lwarx %0,0,%2" MUTEX_HINT_REL "\n"
|
|
|
978e96 |
- " addi %0,%0,1\n"
|
|
|
978e96 |
- " stwcx. %0,0,%2\n"
|
|
|
978e96 |
- " bne- 1b"
|
|
|
978e96 |
- : "=&b" (tmp), "=m" (*once_control)
|
|
|
978e96 |
- : "r" (once_control), "m" (*once_control)
|
|
|
978e96 |
- : "cr0");
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Wake up all other threads. */
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
-
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-}
|
|
|
978e96 |
-weak_alias (__pthread_once, pthread_once)
|
|
|
978e96 |
-hidden_def (__pthread_once)
|
|
|
978e96 |
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/pthread_once.c b/nptl/sysdeps/unix/sysv/linux/s390/pthread_once.c
|
|
|
978e96 |
deleted file mode 100644
|
|
|
978e96 |
index 4bce7fec13ea3bb2..0000000000000000
|
|
|
978e96 |
--- a/nptl/sysdeps/unix/sysv/linux/s390/pthread_once.c
|
|
|
978e96 |
+++ /dev/null
|
|
|
978e96 |
@@ -1,108 +0,0 @@
|
|
|
978e96 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
978e96 |
- This file is part of the GNU C Library.
|
|
|
978e96 |
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
978e96 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
978e96 |
- License as published by the Free Software Foundation; either
|
|
|
978e96 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
978e96 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
978e96 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
978e96 |
- Lesser General Public License for more details.
|
|
|
978e96 |
-
|
|
|
978e96 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
978e96 |
- License along with the GNU C Library; if not, see
|
|
|
978e96 |
- <http://www.gnu.org/licenses/>. */
|
|
|
978e96 |
-
|
|
|
978e96 |
-#include "pthreadP.h"
|
|
|
978e96 |
-#include <lowlevellock.h>
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-unsigned long int __fork_generation attribute_hidden;
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-static void
|
|
|
978e96 |
-clear_once_control (void *arg)
|
|
|
978e96 |
-{
|
|
|
978e96 |
- pthread_once_t *once_control = (pthread_once_t *) arg;
|
|
|
978e96 |
-
|
|
|
978e96 |
- *once_control = 0;
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
-}
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-int
|
|
|
978e96 |
-__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|
|
978e96 |
-{
|
|
|
978e96 |
- while (1)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- int oldval;
|
|
|
978e96 |
- int newval;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Pseudo code:
|
|
|
978e96 |
- oldval = *once_control;
|
|
|
978e96 |
- if ((oldval & 2) == 0)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- newval = (oldval & 3) | __fork_generation | 1;
|
|
|
978e96 |
- *once_control = newval;
|
|
|
978e96 |
- }
|
|
|
978e96 |
- Do this atomically. */
|
|
|
978e96 |
- __asm __volatile (" l %1,%0\n"
|
|
|
978e96 |
- "0: lhi %2,2\n"
|
|
|
978e96 |
- " tml %1,2\n"
|
|
|
978e96 |
- " jnz 1f\n"
|
|
|
978e96 |
- " nr %2,%1\n"
|
|
|
978e96 |
- " ahi %2,1\n"
|
|
|
978e96 |
- " o %2,%3\n"
|
|
|
978e96 |
- " cs %1,%2,%0\n"
|
|
|
978e96 |
- " jl 0b\n"
|
|
|
978e96 |
- "1:"
|
|
|
978e96 |
- : "=Q" (*once_control), "=&d" (oldval), "=&d" (newval)
|
|
|
978e96 |
- : "m" (__fork_generation), "m" (*once_control)
|
|
|
978e96 |
- : "cc" );
|
|
|
978e96 |
- /* Check if the initialized has already been done. */
|
|
|
978e96 |
- if ((oldval & 2) != 0)
|
|
|
978e96 |
- break;
|
|
|
978e96 |
- /* Check if another thread already runs the initializer. */
|
|
|
978e96 |
- if ((oldval & 1) != 0)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- /* Check whether the initializer execution was interrupted
|
|
|
978e96 |
- by a fork. */
|
|
|
978e96 |
- if (((oldval ^ newval) & -4) == 0)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- /* Same generation, some other thread was faster. Wait. */
|
|
|
978e96 |
- lll_futex_wait (once_control, newval, LLL_PRIVATE);
|
|
|
978e96 |
- continue;
|
|
|
978e96 |
- }
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* This thread is the first here. Do the initialization.
|
|
|
978e96 |
- Register a cleanup handler so that in case the thread gets
|
|
|
978e96 |
- interrupted the initialization can be restarted. */
|
|
|
978e96 |
- pthread_cleanup_push (clear_once_control, once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- init_routine ();
|
|
|
978e96 |
-
|
|
|
978e96 |
- pthread_cleanup_pop (0);
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Add one to *once_control. */
|
|
|
978e96 |
- __asm __volatile (" l %1,%0\n"
|
|
|
978e96 |
- "0: lr %2,%1\n"
|
|
|
978e96 |
- " ahi %2,1\n"
|
|
|
978e96 |
- " cs %1,%2,%0\n"
|
|
|
978e96 |
- " jl 0b\n"
|
|
|
978e96 |
- : "=Q" (*once_control), "=&d" (oldval), "=&d" (newval)
|
|
|
978e96 |
- : "m" (*once_control) : "cc" );
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Wake up all other threads. */
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
- break;
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-}
|
|
|
978e96 |
-weak_alias (__pthread_once, pthread_once)
|
|
|
978e96 |
-hidden_def (__pthread_once)
|
|
|
978e96 |
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S
|
|
|
978e96 |
deleted file mode 100644
|
|
|
978e96 |
index 62b92d8b103ded65..0000000000000000
|
|
|
978e96 |
--- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S
|
|
|
978e96 |
+++ /dev/null
|
|
|
978e96 |
@@ -1,257 +0,0 @@
|
|
|
978e96 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
978e96 |
- This file is part of the GNU C Library.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
978e96 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
978e96 |
- License as published by the Free Software Foundation; either
|
|
|
978e96 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
978e96 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
978e96 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
978e96 |
- Lesser General Public License for more details.
|
|
|
978e96 |
-
|
|
|
978e96 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
978e96 |
- License along with the GNU C Library; if not, see
|
|
|
978e96 |
- <http://www.gnu.org/licenses/>. */
|
|
|
978e96 |
-
|
|
|
978e96 |
-#include <unwindbuf.h>
|
|
|
978e96 |
-#include <sysdep.h>
|
|
|
978e96 |
-#include <kernel-features.h>
|
|
|
978e96 |
-#include <lowlevellock.h>
|
|
|
978e96 |
-#include "lowlevel-atomic.h"
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
- .comm __fork_generation, 4, 4
|
|
|
978e96 |
-
|
|
|
978e96 |
- .text
|
|
|
978e96 |
- .globl __pthread_once
|
|
|
978e96 |
- .type __pthread_once,@function
|
|
|
978e96 |
- .align 5
|
|
|
978e96 |
- cfi_startproc
|
|
|
978e96 |
-__pthread_once:
|
|
|
978e96 |
- mov.l @r4, r0
|
|
|
978e96 |
- tst #2, r0
|
|
|
978e96 |
- bt 1f
|
|
|
978e96 |
- rts
|
|
|
978e96 |
- mov #0, r0
|
|
|
978e96 |
-
|
|
|
978e96 |
-1:
|
|
|
978e96 |
- mov.l r12, @-r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (4)
|
|
|
978e96 |
- cfi_rel_offset (r12, 0)
|
|
|
978e96 |
- mov.l r9, @-r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (4)
|
|
|
978e96 |
- cfi_rel_offset (r9, 0)
|
|
|
978e96 |
- mov.l r8, @-r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (4)
|
|
|
978e96 |
- cfi_rel_offset (r8, 0)
|
|
|
978e96 |
- sts.l pr, @-r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (4)
|
|
|
978e96 |
- cfi_rel_offset (pr, 0)
|
|
|
978e96 |
- mov r5, r8
|
|
|
978e96 |
- mov r4, r9
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Not yet initialized or initialization in progress.
|
|
|
978e96 |
- Get the fork generation counter now. */
|
|
|
978e96 |
-6:
|
|
|
978e96 |
- mov.l @r4, r1
|
|
|
978e96 |
- mova .Lgot, r0
|
|
|
978e96 |
- mov.l .Lgot, r12
|
|
|
978e96 |
- add r0, r12
|
|
|
978e96 |
-
|
|
|
978e96 |
-5:
|
|
|
978e96 |
- mov r1, r0
|
|
|
978e96 |
-
|
|
|
978e96 |
- tst #2, r0
|
|
|
978e96 |
- bf 4f
|
|
|
978e96 |
-
|
|
|
978e96 |
- and #3, r0
|
|
|
978e96 |
- mov.l .Lfgen, r2
|
|
|
978e96 |
-#ifdef PIC
|
|
|
978e96 |
- add r12, r2
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
- mov.l @r2, r3
|
|
|
978e96 |
- or r3, r0
|
|
|
978e96 |
- or #1, r0
|
|
|
978e96 |
- mov r0, r3
|
|
|
978e96 |
- mov r1, r5
|
|
|
978e96 |
-
|
|
|
978e96 |
- CMPXCHG (r5, @r4, r3, r2)
|
|
|
978e96 |
- bf 5b
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check whether another thread already runs the initializer. */
|
|
|
978e96 |
- mov r2, r0
|
|
|
978e96 |
- tst #1, r0
|
|
|
978e96 |
- bt 3f /* No -> do it. */
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check whether the initializer execution was interrupted
|
|
|
978e96 |
- by a fork. */
|
|
|
978e96 |
- xor r3, r0
|
|
|
978e96 |
- mov #-4, r1 /* -4 = 0xfffffffc */
|
|
|
978e96 |
- tst r1, r0
|
|
|
978e96 |
- bf 3f /* Different for generation -> run initializer. */
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Somebody else got here first. Wait. */
|
|
|
978e96 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
978e96 |
- mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r5
|
|
|
978e96 |
- extu.b r5, r5
|
|
|
978e96 |
-#else
|
|
|
978e96 |
- stc gbr, r1
|
|
|
978e96 |
- mov.w .Lpfoff, r2
|
|
|
978e96 |
- add r2, r1
|
|
|
978e96 |
- mov.l @r1, r5
|
|
|
978e96 |
-# if FUTEX_WAIT != 0
|
|
|
978e96 |
- mov #FUTEX_WAIT, r0
|
|
|
978e96 |
- or r0, r5
|
|
|
978e96 |
-# endif
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
- mov r3, r6
|
|
|
978e96 |
- mov #0, r7
|
|
|
978e96 |
- mov #SYS_futex, r3
|
|
|
978e96 |
- extu.b r3, r3
|
|
|
978e96 |
- trapa #0x14
|
|
|
978e96 |
- SYSCALL_INST_PAD
|
|
|
978e96 |
- bra 6b
|
|
|
978e96 |
- nop
|
|
|
978e96 |
-
|
|
|
978e96 |
- .align 2
|
|
|
978e96 |
-.Lgot:
|
|
|
978e96 |
- .long _GLOBAL_OFFSET_TABLE_
|
|
|
978e96 |
-#ifdef PIC
|
|
|
978e96 |
-.Lfgen:
|
|
|
978e96 |
- .long __fork_generation@GOTOFF
|
|
|
978e96 |
-#else
|
|
|
978e96 |
-.Lfgen:
|
|
|
978e96 |
- .long __fork_generation
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
-
|
|
|
978e96 |
-3:
|
|
|
978e96 |
- /* Call the initializer function after setting up the
|
|
|
978e96 |
- cancellation handler. Note that it is not possible here
|
|
|
978e96 |
- to use the unwind-based cleanup handling. This would require
|
|
|
978e96 |
- that the user-provided function and all the code it calls
|
|
|
978e96 |
- is compiled with exceptions. Unfortunately this cannot be
|
|
|
978e96 |
- guaranteed. */
|
|
|
978e96 |
- add #-UNWINDBUFSIZE, r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (UNWINDBUFSIZE)
|
|
|
978e96 |
-
|
|
|
978e96 |
- mov.l .Lsigsetjmp, r1
|
|
|
978e96 |
- mov #UWJMPBUF, r4
|
|
|
978e96 |
- add r15, r4
|
|
|
978e96 |
- bsrf r1
|
|
|
978e96 |
- mov #0, r5
|
|
|
978e96 |
-.Lsigsetjmp0:
|
|
|
978e96 |
- tst r0, r0
|
|
|
978e96 |
- bf 7f
|
|
|
978e96 |
-
|
|
|
978e96 |
- mov.l .Lcpush, r1
|
|
|
978e96 |
- bsrf r1
|
|
|
978e96 |
- mov r15, r4
|
|
|
978e96 |
-.Lcpush0:
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Call the user-provided initialization function. */
|
|
|
978e96 |
- jsr @r8
|
|
|
978e96 |
- nop
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Pop the cleanup handler. */
|
|
|
978e96 |
- mov.l .Lcpop, r1
|
|
|
978e96 |
- bsrf r1
|
|
|
978e96 |
- mov r15, r4
|
|
|
978e96 |
-.Lcpop0:
|
|
|
978e96 |
-
|
|
|
978e96 |
- add #UNWINDBUFSIZE, r15
|
|
|
978e96 |
- cfi_adjust_cfa_offset (-UNWINDBUFSIZE)
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Sucessful run of the initializer. Signal that we are done. */
|
|
|
978e96 |
- INC (@r9, r2)
|
|
|
978e96 |
- /* Wake up all other threads. */
|
|
|
978e96 |
- mov r9, r4
|
|
|
978e96 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
978e96 |
- mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
|
|
|
978e96 |
- extu.b r5, r5
|
|
|
978e96 |
-#else
|
|
|
978e96 |
- stc gbr, r1
|
|
|
978e96 |
- mov.w .Lpfoff, r2
|
|
|
978e96 |
- add r2, r1
|
|
|
978e96 |
- mov.l @r1, r5
|
|
|
978e96 |
- mov #FUTEX_WAKE, r0
|
|
|
978e96 |
- or r0, r5
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
- mov #-1, r6
|
|
|
978e96 |
- shlr r6 /* r6 = 0x7fffffff */
|
|
|
978e96 |
- mov #0, r7
|
|
|
978e96 |
- mov #SYS_futex, r3
|
|
|
978e96 |
- extu.b r3, r3
|
|
|
978e96 |
- trapa #0x14
|
|
|
978e96 |
- SYSCALL_INST_PAD
|
|
|
978e96 |
-
|
|
|
978e96 |
-4:
|
|
|
978e96 |
- lds.l @r15+, pr
|
|
|
978e96 |
- cfi_adjust_cfa_offset (-4)
|
|
|
978e96 |
- cfi_restore (pr)
|
|
|
978e96 |
- mov.l @r15+, r8
|
|
|
978e96 |
- cfi_adjust_cfa_offset (-4)
|
|
|
978e96 |
- cfi_restore (r8)
|
|
|
978e96 |
- mov.l @r15+, r9
|
|
|
978e96 |
- cfi_adjust_cfa_offset (-4)
|
|
|
978e96 |
- cfi_restore (r9)
|
|
|
978e96 |
- mov.l @r15+, r12
|
|
|
978e96 |
- cfi_adjust_cfa_offset (-4)
|
|
|
978e96 |
- cfi_restore (r12)
|
|
|
978e96 |
- rts
|
|
|
978e96 |
- mov #0, r0
|
|
|
978e96 |
-
|
|
|
978e96 |
-7:
|
|
|
978e96 |
- /* __sigsetjmp returned for the second time. */
|
|
|
978e96 |
- cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
|
|
|
978e96 |
- cfi_offset (r12, -4)
|
|
|
978e96 |
- cfi_offset (r9, -8)
|
|
|
978e96 |
- cfi_offset (r8, -12)
|
|
|
978e96 |
- cfi_offset (pr, -16)
|
|
|
978e96 |
- mov #0, r7
|
|
|
978e96 |
- mov.l r7, @r9
|
|
|
978e96 |
- mov r9, r4
|
|
|
978e96 |
-#ifdef __ASSUME_PRIVATE_FUTEX
|
|
|
978e96 |
- mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
|
|
|
978e96 |
-#else
|
|
|
978e96 |
- stc gbr, r1
|
|
|
978e96 |
- mov.w .Lpfoff, r2
|
|
|
978e96 |
- add r2, r1
|
|
|
978e96 |
- mov.l @r1, r5
|
|
|
978e96 |
- mov #FUTEX_WAKE, r0
|
|
|
978e96 |
- or r0, r5
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
- extu.b r5, r5
|
|
|
978e96 |
- mov #-1, r6
|
|
|
978e96 |
- shlr r6 /* r6 = 0x7fffffff */
|
|
|
978e96 |
- mov #SYS_futex, r3
|
|
|
978e96 |
- extu.b r3, r3
|
|
|
978e96 |
- trapa #0x14
|
|
|
978e96 |
- SYSCALL_INST_PAD
|
|
|
978e96 |
-
|
|
|
978e96 |
- mov.l .Lunext, r1
|
|
|
978e96 |
- bsrf r1
|
|
|
978e96 |
- mov r15, r4
|
|
|
978e96 |
-.Lunext0:
|
|
|
978e96 |
- /* NOTREACHED */
|
|
|
978e96 |
- sleep
|
|
|
978e96 |
- cfi_endproc
|
|
|
978e96 |
-
|
|
|
978e96 |
-#ifndef __ASSUME_PRIVATE_FUTEX
|
|
|
978e96 |
-.Lpfoff:
|
|
|
978e96 |
- .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
|
|
|
978e96 |
-#endif
|
|
|
978e96 |
- .align 2
|
|
|
978e96 |
-.Lsigsetjmp:
|
|
|
978e96 |
- .long __sigsetjmp@PLT-(.Lsigsetjmp0-.)
|
|
|
978e96 |
-.Lcpush:
|
|
|
978e96 |
- .long HIDDEN_JUMPTARGET(__pthread_register_cancel)-.Lcpush0
|
|
|
978e96 |
-.Lcpop:
|
|
|
978e96 |
- .long HIDDEN_JUMPTARGET(__pthread_unregister_cancel)-.Lcpop0
|
|
|
978e96 |
-.Lunext:
|
|
|
978e96 |
- .long HIDDEN_JUMPTARGET(__pthread_unwind_next)-.Lunext0
|
|
|
978e96 |
- .size __pthread_once,.-__pthread_once
|
|
|
978e96 |
-
|
|
|
978e96 |
-hidden_def (__pthread_once)
|
|
|
978e96 |
-strong_alias (__pthread_once, pthread_once)
|
|
|
978e96 |
diff --git a/sysdeps/unix/sysv/linux/alpha/nptl/pthread_once.c b/sysdeps/unix/sysv/linux/alpha/nptl/pthread_once.c
|
|
|
978e96 |
deleted file mode 100644
|
|
|
978e96 |
index c342e0a7a0965086..0000000000000000
|
|
|
978e96 |
--- a/sysdeps/unix/sysv/linux/alpha/nptl/pthread_once.c
|
|
|
978e96 |
+++ /dev/null
|
|
|
978e96 |
@@ -1,95 +0,0 @@
|
|
|
978e96 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
978e96 |
- This file is part of the GNU C Library.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
978e96 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
978e96 |
- License as published by the Free Software Foundation; either
|
|
|
978e96 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
978e96 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
978e96 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
978e96 |
- Lesser General Public License for more details.
|
|
|
978e96 |
-
|
|
|
978e96 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
978e96 |
- License along with the GNU C Library. If not, see
|
|
|
978e96 |
- <http://www.gnu.org/licenses/>. */
|
|
|
978e96 |
-
|
|
|
978e96 |
-#include "pthreadP.h"
|
|
|
978e96 |
-#include <lowlevellock.h>
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-unsigned long int __fork_generation attribute_hidden;
|
|
|
978e96 |
-
|
|
|
978e96 |
-static void
|
|
|
978e96 |
-clear_once_control (void *arg)
|
|
|
978e96 |
-{
|
|
|
978e96 |
- pthread_once_t *once_control = (pthread_once_t *) arg;
|
|
|
978e96 |
-
|
|
|
978e96 |
- *once_control = 0;
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
-}
|
|
|
978e96 |
-
|
|
|
978e96 |
-int
|
|
|
978e96 |
-__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
|
|
978e96 |
-{
|
|
|
978e96 |
- for (;;)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- int oldval;
|
|
|
978e96 |
- int newval;
|
|
|
978e96 |
- int tmp;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Pseudo code:
|
|
|
978e96 |
- newval = __fork_generation | 1;
|
|
|
978e96 |
- oldval = *once_control;
|
|
|
978e96 |
- if ((oldval & 2) == 0)
|
|
|
978e96 |
- *once_control = newval;
|
|
|
978e96 |
- Do this atomically.
|
|
|
978e96 |
- */
|
|
|
978e96 |
- newval = __fork_generation | 1;
|
|
|
978e96 |
- __asm __volatile (
|
|
|
978e96 |
- "1: ldl_l %0, %2\n"
|
|
|
978e96 |
- " and %0, 2, %1\n"
|
|
|
978e96 |
- " bne %1, 2f\n"
|
|
|
978e96 |
- " mov %3, %1\n"
|
|
|
978e96 |
- " stl_c %1, %2\n"
|
|
|
978e96 |
- " beq %1, 1b\n"
|
|
|
978e96 |
- "2: mb"
|
|
|
978e96 |
- : "=&r" (oldval), "=&r" (tmp), "=m" (*once_control)
|
|
|
978e96 |
- : "r" (newval), "m" (*once_control));
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check if the initializer has already been done. */
|
|
|
978e96 |
- if ((oldval & 2) != 0)
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check if another thread already runs the initializer. */
|
|
|
978e96 |
- if ((oldval & 1) == 0)
|
|
|
978e96 |
- break;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check whether the initializer execution was interrupted by a fork. */
|
|
|
978e96 |
- if (oldval != newval)
|
|
|
978e96 |
- break;
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Same generation, some other thread was faster. Wait. */
|
|
|
978e96 |
- lll_futex_wait (once_control, oldval, LLL_PRIVATE);
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* This thread is the first here. Do the initialization.
|
|
|
978e96 |
- Register a cleanup handler so that in case the thread gets
|
|
|
978e96 |
- interrupted the initialization can be restarted. */
|
|
|
978e96 |
- pthread_cleanup_push (clear_once_control, once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- init_routine ();
|
|
|
978e96 |
-
|
|
|
978e96 |
- pthread_cleanup_pop (0);
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Add one to *once_control to take the bottom 2 bits from 01 to 10. */
|
|
|
978e96 |
- atomic_increment (once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Wake up all other threads. */
|
|
|
978e96 |
- lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
|
|
|
978e96 |
-
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-}
|
|
|
978e96 |
-weak_alias (__pthread_once, pthread_once)
|
|
|
978e96 |
-hidden_def (__pthread_once)
|
|
|
978e96 |
diff --git a/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c b/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
|
|
|
978e96 |
deleted file mode 100644
|
|
|
978e96 |
index b920ebb22c10a569..0000000000000000
|
|
|
978e96 |
--- a/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
|
|
|
978e96 |
+++ /dev/null
|
|
|
978e96 |
@@ -1,93 +0,0 @@
|
|
|
978e96 |
-/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
|
|
|
978e96 |
- This file is part of the GNU C Library.
|
|
|
978e96 |
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
978e96 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
978e96 |
- License as published by the Free Software Foundation; either
|
|
|
978e96 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
978e96 |
-
|
|
|
978e96 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
978e96 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
978e96 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
978e96 |
- Lesser General Public License for more details.
|
|
|
978e96 |
-
|
|
|
978e96 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
978e96 |
- License along with the GNU C Library. If not, see
|
|
|
978e96 |
- <http://www.gnu.org/licenses/>. */
|
|
|
978e96 |
-
|
|
|
978e96 |
-#include "pthreadP.h"
|
|
|
978e96 |
-#include <lowlevellock.h>
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-unsigned long int __fork_generation attribute_hidden;
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-static void
|
|
|
978e96 |
-clear_once_control (void *arg)
|
|
|
978e96 |
-{
|
|
|
978e96 |
- pthread_once_t *once_control = (pthread_once_t *) arg;
|
|
|
978e96 |
-
|
|
|
978e96 |
- *once_control = 0;
|
|
|
978e96 |
- lll_private_futex_wake (once_control, INT_MAX);
|
|
|
978e96 |
-}
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
-int
|
|
|
978e96 |
-__pthread_once (once_control, init_routine)
|
|
|
978e96 |
- pthread_once_t *once_control;
|
|
|
978e96 |
- void (*init_routine) (void);
|
|
|
978e96 |
-{
|
|
|
978e96 |
- while (1)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- int oldval, val, newval;
|
|
|
978e96 |
-
|
|
|
978e96 |
- val = *once_control;
|
|
|
978e96 |
- do
|
|
|
978e96 |
- {
|
|
|
978e96 |
- /* Check if the initialized has already been done. */
|
|
|
978e96 |
- if ((val & 2) != 0)
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-
|
|
|
978e96 |
- oldval = val;
|
|
|
978e96 |
- newval = (oldval & 3) | __fork_generation | 1;
|
|
|
978e96 |
- val = atomic_compare_and_exchange_val_acq (once_control, newval,
|
|
|
978e96 |
- oldval);
|
|
|
978e96 |
- }
|
|
|
978e96 |
- while (__builtin_expect (val != oldval, 0));
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Check if another thread already runs the initializer. */
|
|
|
978e96 |
- if ((oldval & 1) != 0)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- /* Check whether the initializer execution was interrupted
|
|
|
978e96 |
- by a fork. */
|
|
|
978e96 |
- if (((oldval ^ newval) & -4) == 0)
|
|
|
978e96 |
- {
|
|
|
978e96 |
- /* Same generation, some other thread was faster. Wait. */
|
|
|
978e96 |
- lll_private_futex_wait (once_control, newval);
|
|
|
978e96 |
- continue;
|
|
|
978e96 |
- }
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* This thread is the first here. Do the initialization.
|
|
|
978e96 |
- Register a cleanup handler so that in case the thread gets
|
|
|
978e96 |
- interrupted the initialization can be restarted. */
|
|
|
978e96 |
- pthread_cleanup_push (clear_once_control, once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- init_routine ();
|
|
|
978e96 |
-
|
|
|
978e96 |
- pthread_cleanup_pop (0);
|
|
|
978e96 |
-
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Add one to *once_control. */
|
|
|
978e96 |
- atomic_increment (once_control);
|
|
|
978e96 |
-
|
|
|
978e96 |
- /* Wake up all other threads. */
|
|
|
978e96 |
- lll_private_futex_wake (once_control, INT_MAX);
|
|
|
978e96 |
- break;
|
|
|
978e96 |
- }
|
|
|
978e96 |
-
|
|
|
978e96 |
- return 0;
|
|
|
978e96 |
-}
|
|
|
978e96 |
-weak_alias (__pthread_once, pthread_once)
|
|
|
978e96 |
-hidden_def (__pthread_once)
|