summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/sysdeps
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:04:02 -0600
committerWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:04:02 -0600
commite1e46622ac0fce73d802fa4a8a2e83cc25cd9e7a (patch)
tree2c8d14e4dcc733f4227f0984ed05da5826b13acd /libpthread/linuxthreads/sysdeps
parent6b6ede3d15f04fe825cfa9f697507457e3640344 (diff)
Revert "resolve merge"
This reverts commit 6b6ede3d15f04fe825cfa9f697507457e3640344.
Diffstat (limited to 'libpthread/linuxthreads/sysdeps')
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c89
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/pspinlock.c109
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/tls.h133
-rw-r--r--libpthread/linuxthreads/sysdeps/arc/pt-machine.h42
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pspinlock.c81
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pt-machine.h69
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/tls.h171
-rw-r--r--libpthread/linuxthreads/sysdeps/bfin/pt-machine.h75
-rw-r--r--libpthread/linuxthreads/sysdeps/cris/pspinlock.c71
-rw-r--r--libpthread/linuxthreads/sysdeps/cris/pt-machine.h21
-rw-r--r--libpthread/linuxthreads/sysdeps/frv/pt-machine.h69
-rw-r--r--libpthread/linuxthreads/sysdeps/hppa/pspinlock.c80
-rw-r--r--libpthread/linuxthreads/sysdeps/hppa/pt-machine.h (renamed from libpthread/linuxthreads/sysdeps/h8300/pt-machine.h)44
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h (renamed from libpthread/linuxthreads/sysdeps/c6x/pt-machine.h)71
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/pspinlock.c102
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/pt-machine.h93
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/tcb-offsets.sym7
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/tls.h84
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/useldt.h19
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/pspinlock.c78
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/pt-machine.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym9
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/tls.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/m68k/pspinlock.c91
-rw-r--r--libpthread/linuxthreads/sysdeps/m68k/pt-machine.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h106
-rw-r--r--libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h17
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/pspinlock.c95
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/pt-machine.h41
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/tls.h169
-rw-r--r--libpthread/linuxthreads/sysdeps/nios/pt-machine.h67
-rw-r--r--libpthread/linuxthreads/sysdeps/nios2/pt-machine.h57
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c69
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h119
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c69
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h184
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/pspinlock.c8
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/pt-machine.h103
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym19
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/tls.h164
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h27
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h65
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h14
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h12
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h65
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/errno-loc.c44
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/flockfile.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/funlockfile.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c116
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c44
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/list.h113
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h66
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/not-cancel.h4
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/posix-timer.h203
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c123
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h14
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pthread.h46
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/res-state.c46
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/semaphore.h1
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/sigaction.c56
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/tcb-offsets.h1
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_create.c169
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_delete.c69
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c44
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c76
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_routines.c572
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_settime.c136
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/tls.h80
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/tst-timer.c113
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h47
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/pspinlock.c79
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym10
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/tls.h140
-rw-r--r--libpthread/linuxthreads/sysdeps/sh64/Makefile.arch30
-rw-r--r--libpthread/linuxthreads/sysdeps/sh64/pt-machine.c46
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/pspinlock.c87
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.h1
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.sym4
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/tls.h114
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h (renamed from libpthread/linuxthreads/sysdeps/sh64/pt-machine.h)29
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c88
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/aio_cancel.c33
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h91
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h65
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S27
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h145
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S69
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h129
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S77
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c39
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c29
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h57
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/aio_cancel.c33
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h26
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h72
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c108
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h188
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h186
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S94
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h91
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h24
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c141
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h143
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S53
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c34
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h128
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S83
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h143
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h143
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S104
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c284
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h158
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S85
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h126
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S90
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/ptlongjmp.c70
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c32
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c41
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c86
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c142
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h23
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h226
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S77
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c82
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h47
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/aio_cancel.c33
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h91
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h65
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h20
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h100
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S64
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c48
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c1
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h131
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S61
-rw-r--r--libpthread/linuxthreads/sysdeps/v850/pt-machine.h52
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c96
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h156
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/tcb-offsets.sym4
-rw-r--r--libpthread/linuxthreads/sysdeps/xtensa/pt-machine.h79
144 files changed, 9945 insertions, 1257 deletions
diff --git a/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c b/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c
new file mode 100644
index 000000000..6cdc69d58
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c
@@ -0,0 +1,89 @@
+/* Special .init and .fini section support for Alpha. Linuxthreads version.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the .init and .fini
+ sections and defines global symbols for those addresses, so they can be
+ called as functions.
+
+ * crtn.s puts the corresponding function epilogues in the .init and .fini
+ sections.
+
+ This differs from what would be generated by the generic code in that
+ we save and restore the GP within the function. In order for linker
+ relaxation to work, the value in the GP register on exit from a function
+ must be valid for the function entry point. Normally, a function is
+ contained within one object file and this is not an issue, provided
+ that the function reloads the gp after making any function calls.
+ However, _init and _fini are constructed from pieces of many object
+ files, all of which may have different GP values. So we must reload
+ the GP value from crti.o in crtn.o. */
+
+__asm__ (" \n\
+#include \"defs.h\" \n\
+ \n\
+/*@HEADER_ENDS*/ \n\
+ \n\
+/*@_init_PROLOG_BEGINS*/ \n\
+ .section .init, \"ax\", @progbits \n\
+ .globl _init \n\
+ .type _init,@function \n\
+ .usepv _init,std \n\
+_init: \n\
+ ldgp $29, 0($27) \n\
+ subq $30, 16, $30 \n\
+ stq $26, 0($30) \n\
+ stq $29, 8($30) \n\
+ jsr $26, __pthread_initialize_minimal \n\
+ ldq $29, 8($30) \n\
+ .align 3 \n\
+/*@_init_PROLOG_ENDS*/ \n\
+ \n\
+/*@_init_EPILOG_BEGINS*/ \n\
+ .section .init, \"ax\", @progbits \n\
+ ldq $26, 0($30) \n\
+ ldq $29, 8($30) \n\
+ addq $30, 16, $30 \n\
+ ret \n\
+/*@_init_EPILOG_ENDS*/ \n\
+ \n\
+/*@_fini_PROLOG_BEGINS*/ \n\
+ .section .fini, \"ax\", @progbits \n\
+ .globl _fini \n\
+ .type _fini,@function \n\
+ .usepv _fini,std \n\
+_fini: \n\
+ ldgp $29, 0($27) \n\
+ subq $30, 16, $30 \n\
+ stq $26, 0($30) \n\
+ stq $29, 8($30) \n\
+ .align 3 \n\
+/*@_fini_PROLOG_ENDS*/ \n\
+ \n\
+/*@_fini_EPILOG_BEGINS*/ \n\
+ .section .fini, \"ax\", @progbits \n\
+ ldq $26, 0($30) \n\
+ ldq $29, 8($30) \n\
+ addq $30, 16, $30 \n\
+ ret \n\
+/*@_fini_EPILOG_ENDS*/ \n\
+ \n\
+/*@TRAILER_BEGINS*/ \n\
+");
diff --git a/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c b/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c
new file mode 100644
index 000000000..cdf4be99c
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c
@@ -0,0 +1,109 @@
+/* POSIX spinlock implementation. Alpha version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+
+/* This implementation is similar to the one used in the Linux kernel.
+ But the kernel is byte instructions for the memory access. This is
+ faster but unusable here. The problem is that only 128
+ threads/processes could use the spinlock at the same time. If (by
+ a design error in the program) a thread/process would hold the
+ spinlock for a time long enough to accumulate 128 waiting
+ processes, the next one will find a positive value in the spinlock
+ and assume it is unlocked. We cannot accept that. */
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int tmp;
+ __asm__ __volatile__
+ ("1: ldl_l %0,%1\n"
+ " blbs %0,2f\n"
+ " or %0,1,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ " mb\n"
+ ".subsection 2\n"
+ "2: ldl %0,%1\n"
+ " blbs %0,2b\n"
+ " br 1b\n"
+ ".previous"
+ : "=r" (tmp), "=m" (lock)
+ : "m" (lock));
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned long int oldval;
+ unsigned long int temp;
+
+ __asm__ __volatile__
+ ("1: ldl_l %0,%1\n"
+ " and %0,%3,%2\n"
+ " bne %2,2f\n"
+ " xor %0,%3,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,3f\n"
+ " mb\n"
+ "2:\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r" (temp), "=m" (*lock), "=&r" (oldval)
+ : "Ir" (1UL), "m" (*lock));
+
+ return oldval == 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__ ("mb");
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/alpha/tls.h b/libpthread/linuxthreads/sysdeps/alpha/tls.h
new file mode 100644
index 000000000..51c7fea8b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/alpha/tls.h
@@ -0,0 +1,133 @@
+/* Definitions for thread-local data handling. linuxthreads/Alpha version.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <pt-machine.h>
+# include <stdbool.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+
+typedef struct
+{
+ dtv_t *dtv;
+
+ /* Reserved for the thread implementation. Unused in LinuxThreads. */
+ void *private;
+} tcbhead_t;
+#endif
+
+
+#ifdef HAVE_TLS_SUPPORT
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+# ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+
+/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
+# define TLS_DTV_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(TCBP, DTVP) \
+ (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(TCBP) \
+ (((tcbhead_t *) (TCBP))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(TCBP, SECONDCALL) \
+ (__builtin_set_thread_pointer (TCBP), 0)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ((pthread_descr)__builtin_thread_pointer () - 1)
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(DESCR, NR) \
+ __builtin_set_thread_pointer ((struct _pthread_descr_struct *)(DESCR) + 1)
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* ??? Generic bits of LinuxThreads may call these macros with
+ DESCR set to NULL. We are expected to be able to reference
+ the "current" value.
+
+ In our case, we'd really prefer to use DESCR, since lots of
+ PAL_code calls would be expensive. We can only trust that
+ the compiler does its job and unifies the multiple
+ __builtin_thread_pointer instances. */
+
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+# endif /* HAVE_TLS_SUPPORT */
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/arc/pt-machine.h b/libpthread/linuxthreads/sysdeps/arc/pt-machine.h
deleted file mode 100644
index 8df1e77e3..000000000
--- a/libpthread/linuxthreads/sysdeps/arc/pt-machine.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
- *
- * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
- */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-PT_EI long int
-testandset (int *spinlock)
-{
- unsigned int old = 1;
-
- /* Atomically exchange @spinlock with 1 */
- __asm__ __volatile__(
- "ex %0, [%1]"
- : "+r" (old)
- : "r" (spinlock)
- : "memory");
-
- return old;
-
-}
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame.
- I don't trust register variables, so let's do this the safe way. */
-#define CURRENT_STACK_FRAME \
-__extension__ ({ char *__sp; __asm__ ("mov %0,sp" : "=r" (__sp)); __sp; })
-
-#else
-#error PT_MACHINE already defined
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/arm/pspinlock.c b/libpthread/linuxthreads/sysdeps/arm/pspinlock.c
new file mode 100644
index 000000000..691085270
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/arm/pspinlock.c
@@ -0,0 +1,81 @@
+/* POSIX spinlock implementation. Arm version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ ("swp %0, %1, [%2]"
+ : "=r" (val)
+ : "0" (1), "r" (lock)
+ : "memory");
+ while (val != 0);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ __asm__ __volatile__ ("swp %0, %1, [%2]"
+ : "=r" (val)
+ : "0" (1), "r" (lock)
+ : "memory");
+
+ return val ? EBUSY : 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
index 2b877f980..0a455b97d 100644
--- a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
ARM version.
- Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <philb@gnu.org>.
@@ -21,86 +21,29 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
-#include <sys/syscall.h>
-#include <unistd.h>
+#include <features.h>
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
-#if defined(__thumb__)
-#if defined(__USE_LDREXSTREX__)
-PT_EI long int ldrex(int *spinlock)
-{
- long int ret;
- __asm__ __volatile__(
- "ldrex %0, [%1]\n"
- : "=r"(ret)
- : "r"(spinlock) : "memory");
- return ret;
-}
-
-PT_EI long int strex(int val, int *spinlock)
-{
- long int ret;
- __asm__ __volatile__(
- "strex %0, %1, [%2]\n"
- : "=r"(ret)
- : "r" (val), "r"(spinlock) : "memory");
- return ret;
-}
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- register unsigned int ret;
-
- do {
- ret = ldrex(spinlock);
- } while (strex(1, spinlock));
-
- return ret;
-}
-
-#else /* __USE_LDREXSTREX__ */
-
/* This will not work on ARM1 or ARM2 because SWP is lacking on those
machines. Unfortunately we have no way to detect this at compile
time; let's hope nobody tries to use one. */
/* Spinlock implementation; required. */
-PT_EI long int testandset (int *spinlock);
-PT_EI long int testandset (int *spinlock)
+PT_EI long int
+testandset (int *spinlock)
{
register unsigned int ret;
- void *pc;
- __asm__ __volatile__(
- ".align 0\n"
- "\tbx pc\n"
- "\tnop\n"
- "\t.arm\n"
- "\tswp %0, %2, [%3]\n"
- "\torr %1, pc, #1\n"
- "\tbx %1\n"
- "\t.force_thumb"
- : "=r"(ret), "=r"(pc)
- : "0"(1), "r"(spinlock));
- return ret;
-}
-#endif
-#else /* __thumb__ */
-PT_EI long int testandset (int *spinlock);
-PT_EI long int testandset (int *spinlock)
-{
- register unsigned int ret;
__asm__ __volatile__("swp %0, %1, [%2]"
: "=r"(ret)
: "0"(1), "r"(spinlock));
+
return ret;
}
-#endif
+
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
diff --git a/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h
new file mode 100644
index 000000000..ba6a1e04b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h
@@ -0,0 +1,8 @@
+#include <sysdep.h>
+
+/* No multi-thread handling enabled. */
+#define SINGLE_THREAD_P (1)
+#define RTLD_SINGLE_THREAD_P (1)
+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+#define LIBC_CANCEL_HANDLED() /* Nothing. */
diff --git a/libpthread/linuxthreads/sysdeps/arm/tls.h b/libpthread/linuxthreads/sysdeps/arm/tls.h
new file mode 100644
index 000000000..df8d97009
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/arm/tls.h
@@ -0,0 +1,171 @@
+/* Definitions for thread-local data handling. linuxthreads/ARM version.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <stdbool.h>
+# include <pt-machine.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ dtv_t *dtv;
+
+ /* Reserved for the thread implementation. Unused in LinuxThreads. */
+ void *private;
+} tcbhead_t;
+#endif
+
+
+/* We can support TLS only if the floating-stack support is available.
+ However, we want to compile in the support and test at runtime whether
+ the running kernel can support it or not. To avoid bothering with the
+ TLS support code at all, use configure --without-tls.
+
+ We need USE_TLS to be consistently defined, for ldsodefs.h conditionals.
+ But some of the code below can cause problems in building libpthread
+ (e.g. useldt.h will defined FLOATING_STACKS when it shouldn't). */
+
+/* LinuxThreads can only support TLS if both floating stacks and support
+ from the tools are available.
+
+ We have to define USE_TLS consistently, or ldsodefs.h will lay out types
+ differently between an NPTL build and a LinuxThreads build. It can be set
+ for libc.so and not libpthread.so, but only if we provide appropriate padding
+ in the _pthread_descr_struct.
+
+ Currently nothing defines FLOATING_STACKS. We could assume this based on
+ kernel version once the TLS patches are available in kernel.org.
+
+ To avoid bothering with the TLS support code at all, use configure
+ --without-tls. */
+
+#if defined HAVE_TLS_SUPPORT \
+ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+/* Include padding in _pthread_descr_struct so that libc can find p_errno,
+ if libpthread will only include the padding because of the !IS_IN_libpthread
+ check. */
+#ifndef FLOATING_STACKS
+# define INCLUDE_TLS_PADDING 1
+#endif
+
+# ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+
+/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
+# define TLS_DTV_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(TCBP, DTVP) \
+ (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(TCBP) \
+ (((tcbhead_t *) (TCBP))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(TCBP, SECONDCALL) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (TCBP)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ((pthread_descr)__builtin_thread_pointer () - 1)
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(DESCR, NR) \
+ TLS_INIT_TP ((struct _pthread_descr_struct *)(DESCR) + 1, 0)
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* ??? Generic bits of LinuxThreads may call these macros with
+ DESCR set to NULL. We are expected to be able to reference
+ the "current" value.
+
+ In our case, we'd really prefer to use DESCR, since lots of
+ PAL_code calls would be expensive. We can only trust that
+ the compiler does its job and unifies the multiple
+ __builtin_thread_pointer instances. */
+
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+/* Initializing the thread pointer will generate a SIGILL if the syscall
+ is not available. */
+#define TLS_INIT_TP_EXPENSIVE 1
+
+# endif /* HAVE_TLS_SUPPORT */
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/bfin/pt-machine.h b/libpthread/linuxthreads/sysdeps/bfin/pt-machine.h
deleted file mode 100644
index 912d64b2c..000000000
--- a/libpthread/linuxthreads/sysdeps/bfin/pt-machine.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Richard Henderson <rth@tamu.edu>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-#include <asm/fixed_code.h>
-
-/* Spinlock implementation; required. */
-/* The semantics of the TESTSET instruction cannot be guaranteed. We cannot
- easily move all locks used by linux kernel to non-cacheable memory.
- EXCPT 0x4 is used to trap into kernel to do the atomic testandset.
- It's ugly. But it's the only thing we can do now.
- The handler of EXCPT 0x4 expects the address of the lock is passed through
- R0. And the result is returned by R0. */
-PT_EI long int
-testandset (int *spinlock)
-{
- long int res;
-
- __asm__ __volatile__ (
- "CALL (%4);"
- : "=q0" (res), "=m" (*spinlock)
- : "qA" (spinlock), "m" (*spinlock), "a" (ATOMIC_XCHG32), "q1" (1)
- : "RETS", "cc", "memory");
-
- return res;
-}
-
-#define HAS_COMPARE_AND_SWAP
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- long int readval;
- __asm__ __volatile__ (
- "CALL (%5);"
- : "=q0" (readval), "=m" (*p)
- : "qA" (p),
- "q1" (oldval),
- "q2" (newval),
- "a" (ATOMIC_CAS32),
- "m" (*p)
- : "RETS", "memory", "cc");
- return readval == oldval;
-}
-
-#ifdef SHARED
-# define PTHREAD_STATIC_FN_REQUIRE(name)
-#else
-# define PTHREAD_STATIC_FN_REQUIRE(name) __asm__ (".globl " "_"#name);
-#endif
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/cris/pspinlock.c b/libpthread/linuxthreads/sysdeps/cris/pspinlock.c
new file mode 100644
index 000000000..7e3e62959
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/cris/pspinlock.c
@@ -0,0 +1,71 @@
+/* POSIX spinlock implementation. CRIS version.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+/* FIXME: These are just dummies. I don't know why or if they're needed;
+ configury should default to these definitions. We just follow the
+ crowd here. */
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ while (testandset (lock) != 0)
+ ;
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ return testandset (lock) != 0 ? EBUSY : 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
index a89579ee0..9b2acb761 100644
--- a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
@@ -14,8 +14,9 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>. */
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -32,19 +33,6 @@ testandset (int *spinlock)
/* Note the use of a dummy output of *spinlock to expose the write. The
memory barrier is to stop *other* writes being moved past this code. */
-
-#ifdef __arch_v32
- __asm__ __volatile__("clearf p\n"
- "0:\n\t"
- "movu.b [%2],%0\n\t"
- "ax\n\t"
- "move.b %3,[%2]\n\t"
- "bcs 0b\n\t"
- "clearf p"
- : "=&r" (ret), "=m" (*spinlock)
- : "r" (spinlock), "r" ((int) 1), "m" (*spinlock)
- : "memory");
-#else /* not __arch_v32 */
__asm__ __volatile__("clearf\n"
"0:\n\t"
"movu.b [%2],%0\n\t"
@@ -53,9 +41,8 @@ testandset (int *spinlock)
"bwf 0b\n\t"
"clearf"
: "=&r" (ret), "=m" (*spinlock)
- : "r" (spinlock), "r" ((int) 1), "m" (*spinlock)
+ : "r" (spinlock), "r" ((int) 1)
: "memory");
-#endif /* __arch_v32 */
return ret;
}
diff --git a/libpthread/linuxthreads/sysdeps/frv/pt-machine.h b/libpthread/linuxthreads/sysdeps/frv/pt-machine.h
deleted file mode 100644
index 6f867ade7..000000000
--- a/libpthread/linuxthreads/sysdeps/frv/pt-machine.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- FR-V version.
- Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Alexandre Oliva <aoliva@redhat.com>
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef __ASSEMBLER__
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int i = 1;
- __asm__ ("swap%I0 %M0, %1" : "+m"(*(volatile int *)spinlock), "+r"(i));
- return i;
-}
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* This symbol is defined by the ABI as the stack size requested by
- the main program. */
-extern char __stacksize;
-#define ARCH_STACK_MAX_SIZE ((unsigned long)&__stacksize)
-
-/* Memory barrier; default is to do nothing */
-#define MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
-/* Write barrier. */
-#define WRITE_MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
-
-/* Return the thread descriptor for the current thread. */
-register struct _pthread_descr_struct *THREAD_SELF __asm__ ("gr29");
-#define THREAD_SELF THREAD_SELF
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) \
- (THREAD_SELF = descr)
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("sp");
-
-#endif
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c b/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c
new file mode 100644
index 000000000..1a6aa64a9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c
@@ -0,0 +1,80 @@
+/* POSIX spinlock implementation. hppa version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+ while (!val);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ __asm__ __volatile__ ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+
+ return val ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
index a37384de9..85c453c77 100644
--- a/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
@@ -1,6 +1,6 @@
/* Machine-dependent pthreads configuration and inline functions.
- H8/300 version.
- Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
+ hppa version.
+ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson <rth@tamu.edu>.
@@ -22,36 +22,38 @@
#define _PT_MACHINE_H 1
#include <features.h>
+#include <bits/initspin.h>
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("%r30");
+
+
+/* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+ someone is holding the lock. */
+
+#define xstr(s) str(s)
+#define str(s) #s
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
{
- char ret;
+ int ret;
__asm__ __volatile__(
- "sub.w %0,%0\n\t"
- "stc ccr,@-sp\n\t"
- "orc #0x80,ccr\n\t"
- "bld #0,@%2\n\t"
- "bset #0,@%2\n\t"
- "rotxl.w %0\n\t"
- "ldc @sp+,ccr\n\t"
- :"=r"(ret),"=m"(*spinlock)
- :"g"(spinlock)
- :"cc");
-
- return ret;
-}
-
+ "ldcw 0(%2),%0"
+ : "=r"(ret), "=m"(*spinlock)
+ : "r"(spinlock));
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("%sp");
+ return ret == 0;
+}
+#undef str
+#undef xstr
#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/c6x/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
index 5e8bfca56..2e52abe2e 100644
--- a/libpthread/linuxthreads/sysdeps/c6x/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
@@ -1,8 +1,8 @@
/* Machine-dependent pthreads configuration and inline functions.
- C6x version.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ i686 version.
+ Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Aurelien Jacquiot <aurelien.jacquiot@jaluna.com>.
+ Contributed by Richard Henderson <rth@tamu.edu>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
@@ -19,45 +19,60 @@
not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
+#define _PT_MACHINE_H 1
#ifndef PT_EI
-# define PT_EI extern inline
+# define PT_EI __extern_always_inline
#endif
+#include <bits/kernel-features.h>
+#ifndef __ASSEMBLER__
+extern long int testandset (int *spinlock);
extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
/* Spinlock implementation; required. */
-static inline long int
+PT_EI long int
testandset (int *spinlock)
{
- register unsigned int ret = 1;
- int dummy;
- __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tand .s2 -2, %0, %0\n\tmvc .s2 %0, CSR\n"
- : "=b" (dummy));
-
- if (*spinlock == 0) {
- *spinlock = 1;
- ret = 0;
- }
- __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tor .s2 1, %0, %0\n\tmvc .s2 %0, CSR\n"
- : "=b" (dummy));
- return ret;
+ long int ret;
+
+ __asm__ __volatile__ (
+ "xchgl %0, %1"
+ : "=r" (ret), "=m" (*spinlock)
+ : "0" (1), "m" (*spinlock)
+ : "memory");
+
+ return ret;
}
-#define WRITE_MEMORY_BARRIER()
-#define READ_MEMORY_BARRIER()
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME get_stack_pointer()
-static inline char * get_stack_pointer(void)
+/* Compare-and-swap for semaphores. It's always available on i686. */
+#define HAS_COMPARE_AND_SWAP
+
+PT_EI int
+__compare_and_swap (long int *p, long int oldval, long int newval)
{
- char *sp;
- __asm__ __volatile__ ("mv .d2 B15, %0" : "=b" (sp));
- return sp;
+ char ret;
+ long int readval;
+
+ __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
+ : "=q" (ret), "=m" (*p), "=a" (readval)
+ : "r" (newval), "m" (*p), "a" (oldval)
+ : "memory");
+ return ret;
}
+#endif
+
+#if __ASSUME_LDT_WORKS > 0
+#include "../useldt.h"
+#endif
-#define THREAD_STACK_OFFSET 8
+/* The P4 and above really want some help to prevent overheating. */
+#define BUSY_WAIT_NOP __asm__ ("rep; nop")
#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/i386/pspinlock.c b/libpthread/linuxthreads/sysdeps/i386/pspinlock.c
new file mode 100644
index 000000000..7936735f9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/i386/pspinlock.c
@@ -0,0 +1,102 @@
+/* POSIX spinlock implementation. x86 version.
+ Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+#include <bits/kernel-features.h>
+
+
+/* This implementation is similar to the one used in the Linux kernel.
+ But the kernel is byte instructions for the memory access. This is
+ faster but unusable here. The problem is that only 128
+ threads/processes could use the spinlock at the same time. If (by
+ a design error in the program) a thread/process would hold the
+ spinlock for a time long enough to accumulate 128 waiting
+ processes, the next one will find a positive value in the spinlock
+ and assume it is unlocked. We cannot accept that. */
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("\n"
+ "1:\n\t"
+ "lock; decl %0\n\t"
+ "js 2f\n\t"
+ ".section .text.spinlock,\"ax\"\n"
+ "2:\n\t"
+ "cmpl $0,%0\n\t"
+ "rep; nop\n\t"
+ "jle 2b\n\t"
+ "jmp 1b\n\t"
+ ".previous"
+ : "=m" (*lock));
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int oldval;
+
+ __asm__ __volatile__
+ ("xchgl %0,%1"
+ : "=r" (oldval), "=m" (*lock)
+ : "0" (0));
+ return oldval > 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("movl $1,%0"
+ : "=m" (*lock));
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
+
+#ifndef __ASSUME_SET_THREAD_AREA_SYSCALL
+int __have_no_set_thread_area;
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
index 24c5e6c7c..82a5cf077 100644
--- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
@@ -18,14 +18,17 @@
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
+#if defined __pentiumpro__ || defined __pentium4__ || defined __athlon__ || \
+ defined __k8__
+# include "i686/pt-machine.h"
+#else
+
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
-#include <features.h>
-
#ifndef __ASSEMBLER__
#ifndef PT_EI
-# define PT_EI __extern_always_inline __attribute__((visibility("hidden")))
+# define PT_EI __extern_always_inline
#endif
extern long int testandset (int *spinlock);
@@ -36,54 +39,6 @@ extern int __compare_and_swap (long int *p, long int oldval, long int newval);
#define CURRENT_STACK_FRAME __builtin_frame_address (0)
-/* See if we can optimize for newer cpus... */
-#if defined __GNUC__ && __GNUC__ >= 2 && \
- (defined __i486__ || defined __pentium__ || defined __pentiumpro__ || defined __pentium4__ || \
- defined __athlon__ || defined __k8__)
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- long int ret;
-
- __asm__ __volatile__ (
- "xchgl %0, %1"
- : "=r" (ret), "=m" (*spinlock)
- : "0" (1), "m" (*spinlock)
- : "memory");
-
- return ret;
-}
-
-/* Compare-and-swap for semaphores. It's always available on i686. */
-#define HAS_COMPARE_AND_SWAP
-
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- char ret;
- long int readval;
-
- __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
- : "=q" (ret), "=m" (*p), "=a" (readval)
- : "r" (newval), "m" (*p), "a" (oldval)
- : "memory");
- return ret;
-}
-
-#if defined(__ASSUME_LDT_WORKS) && __ASSUME_LDT_WORKS > 0
-#include "useldt.h"
-#endif
-
-/* The P4 and above really want some help to prevent overheating. */
-#define BUSY_WAIT_NOP __asm__ ("rep; nop")
-
-
-#else /* Generic i386 implementation */
-
-extern int compare_and_swap_is_available (void);
-
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
@@ -120,27 +75,43 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
return ret;
}
+
+PT_EI int get_eflags (void);
+PT_EI int
+get_eflags (void)
+{
+ int res;
+ __asm__ __volatile__ ("pushfl; popl %0" : "=r" (res) : );
+ return res;
+}
+
+
+PT_EI void set_eflags (int newflags);
+PT_EI void
+set_eflags (int newflags)
+{
+ __asm__ __volatile__ ("pushl %0; popfl" : : "r" (newflags) : "cc");
+}
+
+
+PT_EI int compare_and_swap_is_available (void);
PT_EI int
compare_and_swap_is_available (void)
{
+ int oldflags = get_eflags ();
int changed;
- int oldflags;
- /* get EFLAGS */
- __asm__ __volatile__ ("pushfl; popl %0" : "=r" (oldflags) : );
/* Flip AC bit in EFLAGS. */
- __asm__ __volatile__ ("pushl %0; popfl" : : "r" (oldflags ^ 0x40000) : "cc");
- /* reread EFLAGS */
- __asm__ __volatile__ ("pushfl; popl %0" : "=r" (changed) : );
+ set_eflags (oldflags ^ 0x40000);
/* See if bit changed. */
- changed = (changed ^ oldflags) & 0x40000;
+ changed = (get_eflags () ^ oldflags) & 0x40000;
/* Restore EFLAGS. */
- __asm__ __volatile__ ("pushl %0; popfl" : : "r" (oldflags) : "cc");
+ set_eflags (oldflags);
/* If the AC flag did not change, it's a 386 and it lacks cmpxchg.
Otherwise, it's a 486 or above and it has cmpxchg. */
return changed != 0;
}
-#endif /* Generic i386 implementation */
-
#endif /* __ASSEMBLER__ */
#endif /* pt-machine.h */
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/i386/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/i386/tcb-offsets.sym
new file mode 100644
index 000000000..69a5018d8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/i386/tcb-offsets.sym
@@ -0,0 +1,7 @@
+#include <sysdep.h>
+#include <tls.h>
+
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+#ifdef NEED_DL_SYSINFO
+SYSINFO_OFFSET offsetof (tcbhead_t, sysinfo)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/i386/tls.h b/libpthread/linuxthreads/sysdeps/i386/tls.h
index 4469f0776..d79bf0779 100644
--- a/libpthread/linuxthreads/sysdeps/i386/tls.h
+++ b/libpthread/linuxthreads/sysdeps/i386/tls.h
@@ -30,7 +30,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
@@ -40,15 +44,28 @@ typedef struct
thread descriptor used by libpthread. */
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+ uintptr_t sysinfo;
} tcbhead_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
#endif
+/* We can support TLS only if the floating-stack support is available.
+ However, we want to compile in the support and test at runtime whether
+ the running kernel can support it or not. To avoid bothering with the
+ TLS support code at all, use configure --without-tls.
+
+ We need USE_TLS to be consistently defined, for ldsodefs.h conditionals.
+ But some of the code below can cause problems in building libpthread
+ (e.g. useldt.h will defined FLOATING_STACKS when it shouldn't). */
-/* We can support TLS only if the floating-stack support is available. */
-#if defined FLOATING_STACKS && defined HAVE_TLS_SUPPORT
+#if defined HAVE_TLS_SUPPORT \
+ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
/* Signal that TLS support is available. */
-//# define USE_TLS 1
+# define USE_TLS 1
# ifndef __ASSEMBLER__
/* Get system call information. */
@@ -97,7 +114,20 @@ typedef struct
# define TLS_LOAD_EBX
# endif
+# if !defined IS_IN_libpthread && !defined DO_MODIFY_LDT
+# include "useldt.h" /* For the structure. */
+# endif
+# if __ASSUME_LDT_WORKS > 0
+# define TLS_DO_MODIFY_LDT_KERNEL_CHECK(doit) (doit) /* Nothing to check. */
+# else
+# define TLS_DO_MODIFY_LDT_KERNEL_CHECK(doit) \
+ (__builtin_expect (GLRO(dl_osversion) < 131939, 0) \
+ ? "kernel too old for thread-local storage support\n" \
+ : (doit))
+# endif
+
# define TLS_DO_MODIFY_LDT(descr, nr) \
+TLS_DO_MODIFY_LDT_KERNEL_CHECK( \
({ \
struct modify_ldt_ldt_s ldt_entry = \
{ nr, (unsigned long int) (descr), 0xfffff /* 4GB in pages */, \
@@ -113,8 +143,10 @@ typedef struct
here. */ \
"m" (ldt_entry), TLS_EBX_ARG (1), "c" (&ldt_entry), \
"d" (sizeof (ldt_entry))); \
- __builtin_expect (result, 0) != 0 ? -1 : nr * 8 + 7; \
-})
+ __builtin_expect (result, 0) == 0 \
+ ? ({ __asm__ ("movw %w0, %%gs" : : "q" ((nr) * 8 + 7)); NULL; }) \
+ : "cannot set up LDT for thread-local storage\n"; \
+}))
# define TLS_DO_SET_THREAD_AREA(descr, secondcall) \
({ \
@@ -135,50 +167,60 @@ typedef struct
to let the compiler know that we are accessing LDT_ENTRY \
here. */ \
TLS_EBX_ARG (&ldt_entry), "m" (ldt_entry)); \
- __builtin_expect (result, 0) == 0 ? ldt_entry.entry_number * 8 + 3 : -1; \
+ if (__builtin_expect (result, 0) == 0) \
+ __asm__ ("movw %w0, %%gs" : : "q" (ldt_entry.entry_number * 8 + 3)); \
+ result; \
})
# ifdef __ASSUME_SET_THREAD_AREA_SYSCALL
-# define TLS_SETUP_GS_SEGMENT(descr, secondcall) \
- TLS_DO_SET_THREAD_AREA (descr, firstcall)
+# define TLS_SETUP_GS_SEGMENT(descr, secondcall) \
+ (TLS_DO_SET_THREAD_AREA (descr, secondcall) \
+ ? "set_thread_area failed when setting up thread-local storage\n" : NULL)
# elif defined __NR_set_thread_area
# define TLS_SETUP_GS_SEGMENT(descr, secondcall) \
- ({ int __seg = TLS_DO_SET_THREAD_AREA (descr, secondcall); \
- __seg == -1 ? TLS_DO_MODIFY_LDT (descr, 0) : __seg; })
+ (TLS_DO_SET_THREAD_AREA (descr, secondcall) \
+ ? TLS_DO_MODIFY_LDT (descr, 0) : NULL)
# else
# define TLS_SETUP_GS_SEGMENT(descr, secondcall) \
TLS_DO_MODIFY_LDT ((descr), 0)
# endif
+#if defined NEED_DL_SYSINFO
+# define INIT_SYSINFO \
+ head->sysinfo = GLRO(dl_sysinfo)
+#else
+# define INIT_SYSINFO
+#endif
+
/* Code to initially initialize the thread pointer. This might need
special attention since 'errno' is not yet available and if the
- operation can cause a failure 'errno' must not be touched. */
+ operation can cause a failure 'errno' must not be touched.
+
+ The value of this macro is null if successful, or an error string. */
# define TLS_INIT_TP(descr, secondcall) \
({ \
void *_descr = (descr); \
tcbhead_t *head = _descr; \
- int __gs; \
\
head->tcb = _descr; \
/* For now the thread descriptor is at the same address. */ \
head->self = _descr; \
\
- __gs = TLS_SETUP_GS_SEGMENT (_descr, secondcall); \
- if (__builtin_expect (__gs, 7) != -1) \
- { \
- __asm__ ("movw %w0, %%gs" : : "q" (__gs)); \
- __gs = 0; \
- } \
- __gs; \
+ INIT_SYSINFO; \
+ TLS_SETUP_GS_SEGMENT (_descr, secondcall); \
})
+/* Indicate that dynamic linker shouldn't try to initialize TLS even
+ when no PT_TLS segments are found in the program and libraries
+ it is linked against. */
+# define TLS_INIT_TP_EXPENSIVE 1
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
({ struct _pthread_descr_struct *__descr; \
THREAD_GETMEM (__descr, p_header.data.dtvp); })
-# endif /* FLOATING_STACKS && HAVE_TLS_SUPPORT */
+# endif /* HAVE_TLS_SUPPORT && (FLOATING_STACKS || !IS_IN_libpthread) */
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/i386/useldt.h b/libpthread/linuxthreads/sysdeps/i386/useldt.h
index 02326729a..067e5e242 100644
--- a/libpthread/linuxthreads/sysdeps/i386/useldt.h
+++ b/libpthread/linuxthreads/sysdeps/i386/useldt.h
@@ -21,6 +21,7 @@
#ifndef __ASSEMBLER__
#include <stddef.h> /* For offsetof. */
#include <stdlib.h> /* For abort(). */
+#include <sysdep.h>
/* We don't want to include the kernel header. So duplicate the
@@ -75,7 +76,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
#ifdef __PIC__
# define USETLS_EBX_ARG "r"
-# define USETLS_LOAD_EBX "xchgl %3, %%ebx\n\t"
+# define USETLS_LOAD_EBX "xchgl %1, %%ebx\n\t"
#else
# define USETLS_EBX_ARG "b"
# define USETLS_LOAD_EBX
@@ -85,7 +86,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
because we inherited the value set up in the main thread by TLS setup.
We need to extract that value and set up the same segment in this
thread. */
-#if USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
# define DO_SET_THREAD_AREA_REUSE(nr) 1
#else
/* Without TLS, we do the initialization of the main thread, where NR == 0. */
@@ -107,8 +108,10 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
"movl %2, %%eax\n\t" \
"int $0x80\n\t" \
USETLS_LOAD_EBX \
- : "&a" (__result) \
- : USETLS_EBX_ARG (&ldt_entry), "i" (__NR_set_thread_area)); \
+ : "=&a" (__result) \
+ : USETLS_EBX_ARG (&ldt_entry), "i" (__NR_set_thread_area), \
+ "m" (ldt_entry) \
+ : "memory"); \
if (__result == 0) \
__asm__ ("movw %w0, %%gs" :: "q" (__gs)); \
else \
@@ -125,8 +128,10 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
"movl %2, %%eax\n\t" \
"int $0x80\n\t" \
USETLS_LOAD_EBX \
- : "&a" (__result) \
- : USETLS_EBX_ARG (&ldt_entry), "i" (__NR_set_thread_area)); \
+ : "=&a" (__result) \
+ : USETLS_EBX_ARG (&ldt_entry), "i" (__NR_set_thread_area), \
+ "m" (ldt_entry) \
+ : "memory"); \
if (__result == 0) \
{ \
__gs = (ldt_entry.entry_number << 3) + 3; \
@@ -299,8 +304,10 @@ extern int __have_no_set_thread_area;
})
#endif
+#if __ASSUME_LDT_WORKS > 0
/* We want the OS to assign stack addresses. */
#define FLOATING_STACKS 1
/* Maximum size of the stack if the rlimit is unlimited. */
#define ARCH_STACK_MAX_SIZE 8*1024*1024
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c b/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c
new file mode 100644
index 000000000..d5e52ff6b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c
@@ -0,0 +1,78 @@
+/* POSIX spinlock implementation. ia64 version.
+ Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jes Sorensen <jes@linuxcare.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+#include <ia64intrin.h>
+
+/* This implementation is inspired by the implementation used in the
+ Linux kernel. */
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ int *p = (int *) lock;
+
+ while (__builtin_expect (__sync_val_compare_and_swap (p, 0, 1), 0))
+ {
+ /* Spin without using the atomic instruction. */
+ do
+ __asm__ __volatile__ ("" : : : "memory");
+ while (*p);
+ }
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ return __sync_val_compare_and_swap ((int *) lock, 0, 1) == 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
index f4c6be989..55bdd5df5 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
@@ -23,10 +23,6 @@
#include <features.h>
#include <ia64intrin.h>
-#include <sys/types.h>
-extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
- size_t __child_stack_size, int __flags, void *__arg, ...);
-
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
@@ -34,7 +30,7 @@ extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
/* Make sure gcc doesn't try to be clever and move things around on
us. We need to use _exactly_ the address the user gave us, not some
alias that contains the same information. */
-#define __atomic_fool_gcc(x) (*(volatile struct { int a[100]; } *)x)
+#define __atomic_fool_gcc(x) (*(__volatile__ struct { int a[100]; } *)x)
#ifndef ELF_MACHINE_NAME
diff --git a/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym
new file mode 100644
index 000000000..1000ad0a9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym
@@ -0,0 +1,9 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+#ifdef __UCLIBC_HAS_TLS__
+MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - sizeof (struct _pthread_descr_struct)
+#else
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/ia64/tls.h b/libpthread/linuxthreads/sysdeps/ia64/tls.h
index a78f0ec7a..c86073f26 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/tls.h
+++ b/libpthread/linuxthreads/sysdeps/ia64/tls.h
@@ -111,6 +111,9 @@ typedef struct
# define TLS_MULTIPLE_THREADS_IN_TCB 1
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
# endif
#else
@@ -125,6 +128,9 @@ typedef struct
int multiple_threads;
} tcbhead_t;
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
# define NONTLS_INIT_TP \
do { \
static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
diff --git a/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
new file mode 100644
index 000000000..af77c2a9d
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
@@ -0,0 +1,91 @@
+/* POSIX spinlock implementation. M68k version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+ "tas %1; sne %0"
+#else
+ "bset #7,%1; sne %0"
+#endif
+ : "=dm" (val), "=m" (*lock)
+ : "m" (*lock)
+ : "cc");
+ while (val);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+ "tas %1; sne %0"
+#else
+ "bset #7,%1; sne %0"
+#endif
+ : "=dm" (val), "=m" (*lock)
+ : "m" (*lock)
+ : "cc");
+
+ return val ? EBUSY : 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
index 3be216524..1eb9fd57b 100644
--- a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
@@ -28,6 +28,7 @@
#endif
/* Spinlock implementation; required. */
+PT_EI long int testandset (int *spinlock);
PT_EI long int
testandset (int *spinlock)
{
@@ -35,11 +36,11 @@ testandset (int *spinlock)
__asm__ __volatile__(
#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
- "tas %1; sne %0"
+ "tas %1; sne %0"
#else
- "bset #7,%1; sne %0"
+ "bset #7,%1; sne %0"
#endif
- : "=&dm"(ret), "=m"(*spinlock)
+ : "=dm"(ret), "=m"(*spinlock)
: "m"(*spinlock)
: "cc");
@@ -70,5 +71,4 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
return ret;
}
#endif
-
#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h b/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h
deleted file mode 100644
index e8c03f9e5..000000000
--- a/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * sysdeps/microblaze/pt-machine.h -- microblaze-specific pthread definitions
- *
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2002 NEC Electronics Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI extern inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long *ptr, long old, long new);
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME __stack_pointer
-register char *__stack_pointer __asm__ ("r1");
-
-#define HAS_COMPARE_AND_SWAP
-#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
-#define IMPLEMENT_TAS_WITH_CAS
-
-/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
- otherwise do nothing and return false. */
-PT_EI int __compare_and_swap (long *ptr, long old, long new)
-{
- unsigned long psw;
-
- /* disable interrupts */
- /* This is ugly ugly ugly! */
- __asm__ __volatile__ ("mfs %0, rmsr;"
- "andi r3, %0, ~2;"
- "mts rmsr, r3;"
- : "=&r" (psw)
- :
- : "r3");
-
- if (likely (*ptr == old))
- {
- *ptr = new;
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
- return 1;
- }
- else
- {
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
- return 0;
- }
-}
-
-/* like above's __compare_and_swap() but it first syncs the memory
- (This is also the difference between both functions in e.g.
- ../powerpc/pt-machine.h)
- Doing this additional sync fixes a hang of __pthread_alt_unlock()
- (Falk Brettschneider <fbrettschneider@baumeroptronic.de>) */
-PT_EI int
-__compare_and_swap_with_release_semantics (long *p,
- long oldval, long newval)
-{
- __asm__ __volatile__ ("" : : : "memory"); /*MEMORY_BARRIER ();*/
- return __compare_and_swap (p, oldval, newval);
-}
-
-
-#ifndef IMPLEMENT_TAS_WITH_CAS
-/* Spinlock implementation; required. */
-PT_EI long int testandset (int *spinlock)
-{
- unsigned psw;
-
- /* disable interrupts */
- __asm__ __volatile__ ("mfs %0, rmsr;"
- "andi r3, %0, ~2;"
- "mts rmsr, r3;"
- : "=&r" (psw)
- :
- : "r3");
-
- if (*spinlock)
- {
- /* Enable ints */
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
- return 1;
- } else {
- *spinlock=1;
- /* Enable ints */
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
- return 0;
- }
-}
-
-#endif
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h b/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h
deleted file mode 100644
index de450ff8a..000000000
--- a/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sysdeps/v850/sigcontextinfo.h -- v850-specific pthread signal definitions
- *
- * Copyright (C) 2002 NEC Electronics Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <signal.h>
-
-#define SIGCONTEXT struct sigcontext *
-#define SIGCONTEXT_EXTRA_ARGS
diff --git a/libpthread/linuxthreads/sysdeps/mips/pspinlock.c b/libpthread/linuxthreads/sysdeps/mips/pspinlock.c
new file mode 100644
index 000000000..7b9205ef0
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/mips/pspinlock.c
@@ -0,0 +1,95 @@
+/* POSIX spinlock implementation. MIPS version.
+ Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <sgidefs.h>
+#include <sys/tas.h>
+#include "internals.h"
+
+/* This implementation is similar to the one used in the Linux kernel. */
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int tmp1, tmp2;
+
+ __asm__ __volatile__
+ ("\t\t\t# spin_lock\n"
+ "1:\n\t"
+ ".set push\n\t"
+#if _MIPS_SIM == _ABIO32
+ ".set mips2\n\t"
+#endif
+ "ll %1,%3\n\t"
+ "li %2,1\n\t"
+ "bnez %1,1b\n\t"
+ "sc %2,%0\n\t"
+ ".set pop\n\t"
+ "beqz %2,1b"
+ : "=m" (*lock), "=&r" (tmp1), "=&r" (tmp2)
+ : "m" (*lock)
+ : "memory");
+
+ return 0;
+}
+
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ /* To be done. */
+ return 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("\t\t\t# spin_unlock\n\t"
+ "sw $0,%0"
+ : "=m" (*lock)
+ :
+ : "memory");
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
index caaf9a7c0..74e8807eb 100644
--- a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
@@ -24,40 +24,13 @@
#define _PT_MACHINE_H 1
#include <features.h>
+#include <sgidefs.h>
+#include <sys/tas.h>
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000. */
-static __inline__ int
-__NTH (_test_and_set (int *p, int v))
-{
- int r, t;
-
- __asm__ __volatile__
- ("/* Inline test and set */\n"
- "1:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %0,%3\n\t"
- "move %1,%4\n\t"
- "beq %0,%4,2f\n\t"
- "sc %1,%2\n\t"
- ".set pop\n\t"
- "beqz %1,1b\n"
- "2:\n\t"
- "/* End test and set */"
- : "=&r" (r), "=&r" (t), "=m" (*p)
- : "m" (*p), "r" (v)
- : "memory");
-
- return r;
-}
-
-
/* Spinlock implementation; required. */
PT_EI long int
@@ -85,12 +58,22 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
("/* Inline compare & swap */\n"
"1:\n\t"
".set push\n\t"
+#if _MIPS_SIM == _ABIO32
".set mips2\n\t"
+#endif
+#if _MIPS_SIM == _ABI64
+ "lld %1,%5\n\t"
+#else
"ll %1,%5\n\t"
+#endif
"move %0,$0\n\t"
"bne %1,%3,2f\n\t"
"move %0,%4\n\t"
+#if _MIPS_SIM == _ABI64
+ "scd %0,%2\n\t"
+#else
"sc %0,%2\n\t"
+#endif
".set pop\n\t"
"beqz %0,1b\n"
"2:\n\t"
diff --git a/libpthread/linuxthreads/sysdeps/mips/tls.h b/libpthread/linuxthreads/sysdeps/mips/tls.h
new file mode 100644
index 000000000..4e7887a74
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/mips/tls.h
@@ -0,0 +1,169 @@
+/* Definitions for thread-local data handling. linuxthreads/MIPS version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <stdbool.h>
+# include <pt-machine.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+# define READ_THREAD_POINTER() \
+ ({ void *__result; \
+ __asm__ __volatile__ (".set\tpush\n\t.set\tmips32r2\n\t" \
+ "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \
+ __result; })
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+
+/* Note: rd must be $v1 to be ABI-conformant. */
+# define READ_THREAD_POINTER(rd) \
+ .set push; \
+ .set mips32r2; \
+ rdhwr rd, $29; \
+ .set pop
+#endif /* __ASSEMBLER__ */
+
+/* LinuxThreads can only use TLS if both floating stacks (in the MIPS case,
+ that means support for "rdhwr") and support from the tools are available.
+
+ We have to define USE_TLS consistently, or ldsodefs.h will lay out types
+ differently between an NPTL build and a LinuxThreads build. It can be set
+ for libc.so and not libpthread.so, but only if we provide appropriate padding
+ in the _pthread_descr_struct.
+
+ Currently nothing defines FLOATING_STACKS. We could assume this based on
+ kernel version once the TLS patches are available in kernel.org, but
+ it hardly seems worth it. Use NPTL if you can.
+
+ To avoid bothering with the TLS support code at all, use configure
+ --without-tls. */
+
+#if defined HAVE_TLS_SUPPORT \
+ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+/* Include padding in _pthread_descr_struct so that libc can find p_errno,
+ if libpthread will only include the padding because of the !IS_IN_libpthread
+ check. */
+#ifndef FLOATING_STACKS
+# define INCLUDE_TLS_PADDING 1
+#endif
+
+# ifndef __ASSEMBLER__
+
+/* This layout is actually wholly private and not affected by the ABI.
+ Nor does it overlap the pthread data structure, so we need nothing
+ extra here at all. */
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct _pthread_descr_struct) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The thread pointer (in hardware register $29) points to the end of
+ the TCB + 0x7000, as for PowerPC. The pthread_descr structure is
+ immediately in front of the TCB. */
+#define TLS_TCB_OFFSET 0x7000
+
+/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
+/* This is not really true for powerpc64. We are following alpha
+ where the DTV pointer is first doubleword in the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(TCBP, DTVP) \
+ (((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) (THREAD_DTV() = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(TCBP) (((tcbhead_t *) (TCBP))[-1].dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \
+ (char *) (tcbp) + TLS_TCB_OFFSET); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ((pthread_descr) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
+/* Initializing the thread pointer requires a syscall which may not be
+ available, so don't do it if we don't need to. */
+# define TLS_INIT_TP_EXPENSIVE 1
+
+# endif /* __ASSEMBLER__ */
+
+#endif /* HAVE_TLS_SUPPORT */
+
+#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/nios/pt-machine.h b/libpthread/linuxthreads/sysdeps/nios/pt-machine.h
deleted file mode 100644
index 91bbf8fea..000000000
--- a/libpthread/linuxthreads/sysdeps/nios/pt-machine.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- ARM version.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Philip Blundell <philb@gnu.org>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Spinlock implementation; required. */
-/* it is weird and dangerous to disable interrupt in userspace, but for nios
- what else we can do before we have a swap like instruction? This is better
- than nothing
- */
-PT_EI long int
-testandset (int *spinlock)
-{
- unsigned int ret;
-
- __asm__ __volatile__("pfx 8\n\t"
- "wrctl %1 ; disable interrupt\n\t"
- "nop\n\t"
- "nop\n\t"
- "ld %0, [%2]\n\t"
- "st [%2], %1\n\t"
- "pfx 9\n\t"
- "wrctl %1 ; enable interrupt\n\t"
- "nop\n\t"
- "nop\n\t"
- : "=&r"(ret)
- : "r"(1), "r"(spinlock)
- : "memory");
-
- return ret;
-}
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("%sp");
-
-/* nios needs more because of reg windows */
-#define THREAD_MANAGER_STACK_SIZE (32*1024)
-#define STACK_SIZE (32*1024)
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/nios2/pt-machine.h b/libpthread/linuxthreads/sysdeps/nios2/pt-machine.h
deleted file mode 100644
index e3260811b..000000000
--- a/libpthread/linuxthreads/sysdeps/nios2/pt-machine.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- nios2 version.
- Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- unsigned int scratch;
- long int ret=-2;
-
- __asm__ __volatile__(
- "rdctl %0, status\n\t"
- "and %0, %0, %1\n\t"
- "wrctl status, %0 #disable interrupts\n\t"
- "ldw %1, 0(%4)\n\t"
- "stw %3, 0(%4)\n\t"
- "ori %0, %0, 1\n\t"
- "wrctl status, %0 #enable interrupts\n\t"
- : "=&r"(scratch), "=r"(ret)
- : "1"(ret), "r"(1), "r"(spinlock)
- : "memory");
-
- return ret;
-}
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("%sp");
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c
new file mode 100644
index 000000000..875aa3876
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c
@@ -0,0 +1,69 @@
+/* POSIX spinlock implementation. PowerPC version.
+ Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ while (! __compare_and_swap ((long int *)lock, 0, 1))
+ ;
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ return __compare_and_swap ((long int *)lock, 0, 1) ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ MEMORY_BARRIER ();
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
new file mode 100644
index 000000000..a2b8b61e6
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
@@ -0,0 +1,119 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ powerpc version.
+ Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
+ User's Manual', by IBM and Motorola. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* For multiprocessor systems, we want to ensure all memory accesses
+ are completed before we reset a lock. On other systems, we still
+ need to make sure that the compiler has flushed everything to memory. */
+#define MEMORY_BARRIER() __asm__ __volatile__ ("sync" : : : "memory")
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+
+/* Maximum size of the stack if the rlimit is unlimited. */
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("r1");
+
+/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
+struct _pthread_descr_struct;
+register struct _pthread_descr_struct *__thread_self __asm__("r2");
+
+/* Return the thread descriptor for the current thread. */
+#define THREAD_SELF __thread_self
+
+/* Initialize the thread-unique value. */
+#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+
+/* Compare-and-swap for semaphores. */
+/* note that test-and-set(x) is the same as !compare-and-swap(x, 0, 1) */
+
+#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+#define IMPLEMENT_TAS_WITH_CAS
+
+PT_EI int
+__compare_and_swap (long int *p, long int oldval, long int newval)
+{
+ int ret;
+
+ __asm__ __volatile__ (
+ "0: lwarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ /* This version of __compare_and_swap is to be used when acquiring
+ a lock, so we don't need to worry about whether other memory
+ operations have completed, but we do need to be sure that any loads
+ after this point really occur after we have acquired the lock. */
+ __asm__ __volatile__ ("isync" : : : "memory");
+ return ret == 0;
+}
+
+PT_EI int
+__compare_and_swap_with_release_semantics (long int *p,
+ long int oldval, long int newval)
+{
+ int ret;
+
+ MEMORY_BARRIER ();
+ __asm__ __volatile__ (
+ "0: lwarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ return ret == 0;
+}
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c
new file mode 100644
index 000000000..f588c62c7
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c
@@ -0,0 +1,69 @@
+/* POSIX spinlock implementation. PowerPC version.
+ Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ while (! __compare_and_swap32 ((int *)lock, 0, 1))
+ ;
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ return __compare_and_swap32 ((int *)lock, 0, 1) ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ MEMORY_BARRIER ();
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
new file mode 100644
index 000000000..b9193a871
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
@@ -0,0 +1,184 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ powerpc version.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
+ User's Manual', by IBM and Motorola. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+extern int __compare_and_swap32 (int *p, int oldval, int newval);
+
+/* For multiprocessor systems, we want to ensure all memory accesses
+ are completed before we reset a lock. On other systems, we still
+ need to make sure that the compiler has flushed everything to memory. */
+#define MEMORY_BARRIER() __asm__ __volatile__ ("lwsync" : : : "memory")
+#define READ_MEMORY_BARRIER() __asm__ __volatile__ ("lwsync" : : : "memory")
+#define WRITE_MEMORY_BARRIER() __asm__ __volatile__ ("eieio" : : : "memory")
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+
+/* Maximum size of the stack if the rlimit is unlimited. */
+#define ARCH_STACK_MAX_SIZE 16*1024*1024
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("r1");
+
+/* Register r13 (tp) is reserved by the ABI as "thread pointer". */
+struct _pthread_descr_struct;
+register struct _pthread_descr_struct *__thread_self __asm__("r13");
+
+/* Return the thread descriptor for the current thread. */
+#define THREAD_SELF __thread_self
+
+/* Initialize the thread-unique value. */
+#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) (descr), THREAD_SELF->member = (value))
+
+/* Compare-and-swap for semaphores. */
+/* note that test-and-set(x) is the same as !compare-and-swap(x, 0, 1) */
+
+#define HAS_COMPARE_AND_SWAP
+#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+
+PT_EI int
+__compare_and_swap (long int *p, long int oldval, long int newval)
+{
+ long int ret;
+
+ __asm__ __volatile__ (
+ "0: ldarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stdcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ /* This version of __compare_and_swap is to be used when acquiring
+ a lock, so we don't need to worry about whether other memory
+ operations have completed, but we do need to be sure that any loads
+ after this point really occur after we have acquired the lock. */
+ __asm__ __volatile__ ("isync" : : : "memory");
+ return (int)(ret == 0);
+}
+
+PT_EI int
+__compare_and_swap_with_release_semantics (long int *p,
+ long int oldval, long int newval)
+{
+ long int ret;
+
+ MEMORY_BARRIER ();
+ __asm__ __volatile__ (
+ "0: ldarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stdcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ return (int)(ret == 0);
+}
+
+PT_EI int
+__compare_and_swap32 (int *p, int oldval, int newval)
+{
+ int ret;
+
+ __asm__ __volatile__ (
+ "0: lwarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ /* This version of __compare_and_swap is to be used when acquiring
+ a lock, so we don't need to worry about whether other memory
+ operations have completed, but we do need to be sure that any loads
+ after this point really occur after we have acquired the lock. */
+ __asm__ __volatile__ ("isync" : : : "memory");
+ return (int)(ret == 0);
+}
+
+PT_EI int
+__compare_and_swap32_with_release_semantics (long int *p,
+ long int oldval, long int newval)
+{
+ long int ret;
+
+ MEMORY_BARRIER ();
+ __asm__ __volatile__ (
+ "0: lwarx %0,0,%1 ;"
+ " xor. %0,%3,%0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r"(newval), "r"(oldval)
+ : "cr0", "memory");
+ return (int)(ret == 0);
+}
+
+PT_EI long int
+testandset (int *p)
+{
+ long int ret, val = 1;
+
+ MEMORY_BARRIER ();
+ __asm__ __volatile__ (
+ "0: lwarx %0,0,%1 ;"
+ " cmpwi 0,%0,0;"
+ " bne 1f;"
+ " stwcx. %2,0,%1;"
+ " bne- 0b;"
+ "1: "
+ : "=&r"(ret)
+ : "r"(p), "r" (val)
+ : "cr0", "memory");
+ MEMORY_BARRIER ();
+ return ret != 0;
+}
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/pspinlock.c b/libpthread/linuxthreads/sysdeps/powerpc/pspinlock.c
new file mode 100644
index 000000000..bb88a0690
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/pspinlock.c
@@ -0,0 +1,8 @@
+#include <features.h>
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 32
+# include "powerpc32/pspinlock.c"
+#else
+# include "powerpc64/pspinlock.c"
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/pt-machine.h
index aa2d206b0..55e922efd 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/pt-machine.h
@@ -1,101 +1,8 @@
-/* Machine-dependent pthreads configuration and inline functions.
- powerpc version.
- Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>. */
-
-/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
- User's Manual', by IBM and Motorola. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
#include <features.h>
+#include <bits/wordsize.h>
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
+#if __WORDSIZE == 32
+# include "powerpc32/pt-machine.h"
+#else
+# include "powerpc64/pt-machine.h"
#endif
-
-/* For multiprocessor systems, we want to ensure all memory accesses
- are completed before we reset a lock. On other systems, we still
- need to make sure that the compiler has flushed everything to memory. */
-#define MEMORY_BARRIER() __asm__ __volatile__ ("sync" : : : "memory")
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("r1");
-
-/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
-struct _pthread_descr_struct;
-register struct _pthread_descr_struct *__thread_self __asm__("r2");
-
-/* Return the thread descriptor for the current thread. */
-#define THREAD_SELF __thread_self
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
-
-/* Compare-and-swap for semaphores. */
-/* note that test-and-set(x) is the same as !compare-and-swap(x, 0, 1) */
-
-#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
-#define IMPLEMENT_TAS_WITH_CAS
-
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- int ret;
-
- __asm__ __volatile__ (
- "0: lwarx %0,0,%1 ;"
- " xor. %0,%3,%0;"
- " bne 1f;"
- " stwcx. %2,0,%1;"
- " bne- 0b;"
- "1: "
- : "=&r"(ret)
- : "r"(p), "r"(newval), "r"(oldval)
- : "cr0", "memory");
- /* This version of __compare_and_swap is to be used when acquiring
- a lock, so we don't need to worry about whether other memory
- operations have completed, but we do need to be sure that any loads
- after this point really occur after we have acquired the lock. */
- __asm__ __volatile__ ("isync" : : : "memory");
- return ret == 0;
-}
-
-PT_EI int
-__compare_and_swap_with_release_semantics (long int *p,
- long int oldval, long int newval)
-{
- int ret;
-
- MEMORY_BARRIER ();
- __asm__ __volatile__ (
- "0: lwarx %0,0,%1 ;"
- " xor. %0,%3,%0;"
- " bne 1f;"
- " stwcx. %2,0,%1;"
- " bne- 0b;"
- "1: "
- : "=&r"(ret)
- : "r"(p), "r"(newval), "r"(oldval)
- : "cr0", "memory");
- return ret == 0;
-}
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
new file mode 100644
index 000000000..7940cf620
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
@@ -0,0 +1,19 @@
+#include <sysdep.h>
+#include <tls.h>
+
+-- This line separates the #include lines from conditionals.
+
+# ifdef __UCLIBC_HAS_TLS__
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+# undef __thread_register
+# define __thread_register ((void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct _pthread_descr_struct, p_##mem))
+
+# else
+
+# define thread_offsetof(mem) offsetof (tcbhead_t, mem)
+
+# endif
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (multiple_threads)
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/tls.h b/libpthread/linuxthreads/sysdeps/powerpc/tls.h
new file mode 100644
index 000000000..8555b239d
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/powerpc/tls.h
@@ -0,0 +1,164 @@
+/* Definitions for thread-local data handling. linuxthreads/PPC version.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <pt-machine.h>
+# include <stdbool.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+#ifdef HAVE_TLS_SUPPORT
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+# ifndef __ASSEMBLER__
+
+/* This layout is actually wholly private and not affected by the ABI.
+ Nor does it overlap the pthread data structure, so we need nothing
+ extra here at all. */
+typedef struct
+{
+ dtv_t *dtv;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct _pthread_descr_struct) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The following assumes that TP (R2 or R13) is points to the end of the
+ TCB + 0x7000 (per the ABI). This implies that TCB address is
+ TP - 0x7000. As we define TLS_DTV_AT_TP we can
+ assume that the pthread_descr is allocated immediately ahead of the
+ TCB. This implies that the pthread_descr address is
+ TP - (TLS_PRE_TCB_SIZE + 0x7000). */
+#define TLS_TCB_OFFSET 0x7000
+
+/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
+/* This is not really true for powerpc64. We are following alpha
+ where the DTV pointer is first doubleword in the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(TCBP, DTVP) \
+ (((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) (THREAD_DTV() = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(TCBP) (((tcbhead_t *) (TCBP))[-1].dtv)
+
+/* We still need this define so that tcb-offsets.sym can override it and
+ use THREAD_SELF to generate MULTIPLE_THREADS_OFFSET. */
+# define __thread_register ((void *) __thread_self)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched.
+
+ The global register variable is declared in pt-machine.h with the
+ wrong type, so we need some extra casts to get the desired result.
+ This avoids a lvalue cast that gcc-3.4 does not like. */
+# define TLS_INIT_TP(TCBP, SECONDCALL) \
+ (__thread_self = (struct _pthread_descr_struct *) \
+ ((void *) (TCBP) + TLS_TCB_OFFSET), NULL)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) ((void *) __thread_self - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ((pthread_descr) (__thread_register \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(DESCR, NR) \
+ (__thread_self = (struct _pthread_descr_struct *)((void *) (DESCR) \
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE))
+
+/* Make sure we have the p_multiple_threads member in the thread structure.
+ See below. */
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
+# endif /* __ASSEMBLER__ */
+
+#elif !defined __ASSEMBLER__
+
+/* This overlaps the start of the pthread_descr. System calls
+ and such use this to find the multiple_threads flag and need
+ to use the same offset relative to the thread register in both
+ single-threaded and multi-threaded code. */
+typedef struct
+{
+ void *tcb; /* Never used. */
+ dtv_t *dtv; /* Never used. */
+ void *self; /* Used only if multithreaded, and rarely. */
+ int multiple_threads; /* Only this member is really used. */
+} tcbhead_t;
+
+#define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
+ __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
+ } while (0)
+
+#endif /* HAVE_TLS_SUPPORT */
+
+#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h b/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h
new file mode 100644
index 000000000..b9e4acf30
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h
@@ -0,0 +1,27 @@
+/* Generic definitions for spinlock initializers.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* Initial value of a spinlock. Most platforms should use zero,
+ unless they only implement a "test and clear" operation instead of
+ the usual "test and set". */
+#define __LT_SPINLOCK_INIT 0
+
+/* Macros for lock initializers, using the above definition. */
+#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
+#define __ALT_LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
+#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_INIT }
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
index 8833e343d..855efff12 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
@@ -1,5 +1,5 @@
/* libc-internal interface for mutex locks. LinuxThreads version.
- Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
+ Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -23,13 +23,13 @@
#include <pthread.h>
#if defined _LIBC && !defined NOT_IN_libc
-#include <linuxthreads.old/internals.h>
+#include <linuxthreads/internals.h>
#endif
/* Mutex type. */
#if defined(_LIBC) || defined(_IO_MTSAFE_IO)
typedef pthread_mutex_t __libc_lock_t;
-typedef pthread_mutex_t __libc_lock_recursive_t;
+typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
# ifdef __USE_UNIX98
typedef pthread_rwlock_t __libc_rwlock_t;
# else
@@ -131,39 +131,15 @@ typedef pthread_key_t __libc_key_t;
#define __libc_rwlock_init(NAME) \
(__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0));
-/* Same as last but this time we initialize an adaptive mutex. */
-#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
-#define __libc_lock_init_adaptive(NAME) \
- ({ \
- (NAME).__m_count = 0; \
- (NAME).__m_owner = NULL; \
- (NAME).__m_kind = PTHREAD_MUTEX_ADAPTIVE_NP; \
- (NAME).__m_lock.__status = 0; \
- (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
- 0; })
-#else
-#define __libc_lock_init_adaptive(NAME) \
- do { \
- if (__pthread_mutex_init != NULL) \
- { \
- pthread_mutexattr_t __attr; \
- __pthread_mutexattr_init (&__attr); \
- __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
- __pthread_mutex_init (&(NAME), &__attr); \
- __pthread_mutexattr_destroy (&__attr); \
- } \
- } while (0);
-#endif
-
/* Same as last but this time we initialize a recursive mutex. */
#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
#define __libc_lock_init_recursive(NAME) \
({ \
- (NAME).__m_count = 0; \
- (NAME).__m_owner = NULL; \
- (NAME).__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
- (NAME).__m_lock.__status = 0; \
- (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ (NAME).mutex.__m_count = 0; \
+ (NAME).mutex.__m_owner = NULL; \
+ (NAME).mutex.__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
+ (NAME).mutex.__m_lock.__status = 0; \
+ (NAME).mutex.__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
0; })
#else
#define __libc_lock_init_recursive(NAME) \
@@ -173,7 +149,7 @@ typedef pthread_key_t __libc_key_t;
pthread_mutexattr_t __attr; \
__pthread_mutexattr_init (&__attr); \
__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
- __pthread_mutex_init (&(NAME), &__attr); \
+ __pthread_mutex_init (&(NAME).mutex, &__attr); \
__pthread_mutexattr_destroy (&__attr); \
} \
} while (0);
@@ -226,6 +202,23 @@ typedef pthread_key_t __libc_key_t;
/* Unlock the recursive named lock variable. */
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex)
+#if defined _LIBC && defined SHARED
+# define __rtld_lock_default_lock_recursive(lock) \
+ ++((pthread_mutex_t *)(lock))->__m_count;
+
+# define __rtld_lock_default_unlock_recursive(lock) \
+ --((pthread_mutex_t *)(lock))->__m_count;
+
+# define __rtld_lock_lock_recursive(NAME) \
+ GL(dl_rtld_lock_recursive) (&(NAME).mutex)
+
+# define __rtld_lock_unlock_recursive(NAME) \
+ GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
+#else
+#define __rtld_lock_lock_recursive(NAME) __libc_lock_lock_recursive (NAME)
+#define __rtld_lock_unlock_recursive(NAME) __libc_lock_unlock_recursive (NAME)
+#endif
+
/* Define once control variable. */
#if PTHREAD_ONCE_INIT == 0
/* Special case for static variables where we can avoid the initialization
@@ -244,7 +237,7 @@ typedef pthread_key_t __libc_key_t;
__pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \
else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \
INIT_FUNCTION (); \
- (ONCE_CONTROL) = !PTHREAD_ONCE_INIT; \
+ (ONCE_CONTROL) = 2; \
} \
} while (0)
@@ -270,7 +263,6 @@ typedef pthread_key_t __libc_key_t;
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
}
-#if 0
#define __libc_cleanup_push(fct, arg) \
{ struct _pthread_cleanup_buffer _buffer; \
__libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0)
@@ -278,7 +270,6 @@ typedef pthread_key_t __libc_key_t;
#define __libc_cleanup_pop(execute) \
__libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0); \
}
-#endif
/* Create thread-specific key. */
#define __libc_key_create(KEY, DESTRUCTOR) \
@@ -376,6 +367,7 @@ weak_extern (BP_SYM (__pthread_key_create))
weak_extern (BP_SYM (__pthread_setspecific))
weak_extern (BP_SYM (__pthread_getspecific))
weak_extern (BP_SYM (__pthread_once))
+weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork)
weak_extern (BP_SYM (_pthread_cleanup_push))
weak_extern (BP_SYM (_pthread_cleanup_pop))
@@ -400,6 +392,7 @@ weak_extern (BP_SYM (_pthread_cleanup_pop_restore))
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_once
+# pragma weak __pthread_initialize
# pragma weak __pthread_atfork
# pragma weak _pthread_cleanup_push_defer
# pragma weak _pthread_cleanup_pop_restore
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
index 97af75ebf..7cc5f9cf6 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
@@ -19,19 +19,7 @@
#ifndef _BITS_LIBC_TSD_H
#define _BITS_LIBC_TSD_H 1
-/* Fast thread-specific data internal to libc. */
-enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
- _LIBC_TSD_KEY_DL_ERROR,
- _LIBC_TSD_KEY_RPC_VARS,
- _LIBC_TSD_KEY_LOCALE,
- _LIBC_TSD_KEY_CTYPE_B,
- _LIBC_TSD_KEY_CTYPE_TOLOWER,
- _LIBC_TSD_KEY_CTYPE_TOUPPER,
- _LIBC_TSD_KEY_N };
-
-#include <features.h>
-#include <linuxthreads.old/internals.h>
-
+#include <linuxthreads/descr.h>
#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
index 3eb592919..8d01c8908 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
@@ -56,10 +56,20 @@ typedef struct __pthread_attr_s
/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
+
+#ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef long long __pthread_cond_align_t;
+#else
+typedef long __pthread_cond_align_t;
+#endif
+
typedef struct
{
struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
_pthread_descr __c_waiting; /* Threads waiting on this condition */
+ char __padding[48 - sizeof (struct _pthread_fastlock)
+ - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
+ __pthread_cond_align_t __align;
} pthread_cond_t;
@@ -121,7 +131,7 @@ typedef struct
#ifdef __USE_XOPEN2K
/* POSIX spinlock data type. */
-typedef volatile int pthread_spinlock_t;
+typedef __volatile__ int pthread_spinlock_t;
/* POSIX barrier. */
typedef struct {
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h
new file mode 100644
index 000000000..0e900d2d5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h
@@ -0,0 +1,65 @@
+/* bits/typesizes.h -- underlying types for *_t. Generic version.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_TYPESIZES_H
+#define _BITS_TYPESIZES_H 1
+
+/* See <bits/types.h> for the meaning of these macros. This file exists so
+ that <bits/types.h> need not vary across different GNU platforms. */
+
+#define __DEV_T_TYPE __UQUAD_TYPE
+#define __UID_T_TYPE __U32_TYPE
+#define __GID_T_TYPE __U32_TYPE
+#define __INO_T_TYPE __ULONGWORD_TYPE
+#define __INO64_T_TYPE __UQUAD_TYPE
+#define __MODE_T_TYPE __U32_TYPE
+#define __NLINK_T_TYPE __UWORD_TYPE
+#define __OFF_T_TYPE __SLONGWORD_TYPE
+#define __OFF64_T_TYPE __SQUAD_TYPE
+#define __PID_T_TYPE __S32_TYPE
+#define __RLIM_T_TYPE __ULONGWORD_TYPE
+#define __RLIM64_T_TYPE __UQUAD_TYPE
+#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
+#define __BLKCNT64_T_TYPE __SQUAD_TYPE
+#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
+#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
+#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
+#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
+#define __ID_T_TYPE __U32_TYPE
+#define __CLOCK_T_TYPE __SLONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
+#define __USECONDS_T_TYPE __U32_TYPE
+#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
+#define __DADDR_T_TYPE __S32_TYPE
+#define __SWBLK_T_TYPE __SLONGWORD_TYPE
+#define __KEY_T_TYPE __S32_TYPE
+#define __CLOCKID_T_TYPE __S32_TYPE
+#define __TIMER_T_TYPE __S32_TYPE
+#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
+#define __FSID_T_TYPE struct { int __val[2]; }
+#define __SSIZE_T_TYPE __SWORD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+#endif /* bits/typesizes.h */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c
new file mode 100644
index 000000000..8bdfff485
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c
@@ -0,0 +1,44 @@
+/* MT support function to get address of `errno' variable, linuxthreads
+ version.
+ Copyright (C) 1996, 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <linuxthreads/internals.h>
+#include <sysdep-cancel.h>
+
+#if !defined __UCLIBC_HAS_TLS__ && !RTLD_PRIVATE_ERRNO
+#undef errno
+extern int errno;
+#endif
+
+int *
+#ifndef __UCLIBC_HAS_TLS__
+weak_const_function
+#endif
+__errno_location (void)
+{
+#if !defined __UCLIBC_HAS_TLS__ && !defined NOT_IN_libc
+ if (! SINGLE_THREAD_P)
+ {
+ pthread_descr self = thread_self();
+ return LIBC_THREAD_GETMEM (self, p_errnop);
+ }
+#endif
+ return &errno;
+}
+libc_hidden_def (__errno_location)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/flockfile.c b/libpthread/linuxthreads/sysdeps/pthread/flockfile.c
new file mode 100644
index 000000000..538e368a0
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/flockfile.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <libio.h>
+#include <bits/stdio-lock.h>
+
+
+void
+__flockfile (stream)
+ FILE *stream;
+{
+ _IO_lock_lock (*stream->_lock);
+}
+strong_alias (__flockfile, _IO_flockfile)
+weak_alias (__flockfile, flockfile)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c b/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c
new file mode 100644
index 000000000..d814258d8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <bits/stdio-lock.h>
+
+
+int
+__ftrylockfile (stream)
+ FILE *stream;
+{
+ return _IO_lock_trylock (*stream->_lock);
+}
+strong_alias (__ftrylockfile, _IO_ftrylockfile)
+weak_alias (__ftrylockfile, ftrylockfile)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c b/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c
new file mode 100644
index 000000000..f45479936
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <libio.h>
+#include <bits/stdio-lock.h>
+
+
+void
+__funlockfile (stream)
+ FILE *stream;
+{
+ _IO_lock_unlock (*stream->_lock);
+}
+strong_alias (__funlockfile, _IO_funlockfile)
+weak_alias (__funlockfile, funlockfile)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c b/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c
new file mode 100644
index 000000000..6acb179c5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c
@@ -0,0 +1,116 @@
+/* pthread_getcpuclockid -- Get POSIX clockid_t for a pthread_t. Linux version
+ Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <sys/time.h>
+#include <time.h>
+#include <internals.h>
+#include <spinlock.h>
+#include <bits/kernel-features.h>
+#include <kernel-posix-cpu-timers.h>
+
+
+#if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+int __libc_missing_posix_cpu_timers attribute_hidden;
+#endif
+#if !(__ASSUME_POSIX_TIMERS > 0)
+int __libc_missing_posix_timers attribute_hidden;
+#endif
+
+int
+pthread_getcpuclockid (pthread_t thread_id, clockid_t *clock_id)
+{
+#ifdef __NR_clock_getres
+ pthread_handle handle = thread_handle(thread_id);
+ int pid;
+
+ __pthread_lock (&handle->h_lock, NULL);
+ if (nonexisting_handle (handle, thread_id))
+ {
+ __pthread_unlock (&handle->h_lock);
+ return ESRCH;
+ }
+ pid = handle->h_descr->p_pid;
+ __pthread_unlock (&handle->h_lock);
+
+ /* The clockid_t value is a simple computation from the PID.
+ But we do a clock_getres call to validate it if we aren't
+ yet sure we have the kernel support. */
+
+ const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED);
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers)
+ __libc_missing_posix_cpu_timers = 1;
+# endif
+ if (!__libc_missing_posix_cpu_timers)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL);
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+# endif
+ {
+ *clock_id = pidclock;
+ return 0;
+ }
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
+ {
+ /* The kernel doesn't support these calls at all. */
+ __libc_missing_posix_timers = 1;
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ else
+# endif
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
+ {
+ /* The kernel doesn't support these clocks at all. */
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ else
+ return INTERNAL_SYSCALL_ERRNO (r, err);
+ }
+# endif
+#endif
+
+#ifdef CLOCK_THREAD_CPUTIME_ID
+ /* We need to store the thread ID in the CLOCKID variable together
+ with a number identifying the clock. We reserve the low 3 bits
+ for the clock ID and the rest for the thread ID. This is
+ problematic if the thread ID is too large. But 29 bits should be
+ fine.
+
+ If some day more clock IDs are needed the ID part can be
+ enlarged. The IDs are entirely internal. */
+ if (2 * PTHREAD_THREADS_MAX
+ >= 1 << (8 * sizeof (*clock_id) - CLOCK_IDFIELD_SIZE))
+ return ERANGE;
+
+ /* Store the number. */
+ *clock_id = CLOCK_THREAD_CPUTIME_ID | (thread_id << CLOCK_IDFIELD_SIZE);
+
+ return 0;
+#else
+ /* We don't have a timer for that. */
+ return ENOENT;
+#endif
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
new file mode 100644
index 000000000..634c75245
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1996, 97, 98, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <netdb.h>
+#ifdef __UCLIBC_HAS_TLS__
+#include <tls.h>
+#endif
+#include <linuxthreads/internals.h>
+#include <sysdep-cancel.h>
+
+#ifndef __UCLIBC_HAS_TLS__
+# undef h_errno
+extern int h_errno;
+#endif
+
+/* When threaded, h_errno may be a per-thread variable. */
+int *
+weak_const_function
+__h_errno_location (void)
+{
+#ifndef __UCLIBC_HAS_TLS__
+ if (! SINGLE_THREAD_P)
+ {
+ pthread_descr self = thread_self();
+ return LIBC_THREAD_GETMEM (self, p_h_errnop);
+ }
+#endif
+ return &h_errno;
+}
+libc_hidden_def (__h_errno_location)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/list.h b/libpthread/linuxthreads/sysdeps/pthread/list.h
new file mode 100644
index 000000000..232988fd6
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/list.h
@@ -0,0 +1,113 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LIST_H
+#define _LIST_H 1
+
+/* The definitions of this file are adopted from those which can be
+ found in the Linux kernel headers to enable people familiar with
+ the latter find their way in these sources as well. */
+
+
+/* Basic type for the double-link list. */
+typedef struct list_head
+{
+ struct list_head *next;
+ struct list_head *prev;
+} list_t;
+
+
+/* Define a variable with the head and tail of the list. */
+#define LIST_HEAD(name) \
+ list_t name = { &(name), &(name) }
+
+/* Initialize a new list head. */
+#define INIT_LIST_HEAD(ptr) \
+ (ptr)->next = (ptr)->prev = (ptr)
+
+
+/* Add new element at the head of the list. */
+static __inline__ void
+list_add (list_t *newp, list_t *head)
+{
+ head->next->prev = newp;
+ newp->next = head->next;
+ newp->prev = head;
+ head->next = newp;
+}
+
+
+/* Add new element at the tail of the list. */
+static __inline__ void
+list_add_tail (list_t *newp, list_t *head)
+{
+ head->prev->next = newp;
+ newp->next = head;
+ newp->prev = head->prev;
+ head->prev = newp;
+}
+
+
+/* Remove element from list. */
+static __inline__ void
+list_del (list_t *elem)
+{
+ elem->next->prev = elem->prev;
+ elem->prev->next = elem->next;
+}
+
+
+/* Join two lists. */
+static __inline__ void
+list_splice (list_t *add, list_t *head)
+{
+ /* Do nothing if the list which gets added is empty. */
+ if (add != add->next)
+ {
+ add->next->prev = head;
+ add->prev->next = head->next;
+ head->next->prev = add->prev;
+ head->next = add->next;
+ }
+}
+
+
+/* Get typed element from list at a given position. */
+#define list_entry(ptr, type, member) \
+ ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
+
+
+
+/* Iterate forward over the elements of the list. */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+
+/* Iterate forward over the elements of the list. */
+#define list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); pos = pos->prev)
+
+
+/* Iterate backwards over the elements list. The list elements can be
+ removed from the list while doing this. */
+#define list_for_each_prev_safe(pos, p, head) \
+ for (pos = (head)->prev, p = pos->prev; \
+ pos != (head); \
+ pos = p, p = pos->prev)
+
+#endif /* list.h */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h b/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h
new file mode 100644
index 000000000..f70729fd7
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h
@@ -0,0 +1,66 @@
+/* Basic platform-independent macro definitions for mutexes,
+ thread-specific data and parameters for malloc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MALLOC_MACHINE_H
+#define _MALLOC_MACHINE_H
+
+#undef thread_atfork_static
+
+#include <atomic.h>
+#include <bits/libc-lock.h>
+
+__libc_lock_define (typedef, mutex_t)
+
+#define mutex_init(m) \
+ __libc_maybe_call2 (pthread_mutex_init, (m, NULL), (*(int *)(m) = 0))
+#define mutex_lock(m) \
+ __libc_maybe_call2 (pthread_mutex_lock, (m), ((*(int *)(m) = 1), 0))
+#define mutex_trylock(m) \
+ __libc_maybe_call2 (pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0)))
+#define mutex_unlock(m) \
+ __libc_maybe_call2 (pthread_mutex_unlock, (m), (*(int *)(m) = 0))
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__));
+
+#include <fork.h>
+
+#ifdef SHARED
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, __dso_handle)
+#else
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, \
+ &__dso_handle == NULL ? NULL : __dso_handle)
+#endif
+
+/* thread specific data for glibc */
+
+#include <bits/libc-tsd.h>
+
+typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
+__libc_tsd_define (static, MALLOC) /* declaration/common definition */
+#define tsd_key_create(key, destr) ((void) (key))
+#define tsd_setspecific(key, data) __libc_tsd_set (MALLOC, (data))
+#define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (MALLOC))
+
+#include <sysdeps/generic/malloc-machine.h>
+
+#endif /* !defined(_MALLOC_MACHINE_H) */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h b/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
index bbdb0739c..b46d2ab49 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
@@ -23,10 +23,10 @@
/* Uncancelable open. */
#if defined __NR_openat && !defined __NR_open
#define open_not_cancel(name, flags, mode) \
- INLINE_SYSCALL (openat, 4, AT_FDCWD, (const char *) (name), \
+ INLINE_SYSCALL (openat, 4, (int) (AT_FDCWD), (const char *) (name), \
(flags), (mode))
#define open_not_cancel_2(name, flags) \
- INLINE_SYSCALL (openat, 3, AT_FDCWD, (const char *) (name), \
+ INLINE_SYSCALL (openat, 3, (int) (AT_FDCWD), (const char *) (name), \
(flags))
#else
#define open_not_cancel(name, flags, mode) \
diff --git a/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h b/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h
new file mode 100644
index 000000000..4ac64d9ac
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h
@@ -0,0 +1,203 @@
+/* Definitions for POSIX timer implementation on top of LinuxThreads.
+ Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <signal.h>
+
+/* Double linked list. */
+struct list_links
+{
+ struct list_links *next;
+ struct list_links *prev;
+};
+
+
+/* Forward declaration. */
+struct timer_node;
+
+
+/* Definitions for an internal thread of the POSIX timer implementation. */
+struct thread_node
+{
+ struct list_links links;
+ pthread_attr_t attr;
+ pthread_t id;
+ unsigned int exists;
+ struct list_links timer_queue;
+ pthread_cond_t cond;
+ struct timer_node *current_timer;
+ pthread_t captured;
+ clockid_t clock_id;
+};
+
+
+/* Internal representation of a timer. */
+struct timer_node
+{
+ struct list_links links;
+ struct sigevent event;
+ clockid_t clock;
+ struct itimerspec value;
+ struct timespec expirytime;
+ pthread_attr_t attr;
+ unsigned int abstime;
+ unsigned int armed;
+ enum {
+ TIMER_FREE, TIMER_INUSE, TIMER_DELETED
+ } inuse;
+ struct thread_node *thread;
+ pid_t creator_pid;
+ int refcount;
+ int overrun_count;
+};
+
+
+/* Static array with the structures for all the timers. */
+extern struct timer_node __timer_array[TIMER_MAX];
+
+/* Global lock to protect operation on the lists. */
+extern pthread_mutex_t __timer_mutex;
+
+/* Variable to protext initialization. */
+extern pthread_once_t __timer_init_once_control;
+
+/* Nonzero if initialization of timer implementation failed. */
+extern int __timer_init_failed;
+
+/* Nodes for the threads used to deliver signals. */
+/* A distinct thread is used for each clock type. */
+
+extern struct thread_node __timer_signal_thread_rclk;
+
+
+/* Return pointer to timer structure corresponding to ID. */
+static __inline__ struct timer_node *
+timer_id2ptr (timer_t timerid)
+{
+ if (timerid >= 0 && timerid < TIMER_MAX)
+ return &__timer_array[timerid];
+
+ return NULL;
+}
+
+/* Return ID of TIMER. */
+static __inline__ int
+timer_ptr2id (struct timer_node *timer)
+{
+ return timer - __timer_array;
+}
+
+/* Check whether timer is valid; global mutex must be held. */
+static __inline__ int
+timer_valid (struct timer_node *timer)
+{
+ return timer && timer->inuse == TIMER_INUSE;
+}
+
+/* Timer refcount functions; need global mutex. */
+extern void __timer_dealloc (struct timer_node *timer);
+
+static __inline__ void
+timer_addref (struct timer_node *timer)
+{
+ timer->refcount++;
+}
+
+static __inline__ void
+timer_delref (struct timer_node *timer)
+{
+ if (--timer->refcount == 0)
+ __timer_dealloc (timer);
+}
+
+/* Timespec helper routines. */
+static __inline__ int
+timespec_compare (const struct timespec *left, const struct timespec *right)
+{
+ if (left->tv_sec < right->tv_sec)
+ return -1;
+ if (left->tv_sec > right->tv_sec)
+ return 1;
+
+ if (left->tv_nsec < right->tv_nsec)
+ return -1;
+ if (left->tv_nsec > right->tv_nsec)
+ return 1;
+
+ return 0;
+}
+
+static __inline__ void
+timespec_add (struct timespec *sum, const struct timespec *left,
+ const struct timespec *right)
+{
+ sum->tv_sec = left->tv_sec + right->tv_sec;
+ sum->tv_nsec = left->tv_nsec + right->tv_nsec;
+
+ if (sum->tv_nsec >= 1000000000)
+ {
+ ++sum->tv_sec;
+ sum->tv_nsec -= 1000000000;
+ }
+}
+
+static __inline__ void
+timespec_sub (struct timespec *diff, const struct timespec *left,
+ const struct timespec *right)
+{
+ diff->tv_sec = left->tv_sec - right->tv_sec;
+ diff->tv_nsec = left->tv_nsec - right->tv_nsec;
+
+ if (diff->tv_nsec < 0)
+ {
+ --diff->tv_sec;
+ diff->tv_nsec += 1000000000;
+ }
+}
+
+
+/* We need one of the list functions in the other modules. */
+static __inline__ void
+list_unlink_ip (struct list_links *list)
+{
+ struct list_links *lnext = list->next, *lprev = list->prev;
+
+ lnext->prev = lprev;
+ lprev->next = lnext;
+
+ /* The suffix ip means idempotent; list_unlink_ip can be called
+ * two or more times on the same node.
+ */
+
+ list->next = list;
+ list->prev = list;
+}
+
+
+/* Functions in the helper file. */
+extern void __timer_mutex_cancel_handler (void *arg);
+extern void __timer_init_once (void);
+extern struct timer_node *__timer_alloc (void);
+extern int __timer_thread_start (struct thread_node *thread);
+extern struct thread_node *__timer_thread_find_matching (const pthread_attr_t *desired_attr, clockid_t);
+extern struct thread_node *__timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t);
+extern void __timer_thread_dealloc (struct thread_node *thread);
+extern int __timer_thread_queue_timer (struct thread_node *thread,
+ struct timer_node *insert);
+extern void __timer_thread_wakeup (struct thread_node *thread);
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c b/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c
new file mode 100644
index 000000000..86d4c84e9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c
@@ -0,0 +1,123 @@
+/* Special .init and .fini section support. Linuxthread version.
+ Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+#include <stdlib.h>
+
+/* We use embedded asm for .section unconditionally, as this makes it
+ easier to insert the necessary directives into crtn.S. */
+#define SECTION(x) __asm__ (".section " x )
+
+/* Embed an #include to pull in the alignment and .end directives. */
+__asm__ ("\n#include \"defs.h\"");
+
+/* The initial common code ends here. */
+__asm__ ("\n/*@HEADER_ENDS*/");
+
+/* To determine whether we need .end and .align: */
+__asm__ ("\n/*@TESTS_BEGIN*/");
+extern void dummy (void (*foo) (void));
+void
+dummy (void (*foo) (void))
+{
+ if (foo)
+ (*foo) ();
+}
+__asm__ ("\n/*@TESTS_END*/");
+
+/* The beginning of _init: */
+__asm__ ("\n/*@_init_PROLOG_BEGINS*/");
+
+static void
+call_initialize_minimal (void)
+{
+ extern void __pthread_initialize_minimal (void);
+
+ __pthread_initialize_minimal ();
+}
+
+SECTION (".init");
+extern void _init (void);
+void
+_init (void)
+{
+ /* The very first thing we must do is to set up the registers. */
+ call_initialize_minimal ();
+
+ __asm__ ("ALIGN");
+ __asm__("END_INIT");
+ /* Now the epilog. */
+ __asm__ ("\n/*@_init_PROLOG_ENDS*/");
+ __asm__ ("\n/*@_init_EPILOG_BEGINS*/");
+ SECTION(".init");
+}
+__asm__ ("END_INIT");
+
+/* End of the _init epilog, beginning of the _fini prolog. */
+__asm__ ("\n/*@_init_EPILOG_ENDS*/");
+__asm__ ("\n/*@_fini_PROLOG_BEGINS*/");
+
+SECTION (".fini");
+extern void _fini (void);
+void
+_fini (void)
+{
+
+ /* End of the _fini prolog. */
+ __asm__ ("ALIGN");
+ __asm__ ("END_FINI");
+ __asm__ ("\n/*@_fini_PROLOG_ENDS*/");
+
+ {
+ /* Let GCC know that _fini is not a leaf function by having a dummy
+ function call here. We arrange for this call to be omitted from
+ either crt file. */
+ extern void i_am_not_a_leaf (void);
+ i_am_not_a_leaf ();
+ }
+
+ /* Beginning of the _fini epilog. */
+ __asm__ ("\n/*@_fini_EPILOG_BEGINS*/");
+ SECTION (".fini");
+}
+__asm__ ("END_FINI");
+
+/* End of the _fini epilog. Any further generated assembly (e.g. .ident)
+ is shared between both crt files. */
+__asm__ ("\n/*@_fini_EPILOG_ENDS*/");
+__asm__ ("\n/*@TRAILER_BEGINS*/");
+
+/* End of file. */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h b/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h
index 2afaa52e8..6d8663dcb 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h
@@ -20,21 +20,17 @@
#define _PTHREAD_FUNCTIONS_H 1
#include <pthread.h>
-#if 0
#include <setjmp.h>
-#include <linuxthreads.old/internals.h>
+#include <linuxthreads/descr.h>
struct fork_block;
-#endif
/* Data type shared with libc. The libc uses it to pass on calls to
the thread functions. Wine pokes directly into this structure,
so if possible avoid breaking it and append new hooks to the end. */
struct pthread_functions
{
-#if 0
pid_t (*ptr_pthread_fork) (struct fork_block *);
-#endif
int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
int (*ptr_pthread_attr_init) (pthread_attr_t *);
int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
@@ -71,36 +67,28 @@ struct pthread_functions
pthread_t (*ptr_pthread_self) (void);
int (*ptr_pthread_setcancelstate) (int, int *);
int (*ptr_pthread_setcanceltype) (int, int *);
-#if 0
void (*ptr_pthread_do_exit) (void *retval, char *currentframe);
void (*ptr_pthread_cleanup_upto) (__jmp_buf target,
char *targetframe);
pthread_descr (*ptr_pthread_thread_self) (void);
-#endif
#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
int (*ptr_pthread_internal_tsd_set) (int key, const void *pointer);
void * (*ptr_pthread_internal_tsd_get) (int key);
void ** __attribute__ ((__const__))
(*ptr_pthread_internal_tsd_address) (int key);
#endif
-#if 0
int (*ptr_pthread_sigaction) (int sig, const struct sigaction * act,
struct sigaction *oact);
int (*ptr_pthread_sigwait) (const sigset_t *set, int *sig);
int (*ptr_pthread_raise) (int sig);
-#endif
int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
const struct timespec *);
-#if 0
void (*ptr__pthread_cleanup_push) (struct _pthread_cleanup_buffer * buffer,
void (*routine)(void *), void * arg);
-#endif
void (*ptr__pthread_cleanup_push_defer) (struct _pthread_cleanup_buffer * buffer,
void (*routine)(void *), void * arg);
-#if 0
void (*ptr__pthread_cleanup_pop) (struct _pthread_cleanup_buffer * buffer,
int execute);
-#endif
void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer * buffer,
int execute);
};
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pthread.h b/libpthread/linuxthreads/sysdeps/pthread/pthread.h
index 46c1010c6..94ed95c99 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/pthread.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/pthread.h
@@ -31,7 +31,7 @@ __BEGIN_DECLS
/* Initializers. */
#define PTHREAD_MUTEX_INITIALIZER \
- {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
+ {0, 0, 0, PTHREAD_MUTEX_TIMED_NP, __LOCK_INITIALIZER}
#ifdef __USE_GNU
# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
{0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __LOCK_INITIALIZER}
@@ -41,7 +41,7 @@ __BEGIN_DECLS
{0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
#endif
-#define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0}
+#define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0, "", 0}
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
# define PTHREAD_RWLOCK_INITIALIZER \
@@ -82,13 +82,13 @@ enum
enum
{
- PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_TIMED_NP
+ PTHREAD_MUTEX_ADAPTIVE_NP
#ifdef __USE_UNIX98
,
- PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
@@ -256,7 +256,7 @@ extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict
/* Set the starting address of the stack of the thread to be created.
Depending on whether the stack grows up or down the value must either
be higher or lower than all the address in the memory block. The
- minimal size of the block must be PTHREAD_STACK_SIZE. */
+ minimal size of the block must be PTHREAD_STACK_MIN. */
extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
void *__stackaddr) __THROW;
@@ -280,7 +280,7 @@ extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
#endif
/* Add information about the minimum stack size needed for the thread
- to be started. This size must never be less than PTHREAD_STACK_SIZE
+ to be started. This size must never be less than PTHREAD_STACK_MIN
and must also not exceed the system limits. */
extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
size_t __stacksize) __THROW;
@@ -290,16 +290,12 @@ extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
__THROW;
-#if 0
-/* Not yet implemented in uClibc! */
-
#ifdef __USE_GNU
/* Initialize thread attribute *ATTR with attributes corresponding to the
already running thread TH. It shall be called on uninitialized ATTR
and destroyed with pthread_attr_destroy when no longer needed. */
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
#endif
-#endif
/* Functions for scheduling control. */
@@ -323,11 +319,6 @@ extern int pthread_getconcurrency (void) __THROW;
extern int pthread_setconcurrency (int __level) __THROW;
#endif
-#ifdef __USE_GNU
-/* Same thing, different name */
-#define pthread_yield() sched_yield()
-#endif
-
/* Functions for mutex handling. */
/* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the
@@ -394,25 +385,20 @@ extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
const pthread_condattr_t *__restrict
__cond_attr) __THROW;
-libpthread_hidden_proto(pthread_cond_init)
/* Destroy condition variable COND. */
extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
-libpthread_hidden_proto(pthread_cond_destroy)
/* Wake up one thread waiting for condition variable COND. */
extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
-libpthread_hidden_proto(pthread_cond_signal)
/* Wake up all threads waiting for condition variables COND. */
extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
-libpthread_hidden_proto(pthread_cond_broadcast)
/* Wait for condition variable COND to be signaled or broadcast.
MUTEX is assumed to be locked before. */
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex);
-libpthread_hidden_proto(pthread_cond_wait)
/* Wait for condition variable COND to be signaled or broadcast until
ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
@@ -422,17 +408,14 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
const struct timespec *__restrict
__abstime);
-libpthread_hidden_proto(pthread_cond_timedwait)
/* Functions for handling condition variable attributes. */
/* Initialize condition variable attribute ATTR. */
extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
-libpthread_hidden_proto(pthread_condattr_init)
/* Destroy condition variable attribute ATTR. */
extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
-libpthread_hidden_proto(pthread_condattr_destroy)
/* Get the process-shared flag of the condition variable attribute ATTR. */
extern int pthread_condattr_getpshared (const pthread_condattr_t *
@@ -512,9 +495,6 @@ extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
int __pref) __THROW;
#endif
-#if 0
-/* Not yet implemented in uClibc! */
-
#ifdef __USE_XOPEN2K
/* The IEEE Std. 1003.1j-2000 introduces functions to implement
spinlocks. */
@@ -558,7 +538,6 @@ extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
#endif
-#endif
/* Functions for handling thread-specific data. */
@@ -650,9 +629,6 @@ extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg) __THROW;
-extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
- void (*__routine) (void *),
- void *__arg) __THROW;
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
restores the cancellation type that was in effect when the matching
@@ -663,19 +639,13 @@ extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buff
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
int __execute) __THROW;
-extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
- int __execute) __THROW;
#endif
-#if 0
-/* Not yet implemented in uClibc! */
-
#ifdef __USE_XOPEN2K
/* Get ID of CPU-time clock for thread THREAD_ID. */
extern int pthread_getcpuclockid (pthread_t __thread_id,
- clockid_t *__clock_id) __THROW;
-#endif
+ __clockid_t *__clock_id) __THROW;
#endif
diff --git a/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c b/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c
new file mode 100644
index 000000000..ee5522036
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c
@@ -0,0 +1,32 @@
+/* Linuxthreads - a simple clone()-based implementation of Posix */
+/* threads for Linux. */
+/* Copyright (C) 1998 Xavier Leroy (Xavier.Leroy@inria.fr) */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU Library General Public License for more details. */
+
+/* Redefine siglongjmp and longjmp so that they interact correctly
+ with cleanup handlers */
+
+#include <setjmp.h>
+#include "pthread.h"
+#include "internals.h"
+
+#ifdef SHARED
+void siglongjmp (sigjmp_buf env, int val)
+{
+ __libc_siglongjmp (env, val);
+}
+
+void longjmp (jmp_buf env, int val)
+{
+ __libc_longjmp (env, val);
+}
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/pthread/res-state.c b/libpthread/linuxthreads/sysdeps/pthread/res-state.c
new file mode 100644
index 000000000..6b4354972
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/res-state.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1996, 97, 98, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <resolv.h>
+#include <tls.h>
+#include <linuxthreads/internals.h>
+#include <sysdep-cancel.h>
+
+#ifndef __UCLIBC_HAS_TLS__
+# undef _res
+extern struct __res_state _res;
+#endif
+
+/* When threaded, _res may be a per-thread variable. */
+struct __res_state *
+#ifndef __UCLIBC_HAS_TLS__
+weak_const_function
+#endif
+__res_state (void)
+{
+#ifndef __UCLIBC_HAS_TLS__
+ if (! SINGLE_THREAD_P)
+ {
+ pthread_descr self = thread_self();
+ return LIBC_THREAD_GETMEM (self, p_resp);
+ }
+ return &_res;
+#else
+ return __resp;
+#endif
+}
+libc_hidden_def (__res_state)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/semaphore.h b/libpthread/linuxthreads/sysdeps/pthread/semaphore.h
new file mode 100644
index 000000000..8793768a8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/semaphore.h
@@ -0,0 +1 @@
+#include <linuxthreads/semaphore.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/sigaction.c b/libpthread/linuxthreads/sysdeps/pthread/sigaction.c
new file mode 100644
index 000000000..eecb8c395
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/sigaction.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Somebody please explain what's going on here. --vda */
+
+/* This is tricky. GCC doesn't like #include_next in the primary
+ source file and even if it did, the first #include_next is this
+ exact file anyway. */
+#ifndef LIBC_SIGACTION
+
+# include <bits/libc-lock.h>
+
+# define LIBC_SIGACTION 1
+
+# include "sigaction.c"
+
+# ifndef NOT_IN_libc
+# ifndef SHARED
+weak_extern (__pthread_sigaction)
+# endif
+
+int
+__sigaction (sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+{
+ return __libc_maybe_call2 (pthread_sigaction, (sig, act, oact),
+ __libc_sigaction (sig, act, oact));
+}
+# else
+weak_alias (__libc_sigaction, __sigaction)
+# endif
+libc_hidden_weak (__sigaction)
+weak_alias (__sigaction, sigaction)
+
+#else
+
+# include_next <sigaction.c>
+
+#endif /* LIBC_SIGACTION */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/tcb-offsets.h b/libpthread/linuxthreads/sysdeps/pthread/tcb-offsets.h
new file mode 100644
index 000000000..3fe13702e
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/tcb-offsets.h
@@ -0,0 +1 @@
+/* This is overridden by generated tcb-offsets.h on arches which need it. */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_create.c b/libpthread/linuxthreads/sysdeps/pthread/timer_create.c
new file mode 100644
index 000000000..36fce3567
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_create.c
@@ -0,0 +1,169 @@
+/* Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "posix-timer.h"
+
+
+/* Create new per-process timer using CLOCK. */
+int
+timer_create (clock_id, evp, timerid)
+ clockid_t clock_id;
+ struct sigevent *evp;
+ timer_t *timerid;
+{
+ int retval = -1;
+ struct timer_node *newtimer = NULL;
+ struct thread_node *thread = NULL;
+
+ if (0
+#ifdef _POSIX_CPUTIME
+ || clock_id == CLOCK_PROCESS_CPUTIME_ID
+#endif
+#ifdef _POSIX_THREAD_CPUTIME
+ || clock_id == CLOCK_THREAD_CPUTIME_ID
+#endif
+ )
+ {
+ /* We don't allow timers for CPU clocks. At least not in the
+ moment. */
+ __set_errno (ENOTSUP);
+ return -1;
+ }
+
+ if (clock_id != CLOCK_REALTIME)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ pthread_once (&__timer_init_once_control, __timer_init_once);
+
+ if (__timer_init_failed)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ newtimer = __timer_alloc ();
+ if (__builtin_expect (newtimer == NULL, 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+
+ if (evp != NULL)
+ newtimer->event = *evp;
+ else
+ {
+ newtimer->event.sigev_notify = SIGEV_SIGNAL;
+ newtimer->event.sigev_signo = SIGALRM;
+ newtimer->event.sigev_value.sival_int = timer_ptr2id (newtimer);
+ newtimer->event.sigev_notify_function = 0;
+ }
+
+ newtimer->event.sigev_notify_attributes = &newtimer->attr;
+ newtimer->creator_pid = getpid ();
+
+ switch (__builtin_expect (newtimer->event.sigev_notify, SIGEV_SIGNAL))
+ {
+ case SIGEV_NONE:
+ case SIGEV_SIGNAL:
+ /* We have a global thread for delivering timed signals.
+ If it is not running, try to start it up. */
+ thread = &__timer_signal_thread_rclk;
+ if (! thread->exists)
+ {
+ if (__builtin_expect (__timer_thread_start (thread),
+ 1) < 0)
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+ }
+ break;
+
+ case SIGEV_THREAD:
+ /* Copy over thread attributes or set up default ones. */
+ if (evp->sigev_notify_attributes)
+ newtimer->attr = *(pthread_attr_t *) evp->sigev_notify_attributes;
+ else
+ pthread_attr_init (&newtimer->attr);
+
+ /* Ensure thread attributes call for deatched thread. */
+ pthread_attr_setdetachstate (&newtimer->attr, PTHREAD_CREATE_DETACHED);
+
+ /* Try to find existing thread having the right attributes. */
+ thread = __timer_thread_find_matching (&newtimer->attr, clock_id);
+
+ /* If no existing thread has these attributes, try to allocate one. */
+ if (thread == NULL)
+ thread = __timer_thread_alloc (&newtimer->attr, clock_id);
+
+ /* Out of luck; no threads are available. */
+ if (__builtin_expect (thread == NULL, 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+
+ /* If the thread is not running already, try to start it. */
+ if (! thread->exists
+ && __builtin_expect (! __timer_thread_start (thread), 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+ break;
+
+ default:
+ __set_errno (EINVAL);
+ goto unlock_bail;
+ }
+
+ newtimer->clock = clock_id;
+ newtimer->abstime = 0;
+ newtimer->armed = 0;
+ newtimer->thread = thread;
+
+ *timerid = timer_ptr2id (newtimer);
+ retval = 0;
+
+ if (__builtin_expect (retval, 0) == -1)
+ {
+ unlock_bail:
+ if (thread != NULL)
+ __timer_thread_dealloc (thread);
+ if (newtimer != NULL)
+ {
+ timer_delref (newtimer);
+ __timer_dealloc (newtimer);
+ }
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c b/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c
new file mode 100644
index 000000000..a529d7392
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Delete timer TIMERID. */
+int
+timer_delete (timerid)
+ timer_t timerid;
+{
+ struct timer_node *timer;
+ int retval = -1;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ timer = timer_id2ptr (timerid);
+ if (! timer_valid (timer))
+ /* Invalid timer ID or the timer is not in use. */
+ __set_errno (EINVAL);
+ else
+ {
+ if (timer->armed && timer->thread != NULL)
+ {
+ struct thread_node *thread = timer->thread;
+ assert (thread != NULL);
+
+ /* If thread is cancelled while waiting for handler to terminate,
+ the mutex is unlocked and timer_delete is aborted. */
+ pthread_cleanup_push (__timer_mutex_cancel_handler, &__timer_mutex);
+
+ /* If timer is currently being serviced, wait for it to finish. */
+ while (thread->current_timer == timer)
+ pthread_cond_wait (&thread->cond, &__timer_mutex);
+
+ pthread_cleanup_pop (0);
+ }
+
+ /* Remove timer from whatever queue it may be on and deallocate it. */
+ timer->inuse = TIMER_DELETED;
+ list_unlink_ip (&timer->links);
+ timer_delref (timer);
+ retval = 0;
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c b/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c
new file mode 100644
index 000000000..6d753e30d
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Get expiration overrun for timer TIMERID. */
+int
+timer_getoverrun (timerid)
+ timer_t timerid;
+{
+ struct timer_node *timer;
+ int retval = -1;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ if (! timer_valid (timer = timer_id2ptr (timerid)))
+ __set_errno (EINVAL);
+ else
+ retval = timer->overrun_count;
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c b/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c
new file mode 100644
index 000000000..6bd2b84e2
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Get current value of timer TIMERID and store it in VLAUE. */
+int
+timer_gettime (timerid, value)
+ timer_t timerid;
+ struct itimerspec *value;
+{
+ struct timer_node *timer;
+ struct timespec now, expiry;
+ int retval = -1, armed = 0, valid;
+ clock_t clock = 0;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ timer = timer_id2ptr (timerid);
+ valid = timer_valid (timer);
+
+ if (valid) {
+ armed = timer->armed;
+ expiry = timer->expirytime;
+ clock = timer->clock;
+ value->it_interval = timer->value.it_interval;
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ if (valid)
+ {
+ if (armed)
+ {
+ clock_gettime (clock, &now);
+ if (timespec_compare (&now, &expiry) < 0)
+ timespec_sub (&value->it_value, &expiry, &now);
+ else
+ {
+ value->it_value.tv_sec = 0;
+ value->it_value.tv_nsec = 0;
+ }
+ }
+ else
+ {
+ value->it_value.tv_sec = 0;
+ value->it_value.tv_nsec = 0;
+ }
+
+ retval = 0;
+ }
+ else
+ __set_errno (EINVAL);
+
+ return retval;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c b/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c
new file mode 100644
index 000000000..9f6096ba5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c
@@ -0,0 +1,572 @@
+/* Helper code for POSIX timer implementation on LinuxThreads.
+ Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysdep.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "posix-timer.h"
+
+
+/* Number of threads used. */
+#define THREAD_MAXNODES 16
+
+/* Array containing the descriptors for the used threads. */
+static struct thread_node thread_array[THREAD_MAXNODES];
+
+/* Static array with the structures for all the timers. */
+struct timer_node __timer_array[TIMER_MAX];
+
+/* Global lock to protect operation on the lists. */
+pthread_mutex_t __timer_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Variable to protext initialization. */
+pthread_once_t __timer_init_once_control = PTHREAD_ONCE_INIT;
+
+/* Nonzero if initialization of timer implementation failed. */
+int __timer_init_failed;
+
+/* Node for the thread used to deliver signals. */
+struct thread_node __timer_signal_thread_rclk;
+
+/* Lists to keep free and used timers and threads. */
+struct list_links timer_free_list;
+struct list_links thread_free_list;
+struct list_links thread_active_list;
+
+
+#ifdef __NR_rt_sigqueueinfo
+extern int __syscall_rt_sigqueueinfo (int, int, siginfo_t *);
+#endif
+
+
+/* List handling functions. */
+static __inline__ void
+list_init (struct list_links *list)
+{
+ list->next = list->prev = list;
+}
+
+static __inline__ void
+list_append (struct list_links *list, struct list_links *newp)
+{
+ newp->prev = list->prev;
+ newp->next = list;
+ list->prev->next = newp;
+ list->prev = newp;
+}
+
+static __inline__ void
+list_insbefore (struct list_links *list, struct list_links *newp)
+{
+ list_append (list, newp);
+}
+
+/*
+ * Like list_unlink_ip, except that calling it on a node that
+ * is already unlinked is disastrous rather than a noop.
+ */
+
+static __inline__ void
+list_unlink (struct list_links *list)
+{
+ struct list_links *lnext = list->next, *lprev = list->prev;
+
+ lnext->prev = lprev;
+ lprev->next = lnext;
+}
+
+static __inline__ struct list_links *
+list_first (struct list_links *list)
+{
+ return list->next;
+}
+
+static __inline__ struct list_links *
+list_null (struct list_links *list)
+{
+ return list;
+}
+
+static __inline__ struct list_links *
+list_next (struct list_links *list)
+{
+ return list->next;
+}
+
+static __inline__ int
+list_isempty (struct list_links *list)
+{
+ return list->next == list;
+}
+
+
+/* Functions build on top of the list functions. */
+static __inline__ struct thread_node *
+thread_links2ptr (struct list_links *list)
+{
+ return (struct thread_node *) ((char *) list
+ - offsetof (struct thread_node, links));
+}
+
+static __inline__ struct timer_node *
+timer_links2ptr (struct list_links *list)
+{
+ return (struct timer_node *) ((char *) list
+ - offsetof (struct timer_node, links));
+}
+
+
+/* Initialize a newly allocated thread structure. */
+static void
+thread_init (struct thread_node *thread, const pthread_attr_t *attr, clockid_t clock_id)
+{
+ if (attr != NULL)
+ thread->attr = *attr;
+ else
+ {
+ pthread_attr_init (&thread->attr);
+ pthread_attr_setdetachstate (&thread->attr, PTHREAD_CREATE_DETACHED);
+ }
+
+ thread->exists = 0;
+ list_init (&thread->timer_queue);
+ pthread_cond_init (&thread->cond, 0);
+ thread->current_timer = 0;
+ thread->captured = pthread_self ();
+ thread->clock_id = clock_id;
+}
+
+
+/* Initialize the global lists, and acquire global resources. Error
+ reporting is done by storing a non-zero value to the global variable
+ timer_init_failed. */
+static void
+init_module (void)
+{
+ int i;
+
+ list_init (&timer_free_list);
+ list_init (&thread_free_list);
+ list_init (&thread_active_list);
+
+ for (i = 0; i < TIMER_MAX; ++i)
+ {
+ list_append (&timer_free_list, &__timer_array[i].links);
+ __timer_array[i].inuse = TIMER_FREE;
+ }
+
+ for (i = 0; i < THREAD_MAXNODES; ++i)
+ list_append (&thread_free_list, &thread_array[i].links);
+
+ thread_init (&__timer_signal_thread_rclk, 0, CLOCK_REALTIME);
+}
+
+
+/* This is a handler executed in a child process after a fork()
+ occurs. It reinitializes the module, resetting all of the data
+ structures to their initial state. The mutex is initialized in
+ case it was locked in the parent process. */
+static void
+reinit_after_fork (void)
+{
+ init_module ();
+ pthread_mutex_init (&__timer_mutex, 0);
+}
+
+
+/* Called once form pthread_once in timer_init. This initializes the
+ module and ensures that reinit_after_fork will be executed in any
+ child process. */
+void
+__timer_init_once (void)
+{
+ init_module ();
+ pthread_atfork (0, 0, reinit_after_fork);
+}
+
+
+/* Deinitialize a thread that is about to be deallocated. */
+static void
+thread_deinit (struct thread_node *thread)
+{
+ assert (list_isempty (&thread->timer_queue));
+ pthread_cond_destroy (&thread->cond);
+}
+
+
+/* Allocate a thread structure from the global free list. Global
+ mutex lock must be held by caller. The thread is moved to
+ the active list. */
+struct thread_node *
+__timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t clock_id)
+{
+ struct list_links *node = list_first (&thread_free_list);
+
+ if (node != list_null (&thread_free_list))
+ {
+ struct thread_node *thread = thread_links2ptr (node);
+ list_unlink (node);
+ thread_init (thread, desired_attr, clock_id);
+ list_append (&thread_active_list, node);
+ return thread;
+ }
+
+ return 0;
+}
+
+
+/* Return a thread structure to the global free list. Global lock
+ must be held by caller. */
+void
+__timer_thread_dealloc (struct thread_node *thread)
+{
+ thread_deinit (thread);
+ list_unlink (&thread->links);
+ list_append (&thread_free_list, &thread->links);
+}
+
+
+/* Each of our threads which terminates executes this cleanup
+ handler. We never terminate threads ourselves; if a thread gets here
+ it means that the evil application has killed it. If the thread has
+ timers, these require servicing and so we must hire a replacement
+ thread right away. We must also unblock another thread that may
+ have been waiting for this thread to finish servicing a timer (see
+ timer_delete()). */
+
+static void
+thread_cleanup (void *val)
+{
+ if (val != NULL)
+ {
+ struct thread_node *thread = val;
+
+ /* How did the signal thread get killed? */
+ assert (thread != &__timer_signal_thread_rclk);
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ thread->exists = 0;
+
+ /* We are no longer processing a timer event. */
+ thread->current_timer = 0;
+
+ if (list_isempty (&thread->timer_queue))
+ __timer_thread_dealloc (thread);
+ else
+ (void) __timer_thread_start (thread);
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ /* Unblock potentially blocked timer_delete(). */
+ pthread_cond_broadcast (&thread->cond);
+ }
+}
+
+
+/* Handle a timer which is supposed to go off now. */
+static void
+thread_expire_timer (struct thread_node *self, struct timer_node *timer)
+{
+ self->current_timer = timer; /* Lets timer_delete know timer is running. */
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ switch (__builtin_expect (timer->event.sigev_notify, SIGEV_SIGNAL))
+ {
+ case SIGEV_NONE:
+ break;
+
+ case SIGEV_SIGNAL:
+#ifdef __NR_rt_sigqueueinfo
+ {
+ siginfo_t info;
+
+ /* First, clear the siginfo_t structure, so that we don't pass our
+ stack content to other tasks. */
+ memset (&info, 0, sizeof (siginfo_t));
+ /* We must pass the information about the data in a siginfo_t
+ value. */
+ info.si_signo = timer->event.sigev_signo;
+ info.si_code = SI_TIMER;
+ info.si_pid = timer->creator_pid;
+ info.si_uid = getuid ();
+ info.si_value = timer->event.sigev_value;
+
+ INLINE_SYSCALL (rt_sigqueueinfo, 3, info.si_pid, info.si_signo, &info);
+ }
+#else
+ if (pthread_kill (self->captured, timer->event.sigev_signo) != 0)
+ {
+ if (pthread_kill (self->id, timer->event.sigev_signo) != 0)
+ abort ();
+ }
+#endif
+ break;
+
+ case SIGEV_THREAD:
+ timer->event.sigev_notify_function (timer->event.sigev_value);
+ break;
+
+ default:
+ assert (! "unknown event");
+ break;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ self->current_timer = 0;
+
+ pthread_cond_broadcast (&self->cond);
+}
+
+
+/* Thread function; executed by each timer thread. The job of this
+ function is to wait on the thread's timer queue and expire the
+ timers in chronological order as close to their scheduled time as
+ possible. */
+static void
+__attribute__ ((noreturn))
+thread_func (void *arg)
+{
+ struct thread_node *self = arg;
+
+ /* Register cleanup handler, in case rogue application terminates
+ this thread. (This cannot happen to __timer_signal_thread, which
+ doesn't invoke application callbacks). */
+
+ pthread_cleanup_push (thread_cleanup, self);
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ while (1)
+ {
+ struct list_links *first;
+ struct timer_node *timer = NULL;
+
+ /* While the timer queue is not empty, inspect the first node. */
+ first = list_first (&self->timer_queue);
+ if (first != list_null (&self->timer_queue))
+ {
+ struct timespec now;
+
+ timer = timer_links2ptr (first);
+
+ /* This assumes that the elements of the list of one thread
+ are all for the same clock. */
+ clock_gettime (timer->clock, &now);
+
+ while (1)
+ {
+ /* If the timer is due or overdue, remove it from the queue.
+ If it's a periodic timer, re-compute its new time and
+ requeue it. Either way, perform the timer expiry. */
+ if (timespec_compare (&now, &timer->expirytime) < 0)
+ break;
+
+ list_unlink_ip (first);
+
+ if (__builtin_expect (timer->value.it_interval.tv_sec, 0) != 0
+ || timer->value.it_interval.tv_nsec != 0)
+ {
+ timer->overrun_count = 0;
+ timespec_add (&timer->expirytime, &timer->expirytime,
+ &timer->value.it_interval);
+ while (timespec_compare (&timer->expirytime, &now) < 0)
+ {
+ timespec_add (&timer->expirytime, &timer->expirytime,
+ &timer->value.it_interval);
+ if (timer->overrun_count < DELAYTIMER_MAX)
+ ++timer->overrun_count;
+ }
+ __timer_thread_queue_timer (self, timer);
+ }
+
+ thread_expire_timer (self, timer);
+
+ first = list_first (&self->timer_queue);
+ if (first == list_null (&self->timer_queue))
+ break;
+
+ timer = timer_links2ptr (first);
+ }
+ }
+
+ /* If the queue is not empty, wait until the expiry time of the
+ first node. Otherwise wait indefinitely. Insertions at the
+ head of the queue must wake up the thread by broadcasting
+ this condition variable. */
+ if (timer != NULL)
+ pthread_cond_timedwait (&self->cond, &__timer_mutex,
+ &timer->expirytime);
+ else
+ pthread_cond_wait (&self->cond, &__timer_mutex);
+ }
+ /* This macro will never be executed since the while loop loops
+ forever - but we have to add it for proper nesting. */
+ pthread_cleanup_pop (1);
+}
+
+
+/* Enqueue a timer in wakeup order in the thread's timer queue.
+ Returns 1 if the timer was inserted at the head of the queue,
+ causing the queue's next wakeup time to change. */
+
+int
+__timer_thread_queue_timer (struct thread_node *thread,
+ struct timer_node *insert)
+{
+ struct list_links *iter;
+ int athead = 1;
+
+ for (iter = list_first (&thread->timer_queue);
+ iter != list_null (&thread->timer_queue);
+ iter = list_next (iter))
+ {
+ struct timer_node *timer = timer_links2ptr (iter);
+
+ if (timespec_compare (&insert->expirytime, &timer->expirytime) < 0)
+ break;
+ athead = 0;
+ }
+
+ list_insbefore (iter, &insert->links);
+ return athead;
+}
+
+
+/* Start a thread and associate it with the given thread node. Global
+ lock must be held by caller. */
+int
+__timer_thread_start (struct thread_node *thread)
+{
+ int retval = 1;
+
+ assert (!thread->exists);
+ thread->exists = 1;
+
+ if (pthread_create (&thread->id, &thread->attr,
+ (void *(*) (void *)) thread_func, thread) != 0)
+ {
+ thread->exists = 0;
+ retval = -1;
+ }
+
+ return retval;
+}
+
+
+void
+__timer_thread_wakeup (struct thread_node *thread)
+{
+ pthread_cond_broadcast (&thread->cond);
+}
+
+
+/* Compare two pthread_attr_t thread attributes for exact equality.
+ Returns 1 if they are equal, otherwise zero if they are not equal or
+ contain illegal values. This version is LinuxThreads-specific for
+ performance reason. One could use the access functions to get the
+ values of all the fields of the attribute structure. */
+static int
+thread_attr_compare (const pthread_attr_t *left, const pthread_attr_t *right)
+{
+ return (left->__detachstate == right->__detachstate
+ && left->__schedpolicy == right->__schedpolicy
+ && left->__guardsize == right->__guardsize
+ && (left->__schedparam.sched_priority
+ == right->__schedparam.sched_priority)
+ && left->__inheritsched == right->__inheritsched
+ && left->__scope == right->__scope
+ && left->__stacksize == right->__stacksize
+ && left->__stackaddr_set == right->__stackaddr_set
+ && (left->__stackaddr_set
+ || left->__stackaddr == right->__stackaddr));
+}
+
+
+/* Search the list of active threads and find one which has matching
+ attributes. Global mutex lock must be held by caller. */
+struct thread_node *
+__timer_thread_find_matching (const pthread_attr_t *desired_attr,
+ clockid_t desired_clock_id)
+{
+ struct list_links *iter = list_first (&thread_active_list);
+
+ while (iter != list_null (&thread_active_list))
+ {
+ struct thread_node *candidate = thread_links2ptr (iter);
+
+ if (thread_attr_compare (desired_attr, &candidate->attr)
+ && desired_clock_id == candidate->clock_id)
+ return candidate;
+
+ iter = list_next (iter);
+ }
+
+ return NULL;
+}
+
+
+/* Grab a free timer structure from the global free list. The global
+ lock must be held by the caller. */
+struct timer_node *
+__timer_alloc (void)
+{
+ struct list_links *node = list_first (&timer_free_list);
+
+ if (node != list_null (&timer_free_list))
+ {
+ struct timer_node *timer = timer_links2ptr (node);
+ list_unlink_ip (node);
+ timer->inuse = TIMER_INUSE;
+ timer->refcount = 1;
+ return timer;
+ }
+
+ return NULL;
+}
+
+
+/* Return a timer structure to the global free list. The global lock
+ must be held by the caller. */
+void
+__timer_dealloc (struct timer_node *timer)
+{
+ assert (timer->refcount == 0);
+ timer->thread = NULL; /* Break association between timer and thread. */
+ timer->inuse = TIMER_FREE;
+ list_append (&timer_free_list, &timer->links);
+}
+
+
+/* Thread cancellation handler which unlocks a mutex. */
+void
+__timer_mutex_cancel_handler (void *arg)
+{
+ pthread_mutex_unlock (arg);
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c b/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c
new file mode 100644
index 000000000..da0908b0b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Set timer TIMERID to VALUE, returning old value in OVLAUE. */
+int
+timer_settime (timerid, flags, value, ovalue)
+ timer_t timerid;
+ int flags;
+ const struct itimerspec *value;
+ struct itimerspec *ovalue;
+{
+ struct timer_node *timer;
+ struct thread_node *thread = NULL;
+ struct timespec now;
+ int have_now = 0, need_wakeup = 0;
+ int retval = -1;
+
+ timer = timer_id2ptr (timerid);
+ if (timer == NULL)
+ {
+ __set_errno (EINVAL);
+ goto bail;
+ }
+
+ if (value->it_interval.tv_nsec < 0
+ || value->it_interval.tv_nsec >= 1000000000
+ || value->it_value.tv_nsec < 0
+ || value->it_value.tv_nsec >= 1000000000)
+ {
+ __set_errno (EINVAL);
+ goto bail;
+ }
+
+ /* Will need to know current time since this is a relative timer;
+ might as well make the system call outside of the lock now! */
+
+ if ((flags & TIMER_ABSTIME) == 0)
+ {
+ clock_gettime (timer->clock, &now);
+ have_now = 1;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+ timer_addref (timer);
+
+ /* One final check of timer validity; this one is possible only
+ until we have the mutex, because it accesses the inuse flag. */
+
+ if (! timer_valid(timer))
+ {
+ __set_errno (EINVAL);
+ goto unlock_bail;
+ }
+
+ if (ovalue != NULL)
+ {
+ ovalue->it_interval = timer->value.it_interval;
+
+ if (timer->armed)
+ {
+ if (! have_now)
+ {
+ pthread_mutex_unlock (&__timer_mutex);
+ clock_gettime (timer->clock, &now);
+ have_now = 1;
+ pthread_mutex_lock (&__timer_mutex);
+ timer_addref (timer);
+ }
+
+ timespec_sub (&ovalue->it_value, &timer->expirytime, &now);
+ }
+ else
+ {
+ ovalue->it_value.tv_sec = 0;
+ ovalue->it_value.tv_nsec = 0;
+ }
+ }
+
+ timer->value = *value;
+
+ list_unlink_ip (&timer->links);
+ timer->armed = 0;
+
+ thread = timer->thread;
+
+ /* A value of { 0, 0 } causes the timer to be stopped. */
+ if (value->it_value.tv_sec != 0
+ || __builtin_expect (value->it_value.tv_nsec != 0, 1))
+ {
+ if ((flags & TIMER_ABSTIME) != 0)
+ /* The user specified the expiration time. */
+ timer->expirytime = value->it_value;
+ else
+ timespec_add (&timer->expirytime, &now, &value->it_value);
+
+ /* Only need to wake up the thread if timer is inserted
+ at the head of the queue. */
+ if (thread != NULL)
+ need_wakeup = __timer_thread_queue_timer (thread, timer);
+ timer->armed = 1;
+ }
+
+ retval = 0;
+
+unlock_bail:
+ timer_delref (timer);
+ pthread_mutex_unlock (&__timer_mutex);
+
+bail:
+ if (thread != NULL && need_wakeup)
+ __timer_thread_wakeup (thread);
+
+ return retval;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/tls.h b/libpthread/linuxthreads/sysdeps/pthread/tls.h
deleted file mode 100644
index 2068f1e77..000000000
--- a/libpthread/linuxthreads/sysdeps/pthread/tls.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Definition for thread-local data handling. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* By default no TLS support is available. This is signaled by the
- absence of the symbol USE_TLS. */
-#undef USE_TLS
-
-
-/* An architecture-specific version of this file has to defined a
- number of symbols:
-
- TLS_TCB_AT_TP or TLS_DTV_AT_TP
-
- The presence of one of these symbols signals which variant of
- the TLS ABI is used. There are in the moment two variants
- available:
-
- * the thread pointer points to a thread control block
-
- * the thread pointer points to the dynamic thread vector
-
-
- TLS_TCB_SIZE
-
- This is the size of the thread control block structure. How
- this is actually defined depends on the ABI. The thread control
- block could be internal descriptor of the thread library or
- just a data structure which allows finding the DTV.
-
- TLS_INIT_TCB_SIZE
-
- Similarly, but this value is only used at startup and in the
- dynamic linker itself. There are no threads in use at that time.
-
-
- TLS_TCB_ALIGN
-
- Alignment requirements for the TCB structure.
-
- TLS_INIT_TCB_ALIGN
-
- Similarly, but for the structure used at startup time.
-
-
- INSTALL_DTV(tcb, init_dtv)
-
- This macro must install the given initial DTV into the thread control
- block TCB. The normal runtime functionality must then be able to
- use the value.
-
-
- TLS_INIT_TP(tcb, firstcall)
-
- This macro must initialize the thread pointer to enable normal TLS
- operation. The first parameter is a pointer to the thread control
- block. The second parameter specifies whether this is the first
- call for the TCB. ld.so calls this macro more than once.
-
-
- THREAD_DTV()
-
- This macro returns the address of the DTV of the current thread.
- This normally is done using the the thread register which points
- to the dtv or the TCB (from which the DTV can found).
- */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c b/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c
new file mode 100644
index 000000000..0a679d9c6
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c
@@ -0,0 +1,113 @@
+/* Tests for POSIX timer implementation.
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static void
+notify_func (union sigval sigval)
+{
+ puts ("notify_func");
+}
+
+
+static void
+signal_func (int sig)
+{
+ static const char text[] = "signal_func\n";
+ signal (sig, signal_func);
+ write (STDOUT_FILENO, text, sizeof text - 1);
+}
+
+static void
+intr_sleep (int sec)
+{
+ struct timespec ts;
+
+ ts.tv_sec = sec;
+ ts.tv_nsec = 0;
+
+ while (nanosleep (&ts, &ts) == -1 && errno == EINTR)
+ ;
+}
+
+#define ZSIGALRM 14
+
+
+int
+main (void)
+{
+ struct timespec ts;
+ timer_t timer_sig, timer_thr1, timer_thr2;
+ int retval;
+ struct sigevent sigev1 =
+ {
+ .sigev_notify = SIGEV_SIGNAL,
+ .sigev_signo = ZSIGALRM
+ };
+ struct sigevent sigev2;
+ struct itimerspec itimer1 = { { 0, 200000000 }, { 0, 200000000 } };
+ struct itimerspec itimer2 = { { 0, 100000000 }, { 0, 500000000 } };
+ struct itimerspec itimer3 = { { 0, 150000000 }, { 0, 300000000 } };
+ struct itimerspec old;
+
+ retval = clock_gettime (CLOCK_REALTIME, &ts);
+
+ sigev2.sigev_notify = SIGEV_THREAD;
+ sigev2.sigev_notify_function = notify_func;
+ sigev2.sigev_notify_attributes = NULL;
+
+ setvbuf (stdout, 0, _IOLBF, 0);
+
+ printf ("clock_gettime returned %d, timespec = { %ld, %ld }\n",
+ retval, ts.tv_sec, ts.tv_nsec);
+
+ retval = clock_getres (CLOCK_REALTIME, &ts);
+
+ printf ("clock_getres returned %d, timespec = { %ld, %ld }\n",
+ retval, ts.tv_sec, ts.tv_nsec);
+
+ timer_create (CLOCK_REALTIME, &sigev1, &timer_sig);
+ timer_create (CLOCK_REALTIME, &sigev2, &timer_thr1);
+ timer_create (CLOCK_REALTIME, &sigev2, &timer_thr2);
+
+ timer_settime (timer_thr1, 0, &itimer2, &old);
+ timer_settime (timer_thr2, 0, &itimer3, &old);
+
+ signal (ZSIGALRM, signal_func);
+
+ timer_settime (timer_sig, 0, &itimer1, &old);
+
+ timer_delete (-1);
+
+ intr_sleep (3);
+
+ timer_delete (timer_sig);
+ timer_delete (timer_thr1);
+
+ intr_sleep (3);
+
+ timer_delete (timer_thr2);
+
+ return 0;
+}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h b/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h
new file mode 100644
index 000000000..b957dedc9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h
@@ -0,0 +1,47 @@
+#ifndef _UCLIBC_GLUE_H
+#define _UCLIBC_GLUE_H 1
+
+#include <features.h>
+#include <sys/cdefs.h>
+#include <bits/uClibc_page.h>
+
+#ifdef IS_IN_libpthread
+#include <bits/kernel-features.h>
+
+#ifndef __GLIBC_HAVE_LONG_LONG
+# define __GLIBC_HAVE_LONG_LONG
+#endif
+
+#define __getpagesize getpagesize
+#define __sched_get_priority_max sched_get_priority_max
+#define __sched_get_priority_min sched_get_priority_min
+#define __sched_getscheduler sched_getscheduler
+#define __sched_setscheduler sched_setscheduler
+#define __sched_getparam sched_getparam
+#define __getpid getpid
+#define __gettimeofday gettimeofday
+#define __poll poll
+#define __sysctl sysctl
+#define __open open
+#define __read read
+#define __close close
+#define __on_exit on_exit
+#define __libc_current_sigrtmin_private __libc_current_sigrtmin
+#define __clone clone
+
+extern void *__libc_stack_end;
+extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
+
+#endif /* IS_IN_libpthread */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+# define __uselocale(x) uselocale(x)
+#else
+# define __uselocale(x) ((void)0)
+#endif
+
+/* Use a funky version in a probably vein attempt at preventing gdb
+ * from dlopen()'ing glibc's libthread_db library... */
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/sh/pspinlock.c b/libpthread/linuxthreads/sysdeps/sh/pspinlock.c
new file mode 100644
index 000000000..2f039de53
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/sh/pspinlock.c
@@ -0,0 +1,79 @@
+/* POSIX spinlock implementation. SH version.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ ("tas.b @%1; movt %0"
+ : "=r" (val)
+ : "r" (lock)
+ : "memory");
+ while (val == 0);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ __asm__ __volatile__ ("tas.b @%1; movt %0"
+ : "=r" (val)
+ : "r" (lock)
+ : "memory");
+ return val ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym
new file mode 100644
index 000000000..6324a016c
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym
@@ -0,0 +1,10 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+#ifdef __UCLIBC_HAS_TLS__
+MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads)
+TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+#else
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/sh/tls.h b/libpthread/linuxthreads/sysdeps/sh/tls.h
index 25bef830f..512e3181e 100644
--- a/libpthread/linuxthreads/sysdeps/sh/tls.h
+++ b/libpthread/linuxthreads/sysdeps/sh/tls.h
@@ -30,87 +30,129 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
-
-typedef struct
-{
- void *tcb; /* Pointer to the TCB. Not necessary the
- thread descriptor used by libpthread. */
- dtv_t *dtv;
- void *self; /* Pointer to the thread descriptor. */
-} tcbhead_t;
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
/* We can support TLS only if the floating-stack support is available. */
-#if defined FLOATING_STACKS && defined HAVE_TLS_SUPPORT
-
-/* Get system call information. */
-# include <sysdep.h>
+#if defined HAVE_TLS_SUPPORT \
+ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
/* Signal that TLS support is available. */
-//# define USE_TLS 1
+# define USE_TLS 1
+/* Include padding in _pthread_descr_struct so that libc can find p_errno,
+ if libpthread will only include the padding because of the !IS_IN_libpthread
+ check. */
+#ifndef FLOATING_STACKS
+# define INCLUDE_TLS_PADDING 1
+#endif
-/* Get the thread descriptor definition. */
-# include <linuxthreads/descr.h>
+# ifndef __ASSEMBLER__
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
/* This is the size of the TCB. */
-# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
/* Alignment requirements for the TCB. */
-# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
/* The TLS blocks start right after the TCB. */
-# define TLS_DTV_AT_TP 1
-
+# define TLS_DTV_AT_TP 1
/* Install the dtv pointer. The pointer passed is to the element with
index -1 which contain the length. */
-# define INSTALL_DTV(descr, dtvp) \
- ((tcbhead_t *) (descr))->dtv = dtvp + 1
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = dtvp + 1
/* Install new dtv for current thread. */
-# define INSTALL_NEW_DTV(dtv) \
- ({ struct _pthread_descr_struct *__descr; \
- THREAD_SETMEM (__descr, p_header.data.dtvp, (dtv)); })
+# define INSTALL_NEW_DTV(dtv) \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->dtv = (dtv);})
/* Return dtv of given thread descriptor. */
-# define GET_DTV(descr) \
- (((tcbhead_t *) (descr))->dtv)
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
/* Code to initially initialize the thread pointer. This might need
special attention since 'errno' is not yet available and if the
operation can cause a failure 'errno' must not be touched. */
-# define TLS_INIT_TP(descr, secondcall) \
- ({ \
- void *_descr = (descr); \
- int result; \
- tcbhead_t *head = _descr; \
- \
- head->tcb = _descr; \
- /* For now the thread descriptor is at the same address. */ \
- head->self = _descr; \
- \
- __asm__ ("ldc %0,gbr" : : "r" (_descr)); \
- \
- 0; \
- })
-
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __asm__ __volatile__ ("ldc %0,gbr" : : "r" (tcbp)); 0; })
/* Return the address of the dtv for the current thread. */
-# define THREAD_DTV() \
- ({ struct _pthread_descr_struct *__descr; \
- THREAD_GETMEM (__descr, p_header.data.dtvp); })
+# define THREAD_DTV() \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->dtv;})
-#endif /* FLOATING_STACKS && HAVE_TLS_SUPPORT */
-#endif /* __ASSEMBLER__ */
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ({ struct _pthread_descr_struct *__self; \
+ __asm__ ("stc gbr,%0" : "=r" (__self)); \
+ __self - 1;})
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(descr, nr) \
+ ({ struct _pthread_descr_struct *__self = (void *) descr; \
+ __asm__ __volatile__ ("ldc %0,gbr" : : "r" (__self + 1)); \
+ 0; })
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+/* Get the thread descriptor definition. This must be after the
+ the definition of THREAD_SELF for TLS. */
+# include <linuxthreads/descr.h>
+
+# endif /* __ASSEMBLER__ */
+
+#else
+
+# ifndef __ASSEMBLER__
+
+typedef struct
+{
+ void *tcb;
+ dtv_t *dtv;
+ void *self;
+ int multiple_threads;
+} tcbhead_t;
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+# define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
+ __asm__ __volatile__ ("ldc %0,gbr" : : "r" (&nontls_init_tp)); \
+ } while (0)
+
+# endif /* __ASSEMBLER__ */
+
+#endif /* HAVE_TLS_SUPPORT && (FLOATING_STACKS || !IS_IN_libpthread) */
#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/sh64/Makefile.arch b/libpthread/linuxthreads/sysdeps/sh64/Makefile.arch
deleted file mode 100644
index ddb56645c..000000000
--- a/libpthread/linuxthreads/sysdeps/sh64/Makefile.arch
+++ /dev/null
@@ -1,30 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-libpthread_ARCH_DIR:=$(top_srcdir)libpthread/linuxthreads.old/sysdeps/sh64
-libpthread_ARCH_OUT:=$(top_builddir)libpthread/linuxthreads.old/sysdeps/sh64
-
-libpthread_ARCH_SRC:=$(wildcard $(libpthread_ARCH_DIR)/*.c)
-libpthread_ARCH_OBJ:=$(patsubst $(libpthread_ARCH_DIR)/%.c,$(libpthread_ARCH_OUT)/%.o,$(libpthread_ARCH_SRC))
-
-libpthread-a-y+=$(libpthread_ARCH_OBJ)
-libpthread-so-y+=$(libpthread_ARCH_OBJ:.o=.os)
-
-libpthread-multi-y+=$(libpthread_ARCH_SRC)
-
-objclean-y += CLEAN_$($(top_builddir),,$(libpthread_ARCH_OUT))
-
-# We need to build as SHcompact for tas..
-$(libpthread_ARCH_OBJ): %.o : %.c
- $(compile.c:32media=compact)
-
-$(libpthread_ARCH_OBJ:.o=.os): %.os : %.c
- $(compile.c:32media=compact)
-
-CLEAN_$($(top_builddir),,$(libpthread_ARCH_OUT)):
- $(do_rm) $(addprefix $(libpthread_ARCH_OUT)/*., o os)
diff --git a/libpthread/linuxthreads/sysdeps/sh64/pt-machine.c b/libpthread/linuxthreads/sysdeps/sh64/pt-machine.c
deleted file mode 100644
index 1c187c85c..000000000
--- a/libpthread/linuxthreads/sysdeps/sh64/pt-machine.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Cloned for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-
-/* Machine-dependent pthreads configuration and inline functions.
- SH5 version.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Niibe Yutaka <gniibe@m17n.org>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- see <http://www.gnu.org/licenses/>. */
-
-#include "pt-machine.h"
-
-/* Spinlock implementation; required. */
-
-/* The SH5 does not have a suitable test-and-set instruction (SWAP only
- operates on an aligned quad word). So we use the SH4 version instead.
- This must be seperately compiled in SHcompact mode, so it cannot be
- inline. */
-
-long int testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__(
- "tas.b @%1\n\t"
- "movt %0"
- : "=r" (ret)
- : "r" (spinlock)
- : "memory", "cc");
-
- return (ret == 0);
-}
-
diff --git a/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c b/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c
new file mode 100644
index 000000000..4de152be3
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c
@@ -0,0 +1,87 @@
+/* POSIX spinlock implementation. SPARC32 version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+/* This implementation is similar to the one used in the Linux kernel. */
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("1: ldstub [%0], %%g2\n"
+ " orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2f\n"
+ " ldub [%0], %%g2\n"
+ ".subsection 2\n"
+ "2: orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2b\n"
+ " ldub [%0], %%g2\n"
+ " b,a 1b\n"
+ ".previous"
+ : /* no outputs */
+ : "r" (lock)
+ : "g2", "memory", "cc");
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int result;
+ __asm__ __volatile__
+ ("ldstub [%1], %0"
+ : "=r" (result)
+ : "r" (lock)
+ : "memory");
+ return result == 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.h b/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.h
deleted file mode 100644
index 6d6f111f4..000000000
--- a/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../../linuxthreads/sysdeps/pthread/tcb-offsets.h"
diff --git a/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.sym
new file mode 100644
index 000000000..aee6be257
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/sparc/tcb-offsets.sym
@@ -0,0 +1,4 @@
+#include <sysdep.h>
+#include <tls.h>
+
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/tls.h b/libpthread/linuxthreads/sysdeps/sparc/tls.h
new file mode 100644
index 000000000..1e31c2e63
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/sparc/tls.h
@@ -0,0 +1,114 @@
+/* Definitions for thread-local data handling. linuxthreads/sparc version.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <pt-machine.h>
+# include <stdbool.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessary the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+} tcbhead_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+#ifdef HAVE_TLS_SUPPORT
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+# ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* The TCB can have any size and the memory following the address the
+ thread pointer points to is unspecified. Allocate the TCB there. */
+# define TLS_TCB_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(descr, dtvp) \
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) \
+ (((tcbhead_t *) __thread_self)->dtv = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(descr) \
+ (((tcbhead_t *) (descr))->dtv)
+
+/* Code to initially initialize the thread pointer. */
+# define TLS_INIT_TP(descr, secondcall) \
+ (__thread_self = (__typeof (__thread_self)) (descr), NULL)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) __thread_self)->dtv)
+
+# endif
+
+#else
+
+# define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp \
+ = { .multiple_threads = 0 }; \
+ __thread_self = (__typeof (__thread_self)) &nontls_init_tp; \
+ } while (0)
+
+#endif /* USE_TLS */
+
+#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/sh64/pt-machine.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h
index 9b1fc74cd..3d3d2219f 100644
--- a/libpthread/linuxthreads/sysdeps/sh64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h
@@ -1,11 +1,6 @@
-/* Cloned for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-
-/* Machine-dependent pthreads configuration and inline functions.
- SuperH version.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Determine whether block of given size can be allocated on the stack or not.
+ Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Niibe Yutaka <gniibe@m17n.org>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -21,18 +16,10 @@
License along with the GNU C Library; see the file COPYING.LIB. If not,
see <http://www.gnu.org/licenses/>. */
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("r15");
+#include <limits.h>
-#endif /* pt-machine.h */
+__extern_always_inline int __libc_use_alloca (size_t size)
+{
+ return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1)
+ || __libc_alloca_cutoff (size));
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c
new file mode 100644
index 000000000..69bc0d79a
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c
@@ -0,0 +1,88 @@
+/* Handle real-time signal allocation.
+ Copyright (C) 1997,98,99,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+/* Sanity check. */
+#if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
+# error "This must not happen"
+#endif
+
+static int current_rtmin;
+static int current_rtmax;
+
+static int initialized;
+
+#include <testrtsig.h>
+
+static void
+init (void)
+{
+ if (!kernel_has_rtsig ())
+ {
+ current_rtmin = -1;
+ current_rtmax = -1;
+ }
+ else
+ {
+ current_rtmin = __SIGRTMIN + 3;
+ current_rtmax = __SIGRTMAX;
+ }
+ initialized = 1;
+}
+
+/* Return number of available real-time signal with highest priority. */
+int
+__libc_current_sigrtmin (void)
+{
+ if (!initialized)
+ init ();
+ return current_rtmin;
+}
+strong_alias (__libc_current_sigrtmin, __libc_current_sigrtmin_private)
+libc_hidden_def (__libc_current_sigrtmin)
+
+/* Return number of available real-time signal with lowest priority. */
+int
+__libc_current_sigrtmax (void)
+{
+ if (!initialized)
+ init ();
+ return current_rtmax;
+}
+strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private)
+libc_hidden_def (__libc_current_sigrtmax)
+
+#if 0
+/* Allocate real-time signal with highest/lowest available
+ priority. Please note that we don't use a lock since we assume
+ this function to be called at program start. */
+int
+__libc_allocate_rtsig (int high)
+{
+ if (!initialized)
+ init ();
+ if (current_rtmin == -1 || current_rtmin > current_rtmax)
+ /* We don't have anymore signal available. */
+ return -1;
+
+ return high ? current_rtmin++ : current_rtmax--;
+}
+strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/aio_cancel.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/aio_cancel.c
new file mode 100644
index 000000000..0d6da8291
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/aio_cancel.c
@@ -0,0 +1,33 @@
+#include <shlib-compat.h>
+
+#define aio_cancel64 XXX
+#include <aio.h>
+#undef aio_cancel64
+#include <errno.h>
+
+extern __typeof (aio_cancel) __new_aio_cancel;
+extern __typeof (aio_cancel) __old_aio_cancel;
+
+#define aio_cancel __new_aio_cancel
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__new_aio_cancel, __new_aio_cancel64);
+versioned_symbol (librt, __new_aio_cancel, aio_cancel, GLIBC_2_3);
+versioned_symbol (librt, __new_aio_cancel64, aio_cancel64, GLIBC_2_3);
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3)
+
+#undef ECANCELED
+#define aio_cancel __old_aio_cancel
+#define ECANCELED 125
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__old_aio_cancel, __old_aio_cancel64);
+compat_symbol (librt, __old_aio_cancel, aio_cancel, GLIBC_2_1);
+compat_symbol (librt, __old_aio_cancel64, aio_cancel64, GLIBC_2_1);
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
new file mode 100644
index 000000000..001403a19
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
@@ -0,0 +1,91 @@
+/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
+ Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* This is the value this implementation supports. */
+#define PTHREAD_THREADS_MAX 16384
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
+
+/* Maximum number of POSIX timers available. */
+#define TIMER_MAX 256
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
new file mode 100644
index 000000000..6d917e7f5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -0,0 +1,65 @@
+/* bits/typesizes.h -- underlying types for *_t. Linux/Alpha version.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_TYPESIZES_H
+#define _BITS_TYPESIZES_H 1
+
+/* See <bits/types.h> for the meaning of these macros. This file exists so
+ that <bits/types.h> need not vary across different GNU platforms. */
+
+#define __DEV_T_TYPE __U64_TYPE
+#define __UID_T_TYPE __U32_TYPE
+#define __GID_T_TYPE __U32_TYPE
+#define __INO_T_TYPE __U32_TYPE
+#define __INO64_T_TYPE __U64_TYPE
+#define __MODE_T_TYPE __U32_TYPE
+#define __NLINK_T_TYPE __U32_TYPE
+#define __OFF_T_TYPE __SLONGWORD_TYPE
+#define __OFF64_T_TYPE __S64_TYPE
+#define __PID_T_TYPE __S32_TYPE
+#define __RLIM_T_TYPE __ULONGWORD_TYPE
+#define __RLIM64_T_TYPE __U64_TYPE
+#define __BLKCNT_T_TYPE __U32_TYPE
+#define __BLKCNT64_T_TYPE __U64_TYPE
+#define __FSBLKCNT_T_TYPE __S32_TYPE
+#define __FSBLKCNT64_T_TYPE __S64_TYPE
+#define __FSFILCNT_T_TYPE __U32_TYPE
+#define __FSFILCNT64_T_TYPE __U64_TYPE
+#define __ID_T_TYPE __U32_TYPE
+#define __CLOCK_T_TYPE __SLONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
+#define __USECONDS_T_TYPE __U32_TYPE
+#define __SUSECONDS_T_TYPE __S64_TYPE
+#define __DADDR_T_TYPE __S32_TYPE
+#define __SWBLK_T_TYPE __SLONGWORD_TYPE
+#define __KEY_T_TYPE __S32_TYPE
+#define __CLOCKID_T_TYPE __S32_TYPE
+#define __TIMER_T_TYPE __S32_TYPE
+#define __BLKSIZE_T_TYPE __U32_TYPE
+#define __FSID_T_TYPE struct { int __val[2]; }
+#define __SSIZE_T_TYPE __SWORD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+#endif /* bits/typesizes.h */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S
new file mode 100644
index 000000000..754fc5b1c
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S
@@ -0,0 +1,27 @@
+/* Internal sigsuspend system call for LinuxThreads. Alpha version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#undef PSEUDO_PREPARE_ARGS
+#define PSEUDO_PREPARE_ARGS ldq a0, 0(a0);
+
+ .hidden __pthread_sigsuspend
+PSEUDO_NOERRNO(__pthread_sigsuspend, sigsuspend, 1)
+ ret
+PSEUDO_END_NOERRNO(__pthread_sigsuspend)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
new file mode 100644
index 000000000..8ce43153d
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -0,0 +1,145 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+# ifdef PROF
+# define PSEUDO_PROF \
+ .set noat; \
+ lda AT, _mcount; \
+ jsr AT, (AT), _mcount; \
+ .set at
+# else
+# define PSEUDO_PROF
+# endif
+
+/* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
+ besides "ret". */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .globl name; \
+ .align 4; \
+ .type name, @function; \
+ .usepv name, std; \
+ cfi_startproc; \
+__LABEL(name) \
+ ldgp gp, 0(pv); \
+ PSEUDO_PROF; \
+ PSEUDO_PREPARE_ARGS \
+ SINGLE_THREAD_P(t0); \
+ bne t0, $pseudo_cancel; \
+ lda v0, SYS_ify(syscall_name); \
+ call_pal PAL_callsys; \
+ bne a3, SYSCALL_ERROR_LABEL; \
+__LABEL($pseudo_ret) \
+ .subsection 2; \
+__LABEL($pseudo_cancel) \
+ subq sp, 64, sp; \
+ cfi_def_cfa_offset(64); \
+ stq ra, 0(sp); \
+ cfi_offset(ra, -64); \
+ SAVE_ARGS_##args; \
+ CENABLE; \
+ LOAD_ARGS_##args; \
+ lda v0, SYS_ify(syscall_name); \
+ call_pal PAL_callsys; \
+ stq v0, 8(sp); \
+ bne a3, $multi_error; \
+ CDISABLE; \
+ ldq ra, 0(sp); \
+ ldq v0, 8(sp); \
+ addq sp, 64, sp; \
+ cfi_remember_state; \
+ cfi_restore(ra); \
+ cfi_def_cfa_offset(0); \
+ ret; \
+ cfi_restore_state; \
+__LABEL($multi_error) \
+ CDISABLE; \
+ ldq ra, 0(sp); \
+ ldq v0, 8(sp); \
+ addq sp, 64, sp; \
+ cfi_restore(ra); \
+ cfi_def_cfa_offset(0); \
+__LABEL($syscall_error) \
+ SYSCALL_ERROR_HANDLER; \
+ .previous
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ .subsection 2; \
+ cfi_endproc; \
+ .size sym, .-sym
+
+# define SAVE_ARGS_0 /* Nothing. */
+# define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
+# define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
+# define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
+# define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
+# define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
+# define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
+
+# define LOAD_ARGS_0 /* Nothing. */
+# define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
+# define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
+# define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
+# define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
+# define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
+# define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
+
+# ifdef IS_IN_libpthread
+# define __local_enable_asynccancel __pthread_enable_asynccancel
+# define __local_disable_asynccancel __pthread_disable_asynccancel
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define __local_enable_asynccancel __libc_enable_asynccancel
+# define __local_disable_asynccancel __libc_disable_asynccancel
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifdef __PIC__
+# define CENABLE bsr ra, __local_enable_asynccancel !samegp
+# define CDISABLE bsr ra, __local_disable_asynccancel !samegp
+# else
+# define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
+# define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P \
+ __builtin_expect (__local_multiple_threads == 0, 1)
+# elif defined(__PIC__)
+# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
+# else
+# define SINGLE_THREAD_P(reg) \
+ ldah reg, __local_multiple_threads(gp) !gprelhigh; \
+ ldl reg, __local_multiple_threads(reg) !gprellow
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S
new file mode 100644
index 000000000..80fdcc6fb
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+
+#include <sysdep-cancel.h>
+
+ .align 4
+ .globl __vfork
+ .type __vfork, @function
+ .usepv __vfork, std
+ cfi_startproc
+__vfork:
+ ldgp gp, 0(pv)
+ PSEUDO_PROF
+
+#ifdef SHARED
+ ldq t0, __libc_pthread_functions(gp) !gprel
+ bne t0, HIDDEN_JUMPTARGET (fork) !samegp
+#else
+ .weak pthread_create
+ ldq t0, pthread_create(gp) !literal
+ bne t0, $do_fork
+#endif
+
+ lda v0, SYS_ify(vfork)
+ call_pal PAL_callsys
+ bne a3, SYSCALL_ERROR_LABEL
+ ret
+
+#ifndef SHARED
+ /* Can't tail-call due to possible mismatch between GP in
+ fork and vfork object files. */
+$do_fork:
+ subq sp, 16, sp
+ cfi_adjust_cfa_offset(16)
+ stq ra, 0(sp)
+ cfi_offset(ra, -16)
+ jsr ra, HIDDEN_JUMPTARGET (fork)
+ ldgp gp, 0(ra)
+ ldq ra, 0(sp)
+ addq sp, 16, sp
+ cfi_restore(ra)
+ cfi_adjust_cfa_offset(-16)
+ ret
+
+$syscall_error:
+ SYSCALL_ERROR_HANDLER
+#endif
+
+ cfi_endproc
+ .size __vfork, .-__vfork
+
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
new file mode 100644
index 000000000..2c1eba65f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -0,0 +1,129 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+/* We push lr onto the stack, so we have to use ldmib instead of ldmia
+ to find the saved arguments. */
+# ifdef __PIC__
+# undef DOARGS_5
+# undef DOARGS_6
+# undef DOARGS_7
+# define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $8];
+# define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmib ip, {r4, r5};
+# define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmib ip, {r4, r5, r6};
+# endif
+
+# undef PSEUDO_RET
+# define PSEUDO_RET \
+ ldrcc pc, [sp], $4; \
+ ldr lr, [sp], $4; \
+ b PLTJMP(SYSCALL_ERROR)
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ bne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ cmn r0, $4096; \
+ RETINSTR(cc, lr); \
+ b PLTJMP(SYSCALL_ERROR); \
+ .Lpseudo_cancel: \
+ str lr, [sp, $-4]!; \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ swi SYS_ify (syscall_name); /* do the call. */ \
+ str r0, [sp, $-4]!; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ ldr r0, [sp], $4; /* retrieve return value. */ \
+ UNDOC2ARGS_##args; /* fix register damage. */ \
+ cmn r0, $4096;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+# define UNDOC2ARGS_0
+
+# define DOCARGS_1 str r0, [sp, #-4]!;
+# define UNDOCARGS_1 ldr r0, [sp], #4;
+# define UNDOC2ARGS_1
+
+# define DOCARGS_2 str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_2 ldr r0, [sp], #4; ldr r1, [sp], #4;
+# define UNDOC2ARGS_2
+
+# define DOCARGS_3 str r2, [sp, #-4]!; str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_3 ldr r0, [sp], #4; ldr r1, [sp], #4; ldr r2, [sp], #4
+# define UNDOC2ARGS_3
+
+# define DOCARGS_4 stmfd sp!, {r0-r3}
+# define UNDOCARGS_4 ldmfd sp!, {r0-r3}
+# define UNDOC2ARGS_4
+
+# define DOCARGS_5 stmfd sp!, {r0-r3}
+# define UNDOCARGS_5 ldmfd sp, {r0-r3}; str r4, [sp, #-4]!; ldr r4, [sp, #24]
+# define UNDOC2ARGS_5 ldr r4, [sp], #20
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P \
+ ldr ip, =__local_multiple_threads; \
+ ldr ip, [ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S
new file mode 100644
index 000000000..3d9e49a0f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S
@@ -0,0 +1,77 @@
+/* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+#ifdef SHARED
+ ldr ip, 1f
+ ldr r0, 2f
+3: add ip, pc, ip
+ ldr r0, [ip, r0]
+#else
+ ldr r0, 1f
+#endif
+ movs r0, r0
+ bne HIDDEN_JUMPTARGET (fork)
+
+ DO_CALL (vfork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* Check if vfork syscall is known at all. */
+ cmn a1, #ENOSYS
+ bne PLTJMP(C_SYMBOL_NAME(__syscall_error))
+#endif
+
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+ DO_CALL (fork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+#elif !defined __NR_vfork
+# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
+#endif
+ b PLTJMP(C_SYMBOL_NAME(__syscall_error))
+
+#ifdef SHARED
+1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8
+2: .word __libc_pthread_functions(GOTOFF)
+#else
+ .weak pthread_create
+1: .word pthread_create
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c
new file mode 100644
index 000000000..cae12182f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <alloca.h>
+#include <sys/syscall.h>
+
+extern int __syscall_execve(const char *file,
+ char *const *argv,
+ char *const *envp);
+extern void __pthread_kill_other_threads_np(void);
+weak_extern(__pthread_kill_other_threads_np)
+
+int
+__execve(const char *file, char *const argv[], char *const envp[])
+{
+ /* If this is a threaded application kill all other threads. */
+ if (__pthread_kill_other_threads_np)
+ __pthread_kill_other_threads_np();
+ return INLINE_SYSCALL(execve, 3, file, argv, envp);
+}
+weak_alias(__execve, execve)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c
new file mode 100644
index 000000000..8f954d8d9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fork.h>
+#include <bits/libc-lock.h>
+
+struct fork_block __fork_block =
+{
+ .lock = PTHREAD_MUTEX_INITIALIZER,
+ .prepare_list = { &__fork_block.prepare_list, &__fork_block.prepare_list },
+ .parent_list = { &__fork_block.parent_list, &__fork_block.parent_list },
+ .child_list = { &__fork_block.child_list, &__fork_block.child_list }
+};
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h
new file mode 100644
index 000000000..8245d9ef0
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <list.h>
+#include <bits/libc-lock.h>
+
+struct fork_block
+{
+ /* Lock to protect handling of fork handlers. */
+ __libc_lock_define (, lock);
+
+ /* Lists of registered fork handlers. */
+ list_t prepare_list;
+ list_t parent_list;
+ list_t child_list;
+};
+
+extern struct fork_block __fork_block attribute_hidden;
+
+/* Elements of the fork handler lists. */
+struct fork_handler
+{
+ list_t list;
+ void (*handler) (void);
+ void *dso_handle;
+};
+
+
+/* Function to call to unregister fork handlers. */
+extern void __unregister_atfork (void *dso_handle) attribute_hidden;
+#define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
+
+
+/* C library side function to register new fork handlers. */
+extern int __register_atfork (void (*__prepare) (void),
+ void (*__parent) (void),
+ void (*__child) (void),
+ void *dso_handle);
+
+#ifndef ARCH_FORK
+# define ARCH_FORK() __libc_fork()
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/aio_cancel.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/aio_cancel.c
new file mode 100644
index 000000000..0d6da8291
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/aio_cancel.c
@@ -0,0 +1,33 @@
+#include <shlib-compat.h>
+
+#define aio_cancel64 XXX
+#include <aio.h>
+#undef aio_cancel64
+#include <errno.h>
+
+extern __typeof (aio_cancel) __new_aio_cancel;
+extern __typeof (aio_cancel) __old_aio_cancel;
+
+#define aio_cancel __new_aio_cancel
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__new_aio_cancel, __new_aio_cancel64);
+versioned_symbol (librt, __new_aio_cancel, aio_cancel, GLIBC_2_3);
+versioned_symbol (librt, __new_aio_cancel64, aio_cancel64, GLIBC_2_3);
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3)
+
+#undef ECANCELED
+#define aio_cancel __old_aio_cancel
+#define ECANCELED 125
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__old_aio_cancel, __old_aio_cancel64);
+compat_symbol (librt, __old_aio_cancel, aio_cancel, GLIBC_2_1);
+compat_symbol (librt, __old_aio_cancel64, aio_cancel64, GLIBC_2_1);
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h
new file mode 100644
index 000000000..e367fb9d8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h
@@ -0,0 +1,26 @@
+/* PA-RISC specific definitions for spinlock initializers.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* Initial value of a spinlock. PA-RISC only implements atomic load
+ and clear so this must be non-zero. */
+#define __LT_SPINLOCK_INIT 1
+
+/* Macros for lock initializers, using the above definition. */
+#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
+#define __ALT_LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
+#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_INIT }
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h
new file mode 100644
index 000000000..e6b71f441
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h
@@ -0,0 +1,72 @@
+/* HP-PARISC macro definitions for mutexes, thread-specific data
+ and parameters for malloc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MALLOC_MACHINE_H
+#define _MALLOC_MACHINE_H
+
+#undef thread_atfork_static
+
+#include <atomic.h>
+#include <bits/libc-lock.h>
+
+__libc_lock_define (typedef, mutex_t)
+
+/* Since our lock structure does not tolerate being initialized to zero, we must
+ modify the standard function calls made by malloc */
+# define mutex_init(m) \
+ __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
+# define mutex_lock(m) \
+ __libc_maybe_call (__pthread_mutex_lock, (m), \
+ (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
+# define mutex_trylock(m) \
+ __libc_maybe_call (__pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
+# define mutex_unlock(m) \
+ __libc_maybe_call (__pthread_mutex_unlock, (m), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__));
+
+#include <fork.h>
+
+#ifdef SHARED
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, __dso_handle)
+#else
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, \
+ &__dso_handle == NULL ? NULL : __dso_handle)
+#endif
+
+/* thread specific data for glibc */
+
+#include <bits/libc-tsd.h>
+
+typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
+__libc_tsd_define (static, MALLOC) /* declaration/common definition */
+#define tsd_key_create(key, destr) ((void) (key))
+#define tsd_setspecific(key, data) __libc_tsd_set (MALLOC, (data))
+#define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (MALLOC))
+
+#include <sysdeps/generic/malloc-machine.h>
+
+#endif /* !defined(_MALLOC_MACHINE_H) */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c
new file mode 100644
index 000000000..60607ad4f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c
@@ -0,0 +1,108 @@
+/* Special .init and .fini section support for HPPA. Linuxthreads version.
+ Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+/* If we use the standard C version, the linkage table pointer won't
+ be properly preserved due to the splitting up of function prologues
+ and epilogues. Therefore we write these in assembly to make sure
+ they do the right thing. */
+
+__asm__ (
+"#include \"defs.h\"\n"
+"\n"
+"/*@HEADER_ENDS*/\n"
+"\n"
+"/*@_init_PROLOG_BEGINS*/\n"
+" .section .init\n"
+" .align 4\n"
+" .globl _init\n"
+" .type _init,@function\n"
+"_init:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" bl __pthread_initialize_minimal,%rp\n"
+" copy %r19,%r4 /* delay slot */\n"
+" copy %r4,%r19\n"
+"/*@_init_PROLOG_ENDS*/\n"
+"\n"
+"/*@_init_EPILOG_BEGINS*/\n"
+"/* Here is the tail end of _init. */\n"
+" .section .init\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_init:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+"/* Our very own unwind info, because the assembler can't handle\n"
+" functions split into two or more pieces. */\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _init\n"
+" .word _init, _end_init\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_init_EPILOG_ENDS*/\n"
+"\n"
+"/*@_fini_PROLOG_BEGINS*/\n"
+" .section .fini\n"
+" .align 4\n"
+" .globl _fini\n"
+" .type _fini,@function\n"
+"_fini:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" copy %r19,%r4\n"
+"/*@_fini_PROLOG_ENDS*/\n"
+"\n"
+"/*@_fini_EPILOG_BEGINS*/\n"
+" .section .fini\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_fini:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _fini\n"
+" .word _fini, _end_fini\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_fini_EPILOG_ENDS*/\n"
+"\n"
+"/*@TRAILER_BEGINS*/\n"
+);
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
new file mode 100644
index 000000000..8a7bd9705
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
@@ -0,0 +1,188 @@
+/* cancellable system calls for Linux/HPPA.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifndef NO_ERROR
+# define NO_ERROR -0x1000
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ SINGLE_THREAD_P ASM_LINE_SEP \
+ cmpib,<> 0,%ret0,Lpseudo_cancel ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ DO_CALL(syscall_name, args) ASM_LINE_SEP \
+ /* DONE! */ ASM_LINE_SEP \
+ bv 0(2) ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ Lpseudo_cancel: ASM_LINE_SEP \
+ /* store return ptr */ ASM_LINE_SEP \
+ stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
+ /* save syscall args */ ASM_LINE_SEP \
+ PUSHARGS_##args /* MACRO */ ASM_LINE_SEP \
+ STW_PIC ASM_LINE_SEP \
+ CENABLE /* FUNC CALL */ ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* restore syscall args */ ASM_LINE_SEP \
+ POPARGS_##args ASM_LINE_SEP \
+ /* save r4 in arg0 stack slot */ ASM_LINE_SEP \
+ stw %r4, -36(%sr0,%sp) ASM_LINE_SEP \
+ /* save mask from cenable */ ASM_LINE_SEP \
+ copy %ret0, %r4 ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \
+ copy %r4, %r26 ASM_LINE_SEP \
+ copy %ret0, %r4 ASM_LINE_SEP \
+ CDISABLE ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* compare error */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ /* branch if no error */ ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%r4,Lpre_end ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ /* No need to LDW_PIC */ ASM_LINE_SEP \
+ /* make syscall res value positive */ ASM_LINE_SEP \
+ sub %r0, %r4, %r4 ASM_LINE_SEP \
+ /* store into errno location */ ASM_LINE_SEP \
+ stw %r4, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 ASM_LINE_SEP \
+ Lpre_end: ASM_LINE_SEP \
+ ldw -20(%sr0,%sp), %rp ASM_LINE_SEP \
+ /* No need to LDW_PIC */ ASM_LINE_SEP \
+ ldw -36(%sr0,%sp), %r4 ASM_LINE_SEP
+
+/* Save arguments into our frame */
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_5 PUSHARGS_4 /* Args are on the stack... */
+# define PUSHARGS_6 PUSHARGS_5
+
+/* Bring them back from the stack */
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP
+# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP
+# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP
+# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP
+# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP
+# define POPARGS_6 POPARGS_5 ldw -54(%sr0,%sp), %r21 ASM_LINE_SEP
+
+# ifdef IS_IN_libpthread
+# ifdef __PIC__
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# elif !defined NOT_IN_libc
+# ifdef __PIC__
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# else
+# ifdef __PIC__
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# endif
+
+/* p_header.multiple_threads is +12 from the pthread_descr struct start,
+ We could have called __get_cr27() but we really want less overhead */
+# define MULTIPLE_THREADS_OFFSET 0xC
+
+/* cr27 has been initialized to 0x0 by kernel */
+# define NO_THREAD_CR27 0x0
+
+# ifdef IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+ extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+/* This ALT version requires newer kernel support */
+# define SINGLE_THREAD_P_MFCTL \
+ mfctl %cr27, %ret0 ASM_LINE_SEP \
+ cmpib,= NO_THREAD_CR27,%ret0,Lstp ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ ldw MULTIPLE_THREADS_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP \
+ Lstp: ASM_LINE_SEP
+# ifdef __PIC__
+/* Slower version uses GOT to get value of __local_multiple_threads */
+# define SINGLE_THREAD_P \
+ addil LT%__local_multiple_threads, %r19 ASM_LINE_SEP \
+ ldw RT%__local_multiple_threads(%sr0,%r1), %ret0 ASM_LINE_SEP \
+ ldw 0(%sr0,%ret0), %ret0 ASM_LINE_SEP
+# else
+ /* Slow non-pic version using DP */
+# define SINGLE_THREAD_P \
+ addil LR%__local_multiple_threads-$global$,%r27 ASM_LINE_SEP \
+ ldw RR%__local_multiple_threads-$global$(%sr0,%r1),%ret0 ASM_LINE_SEP
+# endif
+# endif
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
+/* !defined NOT_IN_libc || defined IS_IN_libpthread */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
new file mode 100644
index 000000000..d330e664e
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
@@ -0,0 +1,186 @@
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ jne L(pseudo_cancel); \
+ DO_CALL (syscall_name, args); \
+ cmpl $-4095, %eax; \
+ jae SYSCALL_ERROR_LABEL; \
+ ret; \
+ L(pseudo_cancel): \
+ CENABLE \
+ SAVE_OLDTYPE_##args \
+ PUSHCARGS_##args \
+ DOCARGS_##args \
+ movl $SYS_ify (syscall_name), %eax; \
+ int $0x80 \
+ POPCARGS_##args; \
+ POPSTATE_##args \
+ cmpl $-4095, %eax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+# define SAVE_OLDTYPE_0 movl %eax, %ecx;
+# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0
+# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4);
+# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2
+# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2
+# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2
+
+# define PUSHCARGS_0 /* No arguments to push. */
+# define DOCARGS_0 /* No arguments to frob. */
+# define POPCARGS_0 /* No arguments to pop. */
+# define _PUSHCARGS_0 /* No arguments to push. */
+# define _POPCARGS_0 /* No arguments to pop. */
+
+# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0
+# define DOCARGS_1 _DOARGS_1 (4)
+# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx);
+# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebx, 0); _PUSHCARGS_0
+# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (ebx);
+
+# define PUSHCARGS_2 PUSHCARGS_1
+# define DOCARGS_2 _DOARGS_2 (12)
+# define POPCARGS_2 POPCARGS_1
+# define _PUSHCARGS_2 _PUSHCARGS_1
+# define _POPCARGS_2 _POPCARGS_1
+
+# define PUSHCARGS_3 _PUSHCARGS_2
+# define DOCARGS_3 _DOARGS_3 (20)
+# define POPCARGS_3 _POPCARGS_3
+# define _PUSHCARGS_3 _PUSHCARGS_2
+# define _POPCARGS_3 _POPCARGS_2
+
+# define PUSHCARGS_4 _PUSHCARGS_4
+# define DOCARGS_4 _DOARGS_4 (28)
+# define POPCARGS_4 _POPCARGS_4
+# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (esi, 0); _PUSHCARGS_3
+# define _POPCARGS_4 _POPCARGS_3; popl %esi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (esi);
+
+# define PUSHCARGS_5 _PUSHCARGS_5
+# define DOCARGS_5 _DOARGS_5 (36)
+# define POPCARGS_5 _POPCARGS_5
+# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (edi, 0); _PUSHCARGS_4
+# define _POPCARGS_5 _POPCARGS_4; popl %edi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (edi);
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel;
+# define CDISABLE call __pthread_disable_asynccancel
+# elif defined IS_IN_librt
+# ifdef __PIC__
+# define CENABLE pushl %ebx; \
+ call __i686.get_pc_thunk.bx; \
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx; \
+ call __librt_enable_asynccancel@PLT; \
+ popl %ebx;
+# define CDISABLE pushl %ebx; \
+ call __i686.get_pc_thunk.bx; \
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx; \
+ call __librt_disable_asynccancel@PLT; \
+ popl %ebx;
+# else
+# define CENABLE call __librt_enable_asynccancel;
+# define CDISABLE call __librt_disable_asynccancel
+# endif
+# else
+# define CENABLE call __libc_enable_asynccancel;
+# define CDISABLE call __libc_disable_asynccancel
+# endif
+# define POPSTATE_0 \
+ pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \
+ CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4);
+# define POPSTATE_1 POPSTATE_0
+# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \
+ cfi_adjust_cfa_offset (-4);
+# define POPSTATE_3 POPSTATE_2
+# define POPSTATE_4 POPSTATE_3
+# define POPSTATE_5 POPSTATE_4
+
+#if !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+#elif defined IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+#else
+# define __local_multiple_threads __librt_multiple_threads
+#endif
+
+# ifndef __ASSEMBLER__
+# if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ p_header.data.multiple_threads) == 0, 1)
+# else
+extern int __local_multiple_threads
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+ attribute_hidden;
+# else
+ ;
+# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# endif
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads
+# elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__
+# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
+# else
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+# define __SINGLE_THREAD_CMP cmpl $0, __local_multiple_threads@GOTOFF(%ecx)
+# else
+# define __SINGLE_THREAD_CMP \
+ movl __local_multiple_threads@GOT(%ecx), %ecx;\
+ cmpl $0, (%ecx)
+# endif
+# if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__
+# define SINGLE_THREAD_P \
+ SETUP_PIC_REG (cx); \
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
+ __SINGLE_THREAD_CMP
+# else
+# define SINGLE_THREAD_P \
+ call __i686.get_pc_thunk.cx; \
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
+ __SINGLE_THREAD_CMP
+# endif
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
new file mode 100644
index 000000000..83ad9f3b5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
@@ -0,0 +1,94 @@
+/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <bits/kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+# ifdef SHARED
+# if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__
+ SETUP_PIC_REG (cx)
+# else
+ call __i686.get_pc_thunk.cx
+# endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+ cmpl $0, __libc_pthread_functions@GOTOFF(%ecx)
+# else
+ .weak pthread_create
+ movl $pthread_create, %eax
+ testl %eax, %eax
+# endif
+ jne HIDDEN_JUMPTARGET (fork)
+
+ /* Pop the return PC value into ECX. */
+ popl %ecx
+
+ /* Stuff the syscall number in EAX and enter into the kernel. */
+ movl $SYS_ify (vfork), %eax
+ int $0x80
+
+ /* Jump to the return PC. Don't jump directly since this
+ disturbs the branch target cache. Instead push the return
+ address back on the stack. */
+ pushl %ecx
+
+ cmpl $-4095, %eax
+ /* Branch forward if it failed. */
+# ifdef __ASSUME_VFORK_SYSCALL
+ jae SYSCALL_ERROR_LABEL
+.Lpseudo_end:
+# else
+ jae .Lerror
+# endif
+
+ ret
+
+# ifndef __ASSUME_VFORK_SYSCALL
+.Lerror:
+ /* Check if vfork syscall is known at all. */
+ cmpl $-ENOSYS, %eax
+ jne SYSCALL_ERROR_LABEL
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ movl $SYS_ify (fork), %eax
+ int $0x80
+ cmpl $-4095, %eax
+ jae SYSCALL_ERROR_LABEL
+.Lpseudo_end:
+ ret
+#elif !defined __NR_vfork
+# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
+#endif
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
new file mode 100644
index 000000000..ad12181ff
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
@@ -0,0 +1,91 @@
+/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
+ Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* This is the value this implementation supports. */
+#define PTHREAD_THREADS_MAX 16384
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 196608
+
+/* Maximum number of POSIX timers available. */
+#define TIMER_MAX 256
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h
new file mode 100644
index 000000000..88f286145
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <sysdep.h>
+
+#define ARCH_FORK() INLINE_SYSCALL (clone, 2, SIGCHLD, 0)
+
+#include_next <fork.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
new file mode 100644
index 000000000..025566587
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
@@ -0,0 +1,141 @@
+/* Special .init and .fini section support for ia64. LinuxThreads version.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+#include <stddef.h>
+
+#ifdef HAVE_INITFINI_ARRAY
+
+# define INIT_NEW_WAY \
+ ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal)\n"
+# define INIT_OLD_WAY ""
+#else
+# define INIT_NEW_WAY ""
+# define INIT_OLD_WAY \
+ "\n\
+ st8 [r12] = gp, -16\n\
+ br.call.sptk.many b0 = __pthread_initialize_minimal# ;;\n\
+ ;;\n\
+ adds r12 = 16, r12\n\
+ ;;\n\
+ ld8 gp = [r12]\n\
+ ;;\n"
+#endif
+
+__asm__ ("\n\
+\n\
+#include \"defs.h\"\n\
+\n\
+/*@HEADER_ENDS*/\n\
+\n\
+/*@_init_PROLOG_BEGINS*/\n"
+ INIT_NEW_WAY
+ ".section .init\n\
+ .align 16\n\
+ .global _init#\n\
+ .proc _init#\n\
+_init:\n\
+ .prologue\n\
+ .save ar.pfs, r34\n\
+ alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+ .vframe r32\n\
+ mov r32 = r12\n\
+ .save rp, r33\n\
+ mov r33 = b0\n\
+ .body\n\
+ adds r12 = -16, r12\n\
+ ;;\n"
+ INIT_OLD_WAY
+ ".endp _init#\n\
+\n\
+/*@_init_PROLOG_ENDS*/\n\
+\n\
+/*@_init_EPILOG_BEGINS*/\n\
+ .section .init\n\
+ .proc _init#\n\
+_init:\n\
+ .prologue\n\
+ .save ar.pfs, r34\n\
+ .vframe r32\n\
+ .save rp, r33\n\
+ .body\n\
+ mov r12 = r32\n\
+ mov ar.pfs = r34\n\
+ mov b0 = r33\n\
+ br.ret.sptk.many b0\n\
+ .endp _init#\n\
+/*@_init_EPILOG_ENDS*/\n\
+\n\
+/*@_fini_PROLOG_BEGINS*/\n\
+ .section .fini\n\
+ .align 16\n\
+ .global _fini#\n\
+ .proc _fini#\n\
+_fini:\n\
+ .prologue\n\
+ .save ar.pfs, r34\n\
+ alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+ .vframe r32\n\
+ mov r32 = r12\n\
+ .save rp, r33\n\
+ mov r33 = b0\n\
+ .body\n\
+ adds r12 = -16, r12\n\
+ ;;\n\
+ .endp _fini#\n\
+\n\
+/*@_fini_PROLOG_ENDS*/\n\
+\n\
+/*@_fini_EPILOG_BEGINS*/\n\
+ .section .fini\n\
+ .proc _fini#\n\
+_fini:\n\
+ .prologue\n\
+ .save ar.pfs, r34\n\
+ .vframe r32\n\
+ .save rp, r33\n\
+ .body\n\
+ mov r12 = r32\n\
+ mov ar.pfs = r34\n\
+ mov b0 = r33\n\
+ br.ret.sptk.many b0\n\
+ .endp _fini#\n\
+\n\
+/*@_fini_EPILOG_ENDS*/\n\
+\n\
+/*@TRAILER_BEGINS*/\n\
+ .weak __gmon_start__#\n\
+");
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c
new file mode 100644
index 000000000..edb08439a
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c
@@ -0,0 +1,32 @@
+/* Internal sigsuspend system call for LinuxThreads. IA64 version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <linuxthreads/internals.h>
+
+void
+__pthread_sigsuspend (const sigset_t *set)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (rt_sigsuspend, err, 2, set, _NSIG / 8);
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
new file mode 100644
index 000000000..595644044
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -0,0 +1,143 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifdef IS_IN_librt
+# define PSEUDO_NLOCAL 6
+# define PSEUDO_SAVE_GP mov loc5 = gp
+# define PSEUDO_RESTORE_GP mov gp = loc5
+# define PSEUDO_SAVE_GP_1
+# define PSEUDO_RESTORE_GP_1 mov gp = loc5
+# else
+# define PSEUDO_NLOCAL 5
+# define PSEUDO_SAVE_GP
+# define PSEUDO_RESTORE_GP
+# define PSEUDO_SAVE_GP_1 mov loc4 = gp;;
+# define PSEUDO_RESTORE_GP_1 mov gp = loc4
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+.text; \
+ENTRY (name) \
+ adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
+ ld4 r14 = [r14]; \
+ mov r15 = SYS_ify(syscall_name);; \
+ cmp4.ne p6, p7 = 0, r14; \
+(p6) br.cond.spnt .Lpseudo_cancel;; \
+ break __BREAK_SYSCALL;; \
+ cmp.eq p6,p0=-1,r10; \
+(p6) br.cond.spnt.few __syscall_error; \
+ ret;; \
+ .endp name; \
+ .proc __GC_##name; \
+ .globl __GC_##name; \
+ .hidden __GC_##name; \
+__GC_##name: \
+.Lpseudo_cancel: \
+ .prologue; \
+ .regstk args, PSEUDO_NLOCAL, args, 0; \
+ .save ar.pfs, loc0; \
+ alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0; \
+ .save rp, loc1; \
+ mov loc1 = rp; \
+ PSEUDO_SAVE_GP;; \
+ .body; \
+ CENABLE;; \
+ PSEUDO_RESTORE_GP; \
+ mov loc2 = r8; \
+ COPY_ARGS_##args \
+ mov r15 = SYS_ify(syscall_name); \
+ break __BREAK_SYSCALL;; \
+ mov loc3 = r8; \
+ mov loc4 = r10; \
+ mov out0 = loc2; \
+ CDISABLE;; \
+ PSEUDO_RESTORE_GP; \
+ cmp.eq p6,p0=-1,loc4; \
+(p6) br.cond.spnt.few __syscall_error_##args; \
+ mov r8 = loc3; \
+ mov rp = loc1; \
+ mov ar.pfs = loc0; \
+.Lpseudo_end: \
+ ret; \
+ .endp __GC_##name; \
+.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
+ .align 32; \
+ .proc __syscall_error_##args; \
+ .global __syscall_error_##args; \
+ .hidden __syscall_error_##args; \
+ .size __syscall_error_##args, 64; \
+__syscall_error_##args: \
+ .prologue; \
+ .regstk args, PSEUDO_NLOCAL, args, 0; \
+ .save ar.pfs, loc0; \
+ .save rp, loc1; \
+ .body; \
+ PSEUDO_SAVE_GP_1; \
+ br.call.sptk.many b0 = __errno_location;; \
+ st4 [r8] = loc3; \
+ PSEUDO_RESTORE_GP_1; \
+ mov rp = loc1; \
+ mov r8 = -1; \
+ mov ar.pfs = loc0
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) .endp
+
+# ifdef IS_IN_libpthread
+# define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
+# define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
+# elif !defined NOT_IN_libc
+# define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
+# define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
+# else
+# define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
+# define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
+# endif
+
+#define COPY_ARGS_0 /* Nothing */
+#define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
+#define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
+#define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
+#define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
+#define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
+#define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
+#define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S
new file mode 100644
index 000000000..9b5fa767f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S
@@ -0,0 +1,53 @@
+/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+
+#include <sysdep-cancel.h>
+#define _SIGNAL_H
+#include <bits/signum.h>
+
+/* The following are defined in linux/sched.h, which unfortunately */
+/* is not safe for inclusion in an assembly file. */
+#define CLONE_VM 0x00000100 /* set if VM shared between processes */
+#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
+
+/* pid_t vfork(void); */
+/* Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */
+
+ENTRY(__vfork)
+#ifdef SHARED
+ addl r14 = @gprel(__libc_pthread_functions#), gp;;
+#else
+ .weak pthread_create
+ addl r14 = @ltoff(@fptr(pthread_create#)), gp;;
+#endif
+ ld8 r14 = [r14];;
+ cmp.ne p6, p7 = 0, r14
+(p6) br.cond.spnt.few HIDDEN_JUMPTARGET (fork);;
+ alloc r2=ar.pfs,0,0,2,0
+ mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD
+ mov out1=0 /* Standard sp value. */
+ ;;
+ DO_CALL (SYS_ify (clone))
+ cmp.eq p6,p0=-1,r10
+ ;;
+(p6) br.cond.spnt.few __syscall_error
+ ret
+PSEUDO_END(__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c
new file mode 100644
index 000000000..3e04f515f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c
@@ -0,0 +1,34 @@
+/* _longjmp_unwind -- Clean up stack frames unwound by longjmp.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <setjmp.h>
+#include <stddef.h>
+#include <bits/libc-lock.h>
+
+#ifndef SHARED
+weak_extern (__pthread_cleanup_upto);
+#endif
+
+void
+_longjmp_unwind (jmp_buf env, int val)
+{
+ __libc_maybe_call2 (pthread_cleanup_upto,
+ (env->__jmpbuf, __builtin_frame_address (0)),
+ (void) 0);
+}
+libc_hidden_def(_longjmp_unwind)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
new file mode 100644
index 000000000..54b99d688
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ jne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ cmp.l &-4095, %d0; \
+ jcc SYSCALL_ERROR_LABEL; \
+ rts; \
+ .Lpseudo_cancel: \
+ CENABLE; \
+ DOCARGS_##args \
+ move.l %d0, -(%sp); \
+ move.l &SYS_ify (syscall_name), %d0; \
+ trap &0; \
+ move.l %d0, %d2; \
+ CDISABLE; \
+ addq.l &4, %sp; \
+ move.l %d2, %d0; \
+ UNDOCARGS_##args \
+ cmp.l &-4095, %d0; \
+ jcc SYSCALL_ERROR_LABEL
+
+# define DOCARGS_0 move.l %d2, -(%sp);
+# define _DOCARGS_0(n)
+# define UNDOCARGS_0 move.l (%sp)+, %d2;
+
+# define DOCARGS_1 _DOCARGS_1 (4); DOCARGS_0
+# define _DOCARGS_1(n) move.l n(%sp), %d1; _DOARGS_0 (n)
+# define UNDOCARGS_1 UNDOCARGS_0
+
+# define DOCARGS_2 _DOCARGS_2 (8)
+# define _DOCARGS_2(n) move.l %d2, -(%sp); move.l n+4(%sp), %d2; \
+ _DOCARGS_1 (n)
+# define UNDOCARGS_2 UNDOCARGS_1
+
+# define DOCARGS_3 _DOCARGS_3 (12)
+# define _DOCARGS_3(n) move.l %d3, -(%sp); move.l n+4(%sp), %d3; \
+ _DOCARGS_2 (n)
+# define UNDOCARGS_3 UNDOCARGS_2; move.l (%sp)+, %d3;
+
+# define DOCARGS_4 _DOCARGS_4 (16)
+# define _DOCARGS_4(n) move.l %d4, -(%sp); move.l n+4(%sp), %d4; \
+ _DOCARGS_3 (n)
+# define UNDOCARGS_4 UNDOCARGS_3; move.l (%sp)+, %d4;
+
+# define DOCARGS_5 _DOCARGS_5 (20)
+# define _DOCARGS_5(n) move.l %d5, -(%sp); move.l n+4(%sp), %d5; \
+ _DOCARGS_4 (n)
+# define UNDOCARGS_5 UNDOCARGS_4; move.l (%sp)+, %d5;
+
+# ifdef IS_IN_libpthread
+# ifdef __PIC__
+# define CENABLE jbsr __pthread_enable_asynccancel@PLTPC
+# define CDISABLE jbsr __pthread_disable_asynccancel@PLTPC
+# else
+# define CENABLE jbsr __pthread_enable_asynccancel
+# define CDISABLE jbsr __pthread_disable_asynccancel
+# endif
+# elif !defined NOT_IN_libc
+# ifdef __PIC__
+# define CENABLE jbsr __libc_enable_asynccancel@PLTPC
+# define CDISABLE jbsr __libc_disable_asynccancel@PLTPC
+# else
+# define CENABLE jbsr __libc_enable_asynccancel
+# define CDISABLE jbsr __libc_disable_asynccancel
+# endif
+# else
+# ifdef __PIC__
+# define CENABLE jbsr __librt_enable_asynccancel@PLTPC
+# define CDISABLE jbsr __librt_disable_asynccancel@PLTPC
+# else
+# define CENABLE jbsr __librt_enable_asynccancel
+# define CDISABLE jbsr __librt_disable_asynccancel
+# endif
+# endif
+
+# if !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P tst.l __local_multiple_threads
+# else
+# define SINGLE_THREAD_P tst.l (__local_multiple_threads, %pc)
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S
new file mode 100644
index 000000000..2a4d3862c
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S
@@ -0,0 +1,83 @@
+/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <bits/kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef SHARED
+ tstl (__libc_pthread_functions@GOTPC, %pc)
+#else
+ .weak pthread_create
+ movel #pthread_create, %d0
+#endif
+ jbne HIDDEN_JUMPTARGET (fork)
+
+#ifdef __NR_vfork
+
+ /* Pop the return PC value into A0. */
+ movel %sp@+, %a0
+
+ /* Stuff the syscall number in D0 and trap into the kernel. */
+ movel #SYS_ify (vfork), %d0
+ trap #0
+ tstl %d0
+ jmi .Lerror /* Branch forward if it failed. */
+
+ /* Jump to the return PC. */
+ jmp %a0@
+
+.Lerror:
+ /* Push back the return PC. */
+ movel %a0,%sp@-
+
+# ifdef __ASSUME_VFORK_SYSCALL
+# ifndef __PIC__
+ jbra SYSCALL_ERROR_LABEL
+# endif
+# else
+ /* Check if vfork syscall is known at all. */
+ movel #-ENOSYS,%d1
+ cmpl %d0,%d1
+ jne SYSCALL_ERROR_LABEL
+
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ movel #SYS_ify (fork), %d0
+ trap #0
+ tstl %d0
+ jmi SYSCALL_ERROR_LABEL
+ rts
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
new file mode 100644
index 000000000..10c82a61c
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
@@ -0,0 +1,143 @@
+/* system call stubs with cancellation handling. Linux/MIPS version.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Chris Demetriou of Broadcom Corporation,
+ based on work by Guido Guenther <agx@sigxcpu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+#include <sys/asm.h>
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __PIC__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: move a0, v0; \
+ PTR_LA t9,__syscall_error; \
+ /* manual cpreturn. */ \
+ REG_L gp, STKOFF_GP(sp); \
+ RESTORESTK ; \
+ jr t9; \
+ ENTRY (name) \
+ SAVESTK ; \
+ .cpsetup t9, STKOFF_GP, name ; \
+ .set reorder; \
+ SINGLE_THREAD_P(t0); \
+ bne zero, t0, L(pseudo_cancel); \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ /* manual cpreturn. */ \
+ REG_L gp, STKOFF_GP(sp); \
+ RESTORESTK ; \
+ ret; \
+ L(pseudo_cancel): \
+ REG_S ra, STKOFF_RA(sp); \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
+ REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
+ REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
+ CDISABLE; \
+ REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
+ REG_L ra, STKOFF_RA(sp); /* restore return address */ \
+ REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ /* manual cpreturn. */ \
+ REG_L gp, STKOFF_GP(sp); \
+ RESTORESTK ; \
+ L(pseudo_end):
+#endif
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp);
+# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp);
+# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp);
+# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp);
+# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp);
+# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp);
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp);
+# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp);
+# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp);
+# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp);
+# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp);
+# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp);
+
+/* Save an even number of slots. Should be 0 if an even number of slots
+ are used below, or SZREG if an odd number are used. */
+# define STK_PAD SZREG
+
+/* Place values that we are more likely to use later in this sequence, i.e.
+ closer to the SP at function entry. If you do that, the are more
+ likely to already be in your d-cache. */
+# define STKOFF_A5 (STK_PAD)
+# define STKOFF_A4 (STKOFF_A5 + SZREG)
+# define STKOFF_A3 (STKOFF_A4 + SZREG)
+# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */
+# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */
+# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */
+# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */
+# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */
+# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */
+# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */
+# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */
+
+# define STKSPACE (STKOFF_GP + SZREG)
+# define SAVESTK PTR_SUBU sp, STKSPACE
+# define RESTORESTK PTR_ADDU sp, STKSPACE
+
+# ifdef IS_IN_libpthread
+# define CENABLE PTR_LA t9, __pthread_enable_asynccancel; jalr t9;
+# define CDISABLE PTR_LA t9, __pthread_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __pthread_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE PTR_LA t9, __librt_enable_asynccancel; jalr t9;
+# define CDISABLE PTR_LA t9, __librt_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __librt_multiple_threads
+# else
+# define CENABLE PTR_LA t9, __libc_enable_asynccancel; jalr t9;
+# define CDISABLE PTR_LA t9, __libc_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) lw reg, __local_multiple_threads
+#endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
new file mode 100644
index 000000000..4e6dec775
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
@@ -0,0 +1,143 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Guido Guenther <agx@sigxcpu.org>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __PIC__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: move a0, v0; \
+ la t9,__syscall_error; \
+ jr t9; \
+ ENTRY (name) \
+ .set noreorder; \
+ .cpload t9; \
+ .set reorder; \
+ SINGLE_THREAD_P(t0); \
+ bne zero, t0, L(pseudo_cancel); \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ L(pseudo_cancel): \
+ SAVESTK_##args; \
+ sw ra, 28(sp); \
+ sw gp, 32(sp); \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ lw gp, 32(sp); \
+ sw v0, 44(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ sw v0, 36(sp); /* save syscall result */ \
+ sw a3, 40(sp); /* save syscall error flag */ \
+ lw a0, 44(sp); /* pass mask as arg1 */ \
+ CDISABLE; \
+ lw gp, 32(sp); \
+ lw v0, 36(sp); /* restore syscall result */ \
+ lw a3, 40(sp); /* restore syscall error flag */ \
+ lw ra, 28(sp); /* restore return address */ \
+ RESTORESTK; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+#endif
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp);
+# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp);
+# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp);
+# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp);
+# define PUSHARGS_5 PUSHARGS_4 /* handeld by SAVESTK_## */
+# define PUSHARGS_6 PUSHARGS_5
+# define PUSHARGS_7 PUSHARGS_6
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 lw a0, 0(sp);
+# define POPARGS_2 POPARGS_1 lw a1, 4(sp);
+# define POPARGS_3 POPARGS_2 lw a2, 8(sp);
+# define POPARGS_4 POPARGS_3 lw a3, 12(sp);
+# define POPARGS_5 POPARGS_4 /* args already in new stackframe */
+# define POPARGS_6 POPARGS_5
+# define POPARGS_7 POPARGS_6
+
+
+# define STKSPACE 48
+# define SAVESTK_0 subu sp, STKSPACE
+# define SAVESTK_1 SAVESTK_0
+# define SAVESTK_2 SAVESTK_1
+# define SAVESTK_3 SAVESTK_2
+# define SAVESTK_4 SAVESTK_3
+# define SAVESTK_5 lw t0, 16(sp); \
+ subu sp, STKSPACE; \
+ sw t0, 16(sp)
+
+# define SAVESTK_6 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ subu sp, STKSPACE; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp)
+
+# define SAVESTK_7 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ lw t2, 24(sp); \
+ subu sp, STKSPACE; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp); \
+ sw t2, 24(sp)
+
+# define RESTORESTK addu sp, STKSPACE
+
+
+# ifdef IS_IN_libpthread
+# define CENABLE la t9, __pthread_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __pthread_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __pthread_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE la t9, __librt_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __librt_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __librt_multiple_threads
+# else
+# define CENABLE la t9, __libc_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __libc_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) lw reg, __local_multiple_threads
+#endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
new file mode 100644
index 000000000..09dcfa683
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -0,0 +1,104 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* vfork() is just a special case of clone(). */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <asm/unistd.h>
+
+/* int vfork() */
+
+ .text
+LOCALSZ= 1
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(__vfork,FRAMESZ,sp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64 (a5, __vfork)
+#ifdef __PIC__
+ SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+# if (_MIPS_SIM != _ABIO32)
+ PTR_S a5, GPOFF(sp)
+# endif
+ .set noat
+ move $1, ra
+# if (_MIPS_SIM == _ABIO32)
+ subu sp,sp,8
+# endif
+ jal _mcount
+ .set at
+# if (_MIPS_SIM != _ABIO32)
+ PTR_L a5, GPOFF(sp)
+# endif
+#endif
+
+ /* If libpthread is loaded, we need to call fork instead. */
+#ifdef SHARED
+ PTR_L a0, __libc_pthread_functions
+#else
+ .weak pthread_create
+ PTR_LA a0, pthread_create
+#endif
+
+ PTR_ADDU sp, FRAMESZ
+
+ bnez a0, L(call_fork)
+
+ li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
+ move a1, sp
+
+ /* Do the system call */
+ li v0,__NR_clone
+ syscall
+
+ bnez a3,L(error)
+
+ /* Successful return from the parent or child. */
+ RESTORE_GP64
+ ret
+
+ /* Something bad happened -- no child created. */
+L(error):
+ move a0, v0
+#ifdef __PIC__
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+ jr t9
+#else
+ RESTORE_GP64
+ j __syscall_error
+#endif
+
+L(call_fork):
+#ifdef __PIC__
+ PTR_LA t9, fork
+ RESTORE_GP64
+ jr t9
+#else
+ RESTORE_GP64
+ j fork
+#endif
+ END(__vfork)
+
+libc_hidden_def(__vfork)
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c
new file mode 100644
index 000000000..13daefee6
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c
@@ -0,0 +1,284 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contribute by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <not-cancel.h>
+
+
+#ifdef __NR_mq_notify
+
+/* Defined in the kernel headers: */
+#define NOTIFY_COOKIE_LEN 32 /* Length of the cookie used. */
+#define NOTIFY_WOKENUP 1 /* Code for notifcation. */
+#define NOTIFY_REMOVED 2 /* Code for closed message queue
+ of de-notifcation. */
+
+
+/* Data structure for the queued notification requests. */
+union notify_data
+{
+ struct
+ {
+ void (*fct) (union sigval); /* The function to run. */
+ union sigval param; /* The parameter to pass. */
+ pthread_attr_t *attr; /* Attributes to create the thread with. */
+ /* NB: on 64-bit machines the struct as a size of 24 bytes. Which means
+ byte 31 can still be used for returning the status. */
+ };
+ char raw[NOTIFY_COOKIE_LEN];
+};
+
+
+/* Keep track of the initialization. */
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+
+/* The netlink socket. */
+static int netlink_socket = -1;
+
+
+/* Barrier used to make sure data passed to the new thread is not
+ resused by the parent. */
+static pthread_barrier_t notify_barrier;
+
+
+/* Modify the signal mask. We move this into a separate function so
+ that the stack space needed for sigset_t is not deducted from what
+ the thread can use. */
+static int
+__attribute__ ((noinline))
+change_sigmask (int how, sigset_t *oss)
+{
+ sigset_t ss;
+ __sigfillset (&ss);
+ return pthread_sigmask (how, &ss, oss);
+}
+
+
+/* The function used for the notification. */
+static void *
+notification_function (void *arg)
+{
+ /* Copy the function and parameter so that the parent thread can go
+ on with its life. */
+ __volatile__ union notify_data *data = (__volatile__ union notify_data *) arg;
+ void (*fct) (union sigval) = data->fct;
+ union sigval param = data->param;
+
+ /* Let the parent go. */
+ (void) pthread_barrier_wait (&notify_barrier);
+
+ /* Make the thread detached. */
+ (void) pthread_detach (pthread_self ());
+
+ /* The parent thread has all signals blocked. This is probably a
+ bit surprising for this thread. So we unblock all of them. */
+ (void) change_sigmask (SIG_UNBLOCK, NULL);
+
+ /* Now run the user code. */
+ fct (param);
+
+ /* And we are done. */
+ return NULL;
+}
+
+
+/* Helper thread. */
+static void *
+helper_thread (void *arg)
+{
+ while (1)
+ {
+ union notify_data data;
+
+ ssize_t n = recv (netlink_socket, &data, sizeof (data),
+ MSG_NOSIGNAL | MSG_WAITALL);
+ if (n < NOTIFY_COOKIE_LEN)
+ continue;
+
+ if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_WOKENUP)
+ {
+ /* Just create the thread as instructed. There is no way to
+ report a problem with creating a thread. */
+ pthread_t th;
+ if (__builtin_expect (pthread_create (&th, data.attr,
+ notification_function, &data)
+ == 0, 0))
+ /* Since we passed a pointer to DATA to the new thread we have
+ to wait until it is done with it. */
+ (void) pthread_barrier_wait (&notify_barrier);
+ }
+ else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
+ /* The only state we keep is the copy of the thread attributes. */
+ free (data.attr);
+ }
+ return NULL;
+}
+
+
+static void
+reset_once (void)
+{
+ once = PTHREAD_ONCE_INIT;
+}
+
+
+static void
+init_mq_netlink (void)
+{
+ /* This code might be called a second time after fork(). The file
+ descriptor is inherited from the parent. */
+ if (netlink_socket == -1)
+ {
+ /* Just a normal netlink socket, not bound. */
+ netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
+ /* No need to do more if we have no socket. */
+ if (netlink_socket == -1)
+ return;
+
+ /* Make sure the descriptor is closed on exec. */
+ fcntl (netlink_socket, F_SETFD, FD_CLOEXEC);
+ }
+
+ int err = 1;
+
+ /* Initialize the barrier. */
+ if (__builtin_expect (pthread_barrier_init (&notify_barrier, NULL, 2) == 0,
+ 0))
+ {
+ /* Create the helper thread. */
+ pthread_attr_t attr;
+ (void) pthread_attr_init (&attr);
+ (void) pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ /* We do not need much stack space, the bare minimum will be enough. */
+ (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+
+ /* Temporarily block all signals so that the newly created
+ thread inherits the mask. */
+ sigset_t oss;
+ int have_no_oss = change_sigmask (SIG_BLOCK, &oss);
+
+ pthread_t th;
+ err = pthread_create (&th, &attr, helper_thread, NULL);
+
+ /* Reset the signal mask. */
+ if (!have_no_oss)
+ pthread_sigmask (SIG_SETMASK, &oss, NULL);
+
+ (void) pthread_attr_destroy (&attr);
+
+ if (err == 0)
+ {
+ static smallint added_atfork;
+
+ if (added_atfork == 0
+ && pthread_atfork (NULL, NULL, reset_once) != 0)
+ {
+ /* The child thread will call recv() which is a
+ cancellation point. */
+ (void) pthread_cancel (th);
+ err = 1;
+ }
+ else
+ added_atfork = 1;
+ }
+ }
+
+ if (err != 0)
+ {
+ close_not_cancel_no_status (netlink_socket);
+ netlink_socket = -1;
+ }
+}
+
+
+/* Register notification upon message arrival to an empty message queue
+ MQDES. */
+int
+mq_notify (mqd_t mqdes, const struct sigevent *notification)
+{
+ /* Make sure the type is correctly defined. */
+ assert (sizeof (union notify_data) == NOTIFY_COOKIE_LEN);
+
+ /* Special treatment needed for SIGEV_THREAD. */
+ if (notification == NULL || notification->sigev_notify != SIGEV_THREAD)
+ return INLINE_SYSCALL (mq_notify, 2, mqdes, notification);
+
+ /* The kernel cannot directly start threads. This will have to be
+ done at userlevel. Since we cannot start threads from signal
+ handlers we have to create a dedicated thread which waits for
+ notifications for arriving messages and creates threads in
+ response. */
+
+ /* Initialize only once. */
+ pthread_once (&once, init_mq_netlink);
+
+ /* If we cannot create the netlink socket we cannot provide
+ SIGEV_THREAD support. */
+ if (__builtin_expect (netlink_socket == -1, 0))
+ {
+ __set_errno (ENOSYS);
+ return -1;
+ }
+
+ /* Create the cookie. It will hold almost all the state. */
+ union notify_data data;
+ memset (&data, '\0', sizeof (data));
+ data.fct = notification->sigev_notify_function;
+ data.param = notification->sigev_value;
+
+ if (notification->sigev_notify_attributes != NULL)
+ {
+ /* The thread attribute has to be allocated separately. */
+ data.attr = (pthread_attr_t *) malloc (sizeof (pthread_attr_t));
+ if (data.attr == NULL)
+ return -1;
+
+ memcpy (data.attr, notification->sigev_notify_attributes,
+ sizeof (pthread_attr_t));
+ }
+
+ /* Construct the new request. */
+ struct sigevent se;
+ se.sigev_notify = SIGEV_THREAD;
+ se.sigev_signo = netlink_socket;
+ se.sigev_value.sival_ptr = &data;
+
+ /* Tell the kernel. */
+ int retval = INLINE_SYSCALL (mq_notify, 2, mqdes, &se);
+
+ /* If it failed, free the allocated memory. */
+ if (__builtin_expect (retval != 0, 0))
+ free (data.attr);
+
+ return retval;
+}
+
+#else
+# include <rt/mq_notify.c>
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
new file mode 100644
index 000000000..6c3dc12a0
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -0,0 +1,158 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ bne- .Lpseudo_cancel; \
+ DO_CALL (SYS_ify (syscall_name)); \
+ PSEUDO_RET; \
+ .Lpseudo_cancel: \
+ stwu 1,-48(1); \
+ mflr 9; \
+ stw 9,52(1); \
+ CGOTSETUP; \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ stw 3,16(1); /* store CENABLE return value (MASK). */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ DO_CALL (SYS_ify (syscall_name)); \
+ mfcr 0; /* save CR/R3 around CDISABLE. */ \
+ stw 3,8(1); \
+ stw 0,12(1); \
+ lwz 3,16(1); /* pass MASK to CDISABLE. */ \
+ CDISABLE; \
+ lwz 4,52(1); \
+ lwz 0,12(1); /* restore CR/R3. */ \
+ lwz 3,8(1); \
+ CGOTRESTORE; \
+ mtlr 4; \
+ mtcr 0; \
+ addi 1,1,48;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+
+# define DOCARGS_1 stw 3,20(1); DOCARGS_0
+# define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0
+
+# define DOCARGS_2 stw 4,24(1); DOCARGS_1
+# define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1
+
+# define DOCARGS_3 stw 5,28(1); DOCARGS_2
+# define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2
+
+# define DOCARGS_4 stw 6,32(1); DOCARGS_3
+# define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3
+
+# define DOCARGS_5 stw 7,36(1); DOCARGS_4
+# define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4
+
+# define DOCARGS_6 stw 8,40(1); DOCARGS_5
+# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
+
+# define CGOTSETUP
+# define CGOTRESTORE
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl __pthread_enable_asynccancel@local
+# define CDISABLE bl __pthread_disable_asynccancel@local
+# elif !defined NOT_IN_libc
+# define CENABLE bl __libc_enable_asynccancel@local
+# define CDISABLE bl __libc_disable_asynccancel@local
+# else
+# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
+# if defined HAVE_AS_REL16 && defined __PIC__
+# undef CGOTSETUP
+# define CGOTSETUP \
+ bcl 20,31,1f; \
+ 1: stw 30,44(1); \
+ mflr 30; \
+ addis 30,30,_GLOBAL_OFFSET_TABLE-1b@ha; \
+ addi 30,30,_GLOBAL_OFFSET_TABLE-1b@l
+# undef CGOTRESTORE
+# define CGOTRESTORE \
+ lwz 30,44(1)
+# endif
+# endif
+
+# ifdef HAVE_TLS_SUPPORT
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ lwz 10,MULTIPLE_THREADS_OFFSET(2); \
+ cmpwi 10,0
+# endif
+# else
+# if !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P \
+ lis 10,__local_multiple_threads@ha; \
+ lwz 10,__local_multiple_threads@l(10); \
+ cmpwi 10,0
+# else
+# ifdef HAVE_ASM_PPC_REL16
+# define SINGLE_THREAD_P \
+ mflr 9; \
+ bcl 20,31,1f; \
+1:mflr 10; \
+ addis 10,10,__local_multiple_threads-1b@ha; \
+ lwz 10,__local_multiple_threads-1b@l(10); \
+ mtlr 9; \
+ cmpwi 10,0
+# else
+# define SINGLE_THREAD_P \
+ mflr 9; \
+ bl _GLOBAL_OFFSET_TABLE_@local-4; \
+ mflr 10; \
+ mtlr 9; \
+ lwz 10,__local_multiple_threads@got(10); \
+ lwz 10,0(10); \
+ cmpwi 10,0
+# endif
+# endif
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
new file mode 100644
index 000000000..4b16829be
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
@@ -0,0 +1,85 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <bits/kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+# ifdef SHARED
+ mflr 9
+# ifdef HAVE_ASM_PPC_REL16
+ bcl 20,31,1f
+1: mflr 10
+ addis 10,10,__libc_pthread_functions-1b@ha
+ lwz 10,__libc_pthread_functions-1b@l(10)
+ mtlr 9
+# else
+ bl _GLOBAL_OFFSET_TABLE_@local-4
+ mflr 10
+ mtlr 9
+ lwz 10,__libc_pthread_functions@got(10)
+ lwz 10,0(10)
+# endif
+# else
+ .weak pthread_create
+ lis 10,pthread_create@ha
+ la 10,pthread_create@l(10)
+# endif
+
+ cmpwi 10,0
+ bne- .Lhidden_fork
+
+ DO_CALL (SYS_ify (vfork));
+
+# ifdef __ASSUME_VFORK_SYSCALL
+ PSEUDO_RET
+# else
+ bnslr+
+ /* Check if vfork syscall is known at all. */
+ cmpwi r3,ENOSYS
+ bne- .Lsyscall_error
+
+# endif
+
+.Lhidden_fork:
+ b HIDDEN_JUMPTARGET(fork)
+
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ DO_CALL (SYS_ify (fork));
+ bnslr+
+
+.Lsyscall_error:
+ b __syscall_error@local
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
new file mode 100644
index 000000000..901982ec8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
@@ -0,0 +1,126 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ bne- .Lpseudo_cancel; \
+ DO_CALL (SYS_ify (syscall_name)); \
+ PSEUDO_RET; \
+ .Lpseudo_cancel: \
+ stdu 1,-128(1); \
+ mflr 9; \
+ std 9,128+16(1); \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ std 3,72(1); /* store CENABLE return value (MASK). */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ DO_CALL (SYS_ify (syscall_name)); \
+ mfcr 0; /* save CR/R3 around CDISABLE. */ \
+ std 3,64(1); \
+ std 0,8(1); \
+ ld 3,72(1); /* pass MASK to CDISABLE. */ \
+ CDISABLE; \
+ ld 9,128+16(1); \
+ ld 0,8(1); /* restore CR/R3. */ \
+ ld 3,64(1); \
+ mtlr 9; \
+ mtcr 0; \
+ addi 1,1,128;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+
+# define DOCARGS_1 std 3,80(1); DOCARGS_0
+# define UNDOCARGS_1 ld 3,80(1); UNDOCARGS_0
+
+# define DOCARGS_2 std 4,88(1); DOCARGS_1
+# define UNDOCARGS_2 ld 4,88(1); UNDOCARGS_1
+
+# define DOCARGS_3 std 5,96(1); DOCARGS_2
+# define UNDOCARGS_3 ld 5,96(1); UNDOCARGS_2
+
+# define DOCARGS_4 std 6,104(1); DOCARGS_3
+# define UNDOCARGS_4 ld 6,104(1); UNDOCARGS_3
+
+# define DOCARGS_5 std 7,112(1); DOCARGS_4
+# define UNDOCARGS_5 ld 7,112(1); UNDOCARGS_4
+
+# define DOCARGS_6 std 8,120(1); DOCARGS_5
+# define UNDOCARGS_6 ld 8,120(1); UNDOCARGS_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop
+# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifdef HAVE_TLS_SUPPORT
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ lwz 10,MULTIPLE_THREADS_OFFSET(13); \
+ cmpwi 10,0
+# endif
+# else /* !HAVE_TLS_SUPPORT */
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+ attribute_hidden;
+# else
+ ;
+# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ .section ".toc","aw"; \
+.LC__local_multiple_threads:; \
+ .tc __local_multiple_threads[TC],__local_multiple_threads; \
+ .previous; \
+ ld 10,.LC__local_multiple_threads@toc(2); \
+ lwz 10,0(10); \
+ cmpwi 10,0
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
new file mode 100644
index 000000000..47c91dfd4
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
@@ -0,0 +1,90 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <bits/kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+#ifdef SHARED
+ .section ".toc","aw"
+.LC0:
+ .tc __libc_pthread_functions[TC],__libc_pthread_functions
+ .section ".text"
+ .align 2
+#endif
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+# ifdef SHARED
+ ld 10,.LC0@toc(2)
+ ld 10,0(10)
+ cmpwi 10,0
+ bne- HIDDEN_JUMPTARGET(fork)
+# else
+ .weak pthread_create
+ lis 10,pthread_create@highest
+ ori 10,10,pthread_create@higher
+ sldi 10,10,32
+ oris 10,10,pthread_create@h
+ ori 10,10,pthread_create@l
+ cmpwi 10,0
+ bne- .Lhidden_fork
+# endif
+
+ DO_CALL (SYS_ify (vfork));
+
+# ifdef __ASSUME_VFORK_SYSCALL
+ PSEUDO_RET
+# else
+ bnslr+
+ /* Check if vfork syscall is known at all. */
+ cmpdi r3,ENOSYS
+# ifdef SHARED
+ bne JUMPTARGET(__syscall_error)
+# else
+ bne- .Lsyscall_error
+# endif
+
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ DO_CALL (SYS_ify (fork));
+ PSEUDO_RET
+#endif
+
+# ifndef SHARED
+.Lhidden_fork:
+ b HIDDEN_JUMPTARGET(fork)
+.Lsyscall_error:
+ b JUMPTARGET(__syscall_error)
+# endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/ptlongjmp.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/ptlongjmp.c
new file mode 100644
index 000000000..177256c7f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/ptlongjmp.c
@@ -0,0 +1,70 @@
+/* Linuxthreads - a simple clone()-based implementation of Posix */
+/* threads for Linux. */
+/* Copyright (C) 1998 Xavier Leroy (Xavier.Leroy@inria.fr) */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
+/* GNU Library General Public License for more details. */
+
+/* Redefine siglongjmp and longjmp so that they interact correctly
+ with cleanup handlers */
+/* Derived from linuxthreads/ptlongjmp.c & added AltiVec/VMX versioning. */
+#include "pthread.h"
+#include <setjmp.h>
+#include <bits/wordsize.h>
+#include <shlib-compat.h>
+#if defined SHARED
+# if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_3_4)
+
+/* These functions are not declared anywhere since they shouldn't be
+ used at another place but here. */
+extern void __novmx__libc_siglongjmp (sigjmp_buf env, int val)
+ __attribute__ ((noreturn));
+extern void __novmx__libc_longjmp (sigjmp_buf env, int val)
+ __attribute__ ((noreturn));
+
+
+void __novmx_siglongjmp (sigjmp_buf env, int val)
+{
+ __novmx__libc_siglongjmp (env, val);
+}
+
+void __novmx_longjmp (jmp_buf env, int val)
+{
+ __novmx__libc_longjmp (env, val);
+}
+
+# if __WORDSIZE == 64
+symbol_version (__novmx_longjmp,longjmp,GLIBC_2.3);
+symbol_version (__novmx_siglongjmp,siglongjmp,GLIBC_2.3);
+# else
+symbol_version (__novmx_longjmp,longjmp,GLIBC_2.0);
+symbol_version (__novmx_siglongjmp,siglongjmp,GLIBC_2.0);
+# endif
+# endif /* SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_3_4) ) */
+
+/* These functions are not declared anywhere since they shouldn't be
+ used at another place but here. */
+extern void __vmx__libc_siglongjmp (sigjmp_buf env, int val)
+ __attribute__ ((noreturn));
+extern void __vmx__libc_longjmp (sigjmp_buf env, int val)
+ __attribute__ ((noreturn));
+
+void __vmx_siglongjmp (sigjmp_buf env, int val)
+{
+ __vmx__libc_siglongjmp (env, val);
+}
+
+void __vmx_longjmp (jmp_buf env, int val)
+{
+ __vmx__libc_longjmp (env, val);
+}
+default_symbol_version (__vmx_longjmp,longjmp,GLIBC_2.3.4);
+default_symbol_version (__vmx_siglongjmp,siglongjmp,GLIBC_2.3.4);
+#endif /* SHARED */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
new file mode 100644
index 000000000..83f678c8b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
@@ -0,0 +1,32 @@
+/* Internal sigsuspend system call for LinuxThreads. Generic Linux version.
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <sys/syscall.h>
+#include <linuxthreads/internals.h>
+
+#include <bits/kernel-features.h>
+
+void
+__pthread_sigsuspend (const sigset_t *set)
+{
+ sigsuspend(set);
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c
new file mode 100644
index 000000000..1e11a4812
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1996, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <unistd.h>
+
+#ifndef IS_IN_rtld
+# include <bits/libc-lock.h>
+
+# ifndef SHARED
+weak_extern (__pthread_raise)
+# endif
+#endif
+
+/* Raise the signal SIG. */
+int
+raise (sig)
+ int sig;
+{
+#ifdef IS_IN_rtld
+ return __kill (__getpid (), sig);
+#else
+ return __libc_maybe_call2 (pthread_raise, (sig),
+ __kill (__getpid (), sig));
+#endif
+}
+libc_hidden_def (raise)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c
new file mode 100644
index 000000000..338d421e3
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include "fork.h"
+
+
+int
+__register_atfork (prepare, parent, child, dso_handle)
+ void (*prepare) (void);
+ void (*parent) (void);
+ void (*child) (void);
+ void *dso_handle;
+{
+ struct fork_handler *new_prepare = NULL;
+ struct fork_handler *new_parent = NULL;
+ struct fork_handler *new_child = NULL;
+
+ if (prepare != NULL)
+ {
+ new_prepare = (struct fork_handler *) malloc (sizeof (*new_prepare));
+ if (new_prepare == NULL)
+ goto out1;
+
+ new_prepare->handler = prepare;
+ new_prepare->dso_handle = dso_handle;
+ }
+
+ if (parent != NULL)
+ {
+ new_parent = (struct fork_handler *) malloc (sizeof (*new_parent));
+ if (new_parent == NULL)
+ goto out2;
+
+ new_parent->handler = parent;
+ new_parent->dso_handle = dso_handle;
+ }
+
+ if (child != NULL)
+ {
+ new_child = (struct fork_handler *) malloc (sizeof (*new_child));
+ if (new_child == NULL)
+ {
+ free (new_parent);
+ out2:
+ free (new_prepare);
+ out1:
+ return errno;
+ }
+
+ new_child->handler = child;
+ new_child->dso_handle = dso_handle;
+ }
+
+ /* Get the lock to not conflict with running forks. */
+ __libc_lock_lock (__fork_block.lock);
+
+ /* Now that we have all the handlers allocate enqueue them. */
+ if (new_prepare != NULL)
+ list_add_tail (&new_prepare->list, &__fork_block.prepare_list);
+ if (new_parent != NULL)
+ list_add_tail (&new_parent->list, &__fork_block.parent_list);
+ if (new_child != NULL)
+ list_add_tail (&new_child->list, &__fork_block.child_list);
+
+ /* Release the lock. */
+ __libc_lock_unlock (__fork_block.lock);
+
+ return 0;
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c
new file mode 100644
index 000000000..500fff091
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c
@@ -0,0 +1,142 @@
+/* Special .init and .fini section support for SH. Linuxthread version.
+ Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+__asm__ ("\n\
+\n\
+#include \"defs.h\"\n\
+\n\
+/*@HEADER_ENDS*/\n\
+\n\
+/*@TESTS_BEGIN*/\n\
+\n\
+/*@TESTS_END*/\n\
+\n\
+/*@_init_PROLOG_BEGINS*/\n\
+ .section .init\n\
+ .align 5\n\
+ .global _init\n\
+ .type _init,@function\n\
+_init:\n\
+ mov.l r12,@-r15\n\
+ mov.l r14,@-r15\n\
+ sts.l pr,@-r15\n\
+ mova .L22,r0\n\
+ mov.l .L22,r12\n\
+ add r0,r12\n\
+ mova .L24,r0\n\
+ mov.l .L24,r1\n\
+ add r0,r1\n\
+ jsr @r1\n\
+ nop\n\
+ mova .L23,r0\n\
+ mov.l .L23,r1\n\
+ add r0,r1\n\
+ jsr @r1\n\
+ mov r15,r14\n\
+ bra 1f\n\
+ nop\n\
+ .align 2\n\
+.L22:\n\
+ .long _GLOBAL_OFFSET_TABLE_\n\
+.L23:\n\
+ .long __gmon_start__@PLT\n\
+.L24:\n\
+ .long __pthread_initialize_minimal@PLT\n\
+1:\n\
+ ALIGN\n\
+ END_INIT\n\
+\n\
+/*@_init_PROLOG_ENDS*/\n\
+\n\
+/*@_init_EPILOG_BEGINS*/\n\
+ .section .init\n\
+ mov r14,r15\n\
+ lds.l @r15+,pr\n\
+ mov.l @r15+,r14\n\
+ rts \n\
+ mov.l @r15+,r12\n\
+ END_INIT\n\
+ .section .text\n\
+ .align 5\n\
+ .weak __gmon_start__\n\
+ .type __gmon_start__,@function\n\
+__gmon_start__:\n\
+ mov.l r14,@-r15\n\
+ mov r15,r14\n\
+ mov r14,r15\n\
+ rts \n\
+ mov.l @r15+,r14\n\
+ \n\
+/*@_init_EPILOG_ENDS*/\n\
+\n\
+/*@_fini_PROLOG_BEGINS*/\n\
+ .section .fini\n\
+ .align 5\n\
+ .global _fini\n\
+ .type _fini,@function\n\
+_fini:\n\
+ mov.l r12,@-r15\n\
+ mov.l r14,@-r15\n\
+ sts.l pr,@-r15\n\
+ mova .L27,r0\n\
+ mov.l .L27,r12\n\
+ add r0,r12\n\
+ mov r15,r14\n\
+ ALIGN\n\
+ END_FINI\n\
+ bra 1f\n\
+ nop\n\
+ .align 2\n\
+.L27:\n\
+ .long _GLOBAL_OFFSET_TABLE_\n\
+1:\n\
+/*@_fini_PROLOG_ENDS*/\n\
+\n\
+/*@_fini_EPILOG_BEGINS*/\n\
+ .section .fini\n\
+ mov r14,r15\n\
+ lds.l @r15+,pr\n\
+ mov.l @r15+,r14\n\
+ rts \n\
+ mov.l @r15+,r12\n\
+\n\
+ END_FINI\n\
+ \n\
+/*@_fini_EPILOG_ENDS*/\n\
+\n\
+/*@TRAILER_BEGINS*/\n\
+");
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
new file mode 100644
index 000000000..7d8ced7d7
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
@@ -0,0 +1,23 @@
+/* Determine whether the host has multiple processors. SH version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+static __inline__ int
+is_smp_system (void)
+{
+ return 0;
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
new file mode 100644
index 000000000..58c726b20
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -0,0 +1,226 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# define _IMM12 #-12
+# define _IMM16 #-16
+# define _IMP16 #16
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ bf .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ mov r0,r1; \
+ mov _IMM12,r2; \
+ shad r2,r1; \
+ not r1,r1; \
+ tst r1,r1; \
+ bt .Lsyscall_error; \
+ bra .Lpseudo_end; \
+ nop; \
+ .Lpseudo_cancel: \
+ sts.l pr,@-r15; \
+ add _IMM16,r15; \
+ SAVE_ARGS_##args; \
+ CENABLE; \
+ LOAD_ARGS_##args; \
+ add _IMP16,r15; \
+ lds.l @r15+,pr; \
+ DO_CALL(syscall_name, args); \
+ SYSCALL_INST_PAD; \
+ sts.l pr,@-r15; \
+ mov.l r0,@-r15; \
+ CDISABLE; \
+ mov.l @r15+,r0; \
+ lds.l @r15+,pr; \
+ mov r0,r1; \
+ mov _IMM12,r2; \
+ shad r2,r1; \
+ not r1,r1; \
+ tst r1,r1; \
+ bf .Lpseudo_end; \
+ .Lsyscall_error: \
+ SYSCALL_ERROR_HANDLER; \
+ .Lpseudo_end:
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ END (sym)
+
+# define SAVE_ARGS_0 /* Nothing. */
+# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15)
+# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15)
+# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15)
+# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15)
+# define SAVE_ARGS_5 SAVE_ARGS_4
+# define SAVE_ARGS_6 SAVE_ARGS_5
+
+# define LOAD_ARGS_0 /* Nothing. */
+# define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4
+# define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5
+# define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6
+# define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7
+# define LOAD_ARGS_5 LOAD_ARGS_4
+# define LOAD_ARGS_6 LOAD_ARGS_5
+
+# ifdef IS_IN_libpthread
+# define __local_enable_asynccancel __pthread_enable_asynccancel
+# define __local_disable_asynccancel __pthread_disable_asynccancel
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_enable_asynccancel __libc_enable_asynccancel
+# define __local_disable_asynccancel __libc_disable_asynccancel
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_enable_asynccancel __librt_enable_asynccancel
+# define __local_disable_asynccancel __librt_disable_asynccancel
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# if defined IS_IN_librt && defined __PIC__
+# define CENABLE \
+ mov.l r12,@-r15; \
+ mov.l 1f,r12; \
+ mova 1f,r0; \
+ add r0,r12; \
+ mov.l 2f,r0; \
+ bsrf r0; \
+ nop; \
+ 0: bra 3f; \
+ mov r0,r2; \
+ .align 2; \
+ 1: .long _GLOBAL_OFFSET_TABLE_; \
+ 2: .long __local_enable_asynccancel@PLT - (0b-.); \
+ 3: mov.l @r15+,r12
+
+# define CDISABLE \
+ mov.l r12,@-r15; \
+ mov.l 1f,r12; \
+ mova 1f,r0; \
+ add r0,r12; \
+ mov.l 2f,r0; \
+ bsrf r0; \
+ mov r2,r4; \
+ 0: bra 3f; \
+ nop; \
+ .align 2; \
+ 1: .long _GLOBAL_OFFSET_TABLE_; \
+ 2: .long __local_disable_asynccancel@PLT - (0b-.); \
+ 3: mov.l @r15+,r12
+# else
+# define CENABLE \
+ mov.l 1f,r0; \
+ bsrf r0; \
+ nop; \
+ 0: bra 2f; \
+ mov r0,r2; \
+ .align 2; \
+ 1: .long __local_enable_asynccancel - 0b; \
+ 2:
+
+# define CDISABLE \
+ mov.l 1f,r0; \
+ bsrf r0; \
+ mov r2,r4; \
+ 0: bra 2f; \
+ nop; \
+ .align 2; \
+ 1: .long __local_disable_asynccancel - 0b; \
+ 2:
+# endif
+
+# ifndef __ASSEMBLER__
+# if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
+# else
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# endif
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P \
+ mov.l 1f,r0; \
+ mov.l @r0,r0; \
+ bra 2f; \
+ tst r0,r0; \
+ .align 2; \
+ 1: .long __local_multiple_threads; \
+ 2:
+# elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__
+# define SINGLE_THREAD_P \
+ stc gbr,r0; \
+ mov.w 0f,r1; \
+ sub r1,r0; \
+ mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \
+ bra 1f; \
+ tst r0,r0; \
+ 0: .word TLS_PRE_TCB_SIZE; \
+ 1:
+
+# else
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+# define SINGLE_THREAD_P \
+ mov r12,r2; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ mov.l 1f,r0; \
+ mov.l @(r0,r12),r0; \
+ mov r2,r12; \
+ bra 2f; \
+ tst r0,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_; \
+ 1: .long __local_multiple_threads@GOTOFF; \
+ 2:
+# else
+# define SINGLE_THREAD_P \
+ mov r12,r2; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ mov.l 1f,r0; \
+ mov.l @(r0,r12),r0; \
+ mov.l @r0,r0; \
+ mov r2,r12; \
+ bra 2f; \
+ tst r0,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_; \
+ 1: .long __local_multiple_threads@GOT; \
+ 2:
+# endif
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S
new file mode 100644
index 000000000..90733119e
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -0,0 +1,77 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <sys/syscall.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+#ifdef SHARED
+ mov.l .Lgot, r1
+ mova .Lgot, r0
+ add r0, r1
+ mov.l .Lpthread_func, r0
+ mov.l @(r0,r1), r0
+#else
+ mov.l .Lpthread_create, r0
+#endif
+ tst r0, r0
+ bf .Lhidden_fork
+
+ mov.w .L1, r3
+ trapa #__SH_SYSCALL_TRAP_BASE
+ mov r0, r1
+ mov #-12, r2
+ shad r2, r1
+ not r1, r1 /* r1=0 means r0 = -1 to -4095 */
+ tst r1, r1 /* i.e. error in linux */
+ bf .Lpseudo_end
+ SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
+ rts
+ nop
+.L1: .word __NR_vfork
+ .align 2
+#ifdef SHARED
+.Lgot:
+ .long _GLOBAL_OFFSET_TABLE_
+.Lpthread_func:
+ .long __libc_pthread_functions@GOTOFF
+#else
+.Lpthread_create:
+ .weak pthread_create
+ .long pthread_create
+#endif
+
+.Lhidden_fork:
+ mov.l .L2, r1
+ braf r1
+ nop
+1:
+ .align 2
+.L2: .long HIDDEN_JUMPTARGET(fork)-1b
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c
new file mode 100644
index 000000000..2e09d1ba5
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#define __need_NULL
+#include <stddef.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bits/libc-lock.h>
+
+extern int __syscall_rt_sigtimedwait (const sigset_t *, siginfo_t *,
+ const struct timespec *, size_t);
+
+
+/* Return any pending signal or wait for one for the given time. */
+static __inline__ int
+do_sigwait (const sigset_t *set, int *sig)
+{
+ int ret;
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+#ifdef INTERNAL_SYSCALL
+ INTERNAL_SYSCALL_DECL (err);
+ ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set,
+ NULL, NULL, _NSIG / 8);
+ if (! INTERNAL_SYSCALL_ERROR_P (ret, err))
+ {
+ *sig = ret;
+ ret = 0;
+ }
+ else
+ ret = INTERNAL_SYSCALL_ERRNO (ret, err);
+#else
+ ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set,
+ NULL, NULL, _NSIG / 8);
+ if (ret != -1)
+ {
+ *sig = ret;
+ ret = 0;
+ }
+ else
+ ret = errno;
+#endif
+
+ return ret;
+}
+
+#ifndef SHARED
+weak_extern (__pthread_sigwait)
+#endif
+
+int
+sigwait (const sigset_t *set, int *sig)
+{
+#ifndef NOT_IN_libc
+ return __libc_maybe_call2 (pthread_sigwait, (set, sig),
+ do_sigwait (set, sig));
+#else
+ return do_sigwait (set, sig);
+#endif
+}
+strong_alias(sigwait, __libc_sigwait)
+
+/* Cancellation is handled in __pthread_sigwait. */
+LIBC_CANCEL_HANDLED ();
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h
new file mode 100644
index 000000000..6f03b9d55
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h
@@ -0,0 +1,47 @@
+/* Determine whether the host has multiple processors. Linux version.
+ Copyright (C) 1996, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+#include <sys/sysctl.h>
+
+/* Test whether the machine has more than one processor. This is not the
+ best test but good enough. More complicated tests would require `malloc'
+ which is not available at that time. */
+static __inline__ int
+is_smp_system (void)
+{
+ static const int sysctl_args[] = { CTL_KERN, KERN_VERSION };
+ char buf[512];
+ size_t reslen = sizeof (buf);
+
+ /* Try reading the number using `sysctl' first. */
+ if (__sysctl ((int *) sysctl_args,
+ sizeof (sysctl_args) / sizeof (sysctl_args[0]),
+ buf, &reslen, NULL, 0) < 0)
+ {
+ /* This was not successful. Now try reading the /proc filesystem. */
+ int fd = __open ("/proc/sys/kernel/version", O_RDONLY);
+ if (__builtin_expect (fd, 0) == -1
+ || (reslen = __read (fd, buf, sizeof (buf))) <= 0)
+ /* This also didn't work. We give up and say it's a UP machine. */
+ buf[0] = '\0';
+
+ __close (fd);
+ }
+
+ return strstr (buf, "SMP") != NULL;
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/aio_cancel.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/aio_cancel.c
new file mode 100644
index 000000000..0d6da8291
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/aio_cancel.c
@@ -0,0 +1,33 @@
+#include <shlib-compat.h>
+
+#define aio_cancel64 XXX
+#include <aio.h>
+#undef aio_cancel64
+#include <errno.h>
+
+extern __typeof (aio_cancel) __new_aio_cancel;
+extern __typeof (aio_cancel) __old_aio_cancel;
+
+#define aio_cancel __new_aio_cancel
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__new_aio_cancel, __new_aio_cancel64);
+versioned_symbol (librt, __new_aio_cancel, aio_cancel, GLIBC_2_3);
+versioned_symbol (librt, __new_aio_cancel64, aio_cancel64, GLIBC_2_3);
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3)
+
+#undef ECANCELED
+#define aio_cancel __old_aio_cancel
+#define ECANCELED 125
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__old_aio_cancel, __old_aio_cancel64);
+compat_symbol (librt, __old_aio_cancel, aio_cancel, GLIBC_2_1);
+compat_symbol (librt, __old_aio_cancel64, aio_cancel64, GLIBC_2_1);
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
new file mode 100644
index 000000000..3f22f8ae3
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
@@ -0,0 +1,91 @@
+/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
+ Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* This is the value this implementation supports. */
+#define PTHREAD_THREADS_MAX 16384
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
+
+/* Maximum number of POSIX timers available. */
+#define TIMER_MAX 256
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
new file mode 100644
index 000000000..3efee0b8d
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
@@ -0,0 +1,65 @@
+/* bits/typesizes.h -- underlying types for *_t. Linux/SPARC version.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_TYPESIZES_H
+#define _BITS_TYPESIZES_H 1
+
+/* See <bits/types.h> for the meaning of these macros. This file exists so
+ that <bits/types.h> need not vary across different GNU platforms. */
+
+#define __DEV_T_TYPE __UQUAD_TYPE
+#define __UID_T_TYPE __U32_TYPE
+#define __GID_T_TYPE __U32_TYPE
+#define __INO_T_TYPE __ULONGWORD_TYPE
+#define __INO64_T_TYPE __UQUAD_TYPE
+#define __MODE_T_TYPE __U32_TYPE
+#define __NLINK_T_TYPE __U32_TYPE
+#define __OFF_T_TYPE __SLONGWORD_TYPE
+#define __OFF64_T_TYPE __SQUAD_TYPE
+#define __PID_T_TYPE __S32_TYPE
+#define __RLIM_T_TYPE __ULONGWORD_TYPE
+#define __RLIM64_T_TYPE __UQUAD_TYPE
+#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
+#define __BLKCNT64_T_TYPE __SQUAD_TYPE
+#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
+#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
+#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
+#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
+#define __ID_T_TYPE __U32_TYPE
+#define __CLOCK_T_TYPE __SLONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
+#define __USECONDS_T_TYPE __U32_TYPE
+#define __SUSECONDS_T_TYPE __S32_TYPE
+#define __DADDR_T_TYPE __S32_TYPE
+#define __SWBLK_T_TYPE __SLONGWORD_TYPE
+#define __KEY_T_TYPE __S32_TYPE
+#define __CLOCKID_T_TYPE __S32_TYPE
+#define __TIMER_T_TYPE __S32_TYPE
+#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
+#define __FSID_T_TYPE struct { int __val[2]; }
+#define __SSIZE_T_TYPE __SWORD_TYPE
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+#endif /* bits/typesizes.h */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h
new file mode 100644
index 000000000..ce98a3bb9
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h
@@ -0,0 +1,20 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include_next <fork.h>
+
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
new file mode 100644
index 000000000..bd9bb0d6a
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
@@ -0,0 +1,100 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ENTRY(name) \
+ ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1; \
+ cmp %g1, 0; \
+ bne 1f; \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcs __syscall_error_handler; \
+ nop; \
+ .subsection 2; \
+1: save %sp, -96, %sp; \
+ CENABLE; \
+ nop; \
+ mov %o0, %l0; \
+ COPY_ARGS_##args \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcs __syscall_error_handler2; \
+ mov %o0, %l1; \
+ CDISABLE; \
+ mov %l0, %o0; \
+ jmpl %i7 + 8, %g0; \
+ restore %g0, %l1, %o0; \
+ .previous; \
+ SYSCALL_ERROR_HANDLER \
+ SYSCALL_ERROR_HANDLER2
+
+#define SYSCALL_ERROR_HANDLER2 \
+SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
+ .global __errno_location; \
+ .type __errno_location,@function; \
+ CDISABLE; \
+ mov %l0, %o0; \
+ call __errno_location; \
+ nop; \
+ st %l1, [%o0]; \
+ jmpl %i7 + 8, %g0; \
+ restore %g0, -1, %o0; \
+ .previous;
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel
+# define CDISABLE call __pthread_disable_asynccancel
+# elif !defined NOT_IN_libc
+# define CENABLE call __libc_enable_asynccancel
+# define CDISABLE call __libc_disable_asynccancel
+# else
+# define CENABLE call __librt_enable_asynccancel
+# define CDISABLE call __librt_disable_asynccancel
+# endif
+
+#define COPY_ARGS_0 /* Nothing */
+#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
+#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
+#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
+#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
+#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
+#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ p_header.data.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S
new file mode 100644
index 000000000..ab2286ee8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S
@@ -0,0 +1,64 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+
+ .text
+#ifdef SHARED
+.LLGETPC0:
+ retl
+ add %o7, %o0, %o0
+#endif
+ENTRY(__vfork)
+#ifdef SHARED
+ mov %o7, %o1
+ sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o0
+ call .LLGETPC0
+ add %o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0
+ sethi %hi(__libc_pthread_functions), %o2
+ mov %o1, %o7
+ or %o2, %lo(__libc_pthread_functions), %o2
+ ld [%o0 + %o2], %o2
+ ld [%o2], %o2
+ cmp %o2, 0
+#else
+ .weak pthread_create
+ sethi %hi(pthread_create), %o0
+ orcc %o0, %lo(pthread_create), %o0
+#endif
+#if defined SHARED && !defined BROKEN_SPARC_WDISP22
+ bne HIDDEN_JUMPTARGET(fork)
+#else
+ bne 1f
+#endif
+ mov __NR_vfork, %g1
+ ta 0x10
+ bcs __syscall_error_handler
+ nop
+ sub %o1, 1, %o1
+ retl
+ and %o0, %o1, %o0
+#if !defined SHARED || defined BROKEN_SPARC_WDISP22
+1: mov %o7, %g1
+ call HIDDEN_JUMPTARGET(fork)
+ mov %g1, %o7
+#endif
+ SYSCALL_ERROR_HANDLER
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c
new file mode 100644
index 000000000..4bc83d6cc
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include "fork.h"
+
+
+void
+__unregister_atfork (dso_handle)
+ void *dso_handle;
+{
+ /* Get the lock to not conflict with running forks. */
+ __libc_lock_lock (__fork_block.lock);
+
+ list_t *runp;
+ list_t *prevp;
+
+ list_for_each_prev_safe (runp, prevp, &__fork_block.prepare_list)
+ if (list_entry (runp, struct fork_handler, list)->dso_handle == dso_handle)
+ list_del (runp);
+
+ list_for_each_prev_safe (runp, prevp, &__fork_block.parent_list)
+ if (list_entry (runp, struct fork_handler, list)->dso_handle == dso_handle)
+ list_del (runp);
+
+ list_for_each_prev_safe (runp, prevp, &__fork_block.child_list)
+ if (list_entry (runp, struct fork_handler, list)->dso_handle == dso_handle)
+ list_del (runp);
+
+ /* Release the lock. */
+ __libc_lock_unlock (__fork_block.lock);
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c
new file mode 100644
index 000000000..3a0c2afc0
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c
@@ -0,0 +1 @@
+#include "../ia64/pt-sigsuspend.c"
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
new file mode 100644
index 000000000..0b05c96f6
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -0,0 +1,131 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ jne L(pseudo_cancel); \
+ DO_CALL (syscall_name, args); \
+ cmpq $-4095, %rax; \
+ jae SYSCALL_ERROR_LABEL; \
+ ret; \
+ L(pseudo_cancel): \
+ /* Save registers that might get destroyed. */ \
+ SAVESTK_##args \
+ PUSHARGS_##args \
+ CENABLE \
+ /* Restore registers. */ \
+ POPARGS_##args \
+ /* The return value from CENABLE is argument for CDISABLE. */ \
+ movq %rax, (%rsp); \
+ movl $SYS_ify (syscall_name), %eax; \
+ syscall; \
+ movq (%rsp), %rdi; \
+ /* Save %rax since it's the error code from the syscall. */ \
+ movq %rax, 8(%rsp); \
+ CDISABLE \
+ movq 8(%rsp), %rax; \
+ RESTSTK_##args \
+ cmpq $-4095, %rax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+# define PUSHARGS_0 /* Nothing. */
+# define PUSHARGS_1 PUSHARGS_0 movq %rdi, 8(%rsp);
+# define PUSHARGS_2 PUSHARGS_1 movq %rsi, 16(%rsp);
+# define PUSHARGS_3 PUSHARGS_2 movq %rdx, 24(%rsp);
+# define PUSHARGS_4 PUSHARGS_3 movq %rcx, 32(%rsp);
+# define PUSHARGS_5 PUSHARGS_4 movq %r8, 40(%rsp);
+# define PUSHARGS_6 PUSHARGS_5 movq %r9, 48(%rsp);
+
+# define POPARGS_0 /* Nothing. */
+# define POPARGS_1 POPARGS_0 movq 8(%rsp), %rdi;
+# define POPARGS_2 POPARGS_1 movq 16(%rsp), %rsi;
+# define POPARGS_3 POPARGS_2 movq 24(%rsp), %rdx;
+# define POPARGS_4 POPARGS_3 movq 32(%rsp), %r10;
+# define POPARGS_5 POPARGS_4 movq 40(%rsp), %r8;
+# define POPARGS_6 POPARGS_5 movq 48(%rsp), %r9;
+
+/* We always have to align the stack before calling a function. */
+# define SAVESTK_0 subq $24, %rsp;cfi_adjust_cfa_offset(24);
+# define SAVESTK_1 SAVESTK_0
+# define SAVESTK_2 SAVESTK_1
+# define SAVESTK_3 subq $40, %rsp;cfi_adjust_cfa_offset(40);
+# define SAVESTK_4 SAVESTK_3
+# define SAVESTK_5 subq $56, %rsp;cfi_adjust_cfa_offset(56);
+# define SAVESTK_6 SAVESTK_5
+
+# define RESTSTK_0 addq $24,%rsp;cfi_adjust_cfa_offset(-24);
+# define RESTSTK_1 RESTSTK_0
+# define RESTSTK_2 RESTSTK_1
+# define RESTSTK_3 addq $40, %rsp;cfi_adjust_cfa_offset(-40);
+# define RESTSTK_4 RESTSTK_3
+# define RESTSTK_5 addq $56, %rsp;cfi_adjust_cfa_offset(-56);
+# define RESTSTK_6 RESTSTK_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel;
+# define CDISABLE call __pthread_disable_asynccancel;
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE call __libc_enable_asynccancel;
+# define CDISABLE call __libc_disable_asynccancel;
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define CENABLE call __librt_enable_asynccancel@plt;
+# define CDISABLE call __librt_disable_asynccancel@plt;
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P \
+ __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip)
+# endif
+
+# else
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ p_header.data.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET
+# endif
+
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S
new file mode 100644
index 000000000..1a58077c4
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S
@@ -0,0 +1,61 @@
+/* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef SHARED
+ cmpq $0, __libc_pthread_functions(%rip)
+#else
+ .weak pthread_create
+ movq $pthread_create, %rax
+ testq %rax, %rax
+#endif
+ jne HIDDEN_JUMPTARGET (fork)
+
+ /* Pop the return PC value into RDI. We need a register that
+ is preserved by the syscall and that we're allowed to destroy. */
+ popq %rdi
+ cfi_adjust_cfa_offset(-8)
+
+ /* Stuff the syscall number in RAX and enter into the kernel. */
+ movl $SYS_ify (vfork), %eax
+ syscall
+
+ /* Push back the return PC. */
+ pushq %rdi
+ cfi_adjust_cfa_offset(8)
+
+ cmpl $-4095, %eax
+ jae SYSCALL_ERROR_LABEL /* Branch forward if it failed. */
+
+ /* Normal return. */
+.Lpseudo_end:
+ ret
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/v850/pt-machine.h b/libpthread/linuxthreads/sysdeps/v850/pt-machine.h
deleted file mode 100644
index 34de63b9f..000000000
--- a/libpthread/linuxthreads/sysdeps/v850/pt-machine.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * sysdeps/v850/pt-machine.h -- v850-specific pthread definitions
- *
- * Copyright (C) 2002 NEC Electronics Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME __stack_pointer
-register char *__stack_pointer __asm__ ("sp");
-
-#define HAS_COMPARE_AND_SWAP
-
-/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
- otherwise do nothing and return false. */
-PT_EI int
-__compare_and_swap (long *ptr, long old, long new)
-{
- unsigned long psw;
-
- /* disable interrupts */
- __asm__ __volatile__ ("stsr psw, %0; di" : "=&r" (psw));
-
- if (likely (*ptr == old))
- {
- *ptr = new;
- __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
- return 1;
- }
- else
- {
- __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
- return 0;
- }
-}
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c b/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c
new file mode 100644
index 000000000..80c1b05a8
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c
@@ -0,0 +1,96 @@
+/* POSIX spinlock implementation. x86-64 version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+/* This implementation is similar to the one used in the Linux kernel.
+ But the kernel is byte instructions for the memory access. This is
+ faster but unusable here. The problem is that only 128
+ threads/processes could use the spinlock at the same time. If (by
+ a design error in the program) a thread/process would hold the
+ spinlock for a time long enough to accumulate 128 waiting
+ processes, the next one will find a positive value in the spinlock
+ and assume it is unlocked. We cannot accept that. */
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("\n"
+ "1:\n\t"
+ "lock; decl %0\n\t"
+ "js 2f\n\t"
+ ".section .text.spinlock,\"ax\"\n"
+ "2:\n\t"
+ "cmpl $0,%0\n\t"
+ "rep; nop\n\t"
+ "jle 2b\n\t"
+ "jmp 1b\n\t"
+ ".previous"
+ : "=m" (*lock));
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int oldval;
+
+ __asm__ __volatile__
+ ("xchgl %0,%1"
+ : "=r" (oldval), "=m" (*lock)
+ : "0" (0));
+ return oldval > 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("movl $1,%0"
+ : "=m" (*lock));
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 1;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
index ed1fa30b1..0e0851e1e 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
@@ -20,7 +20,7 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
-#include <features.h>
+# include <features.h>
#ifndef __ASSEMBLER__
# include <stddef.h> /* For offsetof. */
@@ -32,9 +32,6 @@
# define PT_EI __extern_always_inline
# endif
-extern long int testandset (int *);
-extern int __compare_and_swap (long int *, long int, long int);
-
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
# define CURRENT_STACK_FRAME stack_pointer
@@ -43,14 +40,14 @@ register char * stack_pointer __asm__ ("%rsp") __attribute_used__;
/* Spinlock implementation; required. */
PT_EI long int
-testandset (int *__spinlock)
+testandset (int *spinlock)
{
long int ret;
__asm__ __volatile__ (
"xchgl %k0, %1"
- : "=r"(ret), "=m"(*__spinlock)
- : "0"(1), "m"(*__spinlock)
+ : "=r"(ret), "=m"(*spinlock)
+ : "0"(1), "m"(*spinlock)
: "memory");
return ret;
@@ -61,18 +58,157 @@ testandset (int *__spinlock)
# define HAS_COMPARE_AND_SWAP
PT_EI int
-__compare_and_swap (long int *__p, long int __oldval, long int __newval)
+__compare_and_swap (long int *p, long int oldval, long int newval)
{
char ret;
long int readval;
__asm__ __volatile__ ("lock; cmpxchgq %3, %1; sete %0"
- : "=q" (ret), "=m" (*__p), "=a" (readval)
- : "r" (__newval), "m" (*__p), "a" (__oldval)
+ : "=q" (ret), "=m" (*p), "=a" (readval)
+ : "r" (newval), "m" (*p), "a" (oldval)
: "memory");
return ret;
}
+/* Return the thread descriptor for the current thread.
+
+ The contained asm must *not* be marked volatile since otherwise
+ assignments like
+ pthread_descr self = thread_self();
+ do not get optimized away. */
+# define THREAD_SELF \
+({ \
+ register pthread_descr __self; \
+ __asm__ ("movq %%fs:%c1,%0" : "=r" (__self) \
+ : "i" (offsetof (struct _pthread_descr_struct, \
+ p_header.data.self))); \
+ __self; \
+})
+
+/* Prototype for the system call. */
+extern int arch_prctl (int __code, unsigned long __addr);
+
+/* Initialize the thread-unique value. */
+# define INIT_THREAD_SELF(descr, nr) \
+{ \
+ if (arch_prctl (ARCH_SET_FS, (unsigned long)descr) != 0) \
+ abort (); \
+}
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) \
+({ \
+ __typeof__ (descr->member) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%fs:%P2,%b0" \
+ : "=q" (__value) \
+ : "0" (0), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%fs:%P2,%k0" \
+ : "=r" (__value) \
+ : "0" (0), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, 4 or 8. */\
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %%fs:%P1,%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+ __value; \
+})
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member) \
+({ \
+ __typeof__ (descr->member) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%fs:(%2),%b0" \
+ : "=q" (__value) \
+ : "0" (0), \
+ "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%fs:(%2),%k0" \
+ : "=r" (__value) \
+ : "0" (0), \
+ "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, 4 or 8. */\
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %%fs:(%1),%0" \
+ : "=r" (__value) \
+ : "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+ __value; \
+})
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM(descr, member, value) \
+({ \
+ __typeof__ (descr->member) __value = (value); \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %0,%%fs:%P1" : \
+ : "q" (__value), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %k0,%%fs:%P1" : \
+ : "r" (__value), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, 4 or 8. */\
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %0,%%fs:%P1" : \
+ : "r" (__value), \
+ "i" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+})
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# define THREAD_SETMEM_NC(descr, member, value) \
+({ \
+ __typeof__ (descr->member) __value = (value); \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %0,%%fs:(%1)" : \
+ : "q" (__value), \
+ "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %k0,%%fs:(%1)" : \
+ : "r" (__value), \
+ "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, 4 or 8. */\
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %0,%%fs:(%1)" : \
+ : "r" (__value), \
+ "r" (offsetof (struct _pthread_descr_struct, \
+ member))); \
+ } \
+})
+
#endif /* !__ASSEMBLER__ */
/* We want the OS to assign stack addresses. */
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/x86_64/tcb-offsets.sym
new file mode 100644
index 000000000..aee6be257
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/x86_64/tcb-offsets.sym
@@ -0,0 +1,4 @@
+#include <sysdep.h>
+#include <tls.h>
+
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/libpthread/linuxthreads/sysdeps/xtensa/pt-machine.h b/libpthread/linuxthreads/sysdeps/xtensa/pt-machine.h
deleted file mode 100644
index 2c68ddfb5..000000000
--- a/libpthread/linuxthreads/sysdeps/xtensa/pt-machine.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- Xtensa version.
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <sys/syscall.h>
-#include <asm/unistd.h>
-
-#ifndef PT_EI
-# define PT_EI extern inline __attribute__ ((gnu_inline))
-#endif
-
-#define MEMORY_BARRIER() __asm__ ("memw" : : : "memory")
-#define HAS_COMPARE_AND_SWAP
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- unsigned long tmp;
- __asm__ volatile (
-" movi %0, 0 \n"
-" wsr %0, SCOMPARE1 \n"
-" movi %0, 1 \n"
-" s32c1i %0, %1, 0 \n"
- : "=&a" (tmp)
- : "a" (spinlock)
- : "memory"
- );
- return tmp;
-}
-
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- unsigned long tmp;
- unsigned long value;
- __asm__ volatile (
-"1: l32i %0, %2, 0 \n"
-" bne %0, %4, 2f \n"
-" wsr %0, SCOMPARE1 \n"
-" mov %1, %0 \n"
-" mov %0, %3 \n"
-" s32c1i %0, %2, 0 \n"
-" bne %1, %0, 1b \n"
-"2: \n"
- : "=&a" (tmp), "=&a" (value)
- : "a" (p), "a" (newval), "a" (oldval)
- : "memory" );
-
- return tmp == oldval;
-}
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME __builtin_frame_address (0)
-
-#endif /* _PT_MACHINE_H */