summaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-04-01 15:13:31 +0000
committerJakub Jelinek <jakub@redhat.com>2005-04-01 15:13:31 +0000
commite8eaba2b25948c0e60f70c33c5c52aad70bbf5fc (patch)
tree020566c0ffd2d27131ee7bac45eea5560a4732bd /nptl
parente3166b6660ce5f0640242a4806a380bb651a2291 (diff)
Updated to fedora-glibc-20050401T1444
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog43
-rw-r--r--nptl/sysdeps/mips/Makefile25
-rw-r--r--nptl/sysdeps/mips/jmpbuf-unwind.h30
-rw-r--r--nptl/sysdeps/mips/nptl-sysdep.S2
-rw-r--r--nptl/sysdeps/mips/pthread_spin_lock.S37
-rw-r--r--nptl/sysdeps/mips/pthread_spin_trylock.S41
-rw-r--r--nptl/sysdeps/mips/pthreaddef.h39
-rw-r--r--nptl/sysdeps/mips/tcb-offsets.sym11
-rw-r--r--nptl/sysdeps/mips/tls.h161
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h193
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h40
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/clone.S2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/createthread.c24
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/fork.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h216
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S37
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c94
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h170
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mips/vfork.S42
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S38
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S15
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S14
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S26
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S26
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S24
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S14
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h4
35 files changed, 1363 insertions, 110 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 6ded83e181..b8ed53aff7 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,46 @@
+2005-03-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Use
+ functionally equivalent, but shorter instructions.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+
+2005-03-28 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/mips/Makefile: New file.
+ * sysdeps/mips/nptl-sysdep.S: New file.
+ * sysdeps/mips/tcb-offsets.sym: New file.
+ * sysdeps/mips/pthread_spin_lock.S: New file.
+ * sysdeps/mips/pthread_spin_trylock.S: New file.
+ * sysdeps/mips/pthreaddef.h: New file.
+ * sysdeps/mips/tls.h: New file.
+ * sysdeps/mips/jmpbuf-unwind.h: New file.
+ * sysdeps/unix/sysv/linux/mips/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/mips/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/mips/fork.c: New file.
+ * sysdeps/unix/sysv/linux/mips/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/clone.S: New file.
+ * sysdeps/unix/sysv/linux/mips/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h: New file.
+
2005-03-23 Ulrich Drepper <drepper@redhat.com>
* pthread_create.c (__pthread_create_2_1): Rename syscall error
diff --git a/nptl/sysdeps/mips/Makefile b/nptl/sysdeps/mips/Makefile
new file mode 100644
index 0000000000..d0c59a5091
--- /dev/null
+++ b/nptl/sysdeps/mips/Makefile
@@ -0,0 +1,25 @@
+# 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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
+
+ifeq ($(subdir),nptl)
+libpthread-sysdep_routines += nptl-sysdep
+endif
diff --git a/nptl/sysdeps/mips/jmpbuf-unwind.h b/nptl/sysdeps/mips/jmpbuf-unwind.h
new file mode 100644
index 0000000000..67cc969663
--- /dev/null
+++ b/nptl/sysdeps/mips/jmpbuf-unwind.h
@@ -0,0 +1,30 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[0].__sp - (_adj))
+
+/* We use the normal longjmp for unwinding. */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/nptl/sysdeps/mips/nptl-sysdep.S b/nptl/sysdeps/mips/nptl-sysdep.S
new file mode 100644
index 0000000000..3f5c2a364a
--- /dev/null
+++ b/nptl/sysdeps/mips/nptl-sysdep.S
@@ -0,0 +1,2 @@
+/* Pull in __syscall_error. */
+#include <sysdep.S>
diff --git a/nptl/sysdeps/mips/pthread_spin_lock.S b/nptl/sysdeps/mips/pthread_spin_lock.S
new file mode 100644
index 0000000000..d5f2a72340
--- /dev/null
+++ b/nptl/sysdeps/mips/pthread_spin_lock.S
@@ -0,0 +1,37 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_lock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+1: ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1b
+ sc a1, 0(a0)
+ beqz a1, 1b
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ ret
+PSEUDO_END (pthread_spin_lock)
diff --git a/nptl/sysdeps/mips/pthread_spin_trylock.S b/nptl/sysdeps/mips/pthread_spin_trylock.S
new file mode 100644
index 0000000000..9c6e740f0f
--- /dev/null
+++ b/nptl/sysdeps/mips/pthread_spin_trylock.S
@@ -0,0 +1,41 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_trylock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+ ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1f
+ sc a1, 0(a0)
+ beqz a1, 1f
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ ret
+1: li v0, EBUSY
+ ret
+PSEUDO_END (pthread_spin_trylock)
diff --git a/nptl/sysdeps/mips/pthreaddef.h b/nptl/sysdeps/mips/pthreaddef.h
new file mode 100644
index 0000000000..e72b4bc58d
--- /dev/null
+++ b/nptl/sysdeps/mips/pthreaddef.h
@@ -0,0 +1,39 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/nptl/sysdeps/mips/tcb-offsets.sym b/nptl/sysdeps/mips/tcb-offsets.sym
new file mode 100644
index 0000000000..e0e71dc430
--- /dev/null
+++ b/nptl/sysdeps/mips/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/nptl/sysdeps/mips/tls.h b/nptl/sysdeps/mips/tls.h
new file mode 100644
index 0000000000..1cef161010
--- /dev/null
+++ b/nptl/sysdeps/mips/tls.h
@@ -0,0 +1,161 @@
+/* Definition for thread-local data handling. NPTL/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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+/* Note: rd must be $v1 to be ABI-conformant. */
+# 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>
+
+# define READ_THREAD_POINTER(rd) \
+ .set push; \
+ .set mips32r2; \
+ rdhwr rd, $29; \
+ .set pop
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB - actually, it includes the TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + ((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
+
+/* 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. */
+# define THREAD_SELF \
+ ((struct pthread *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Access to data in the thread descriptor is easy. */
+# define THREAD_GETMEM(descr, member) \
+ descr->member
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* 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
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
new file mode 100644
index 0000000000..e14a487508
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
@@ -0,0 +1,193 @@
+/* Machine-specific pthread type layouts. 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if _MIPS_SIM == _ABI64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if _MIPS_SIM != _ABI64
+ unsigned int __nusers;
+#endif
+ int __spins;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+# if _MIPS_SIM == _ABI64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __pad1;
+ unsigned long int __pad2;
+ unsigned long int __pad3;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h
new file mode 100644
index 0000000000..c4440f9e9e
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/clone.S b/nptl/sysdeps/unix/sysv/linux/mips/clone.S
new file mode 100644
index 0000000000..80c265bf6c
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <sysdeps/unix/sysv/linux/mips/clone.S>
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/createthread.c b/nptl/sysdeps/unix/sysv/linux/mips/createthread.c
new file mode 100644
index 0000000000..5b2234f470
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/createthread.c
@@ -0,0 +1,24 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE ((void *) (pd) \
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Get the real implementation. */
+#include <nptl/sysdeps/pthread/createthread.c>
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/fork.c b/nptl/sysdeps/unix/sysv/linux/mips/fork.c
new file mode 100644
index 0000000000..06b7e1c69f
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/fork.c
@@ -0,0 +1 @@
+#include "../i386/fork.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h
new file mode 100644
index 0000000000..7edb28794f
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h
@@ -0,0 +1,216 @@
+/* Copyright (C) 2003, 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; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+
+/* Initializer for compatibility lock. */
+#define LLL_MUTEX_LOCK_INITIALIZER (0)
+
+#define lll_futex_wait(futexp, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_timed_wait(futexp, val, timespec) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), (timespec)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAKE, (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_CMP_REQUEUE, (nr_wake), \
+ (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+}
+#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_cond_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+}
+#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock))
+
+
+extern void __lll_lock_wait (int *futex) attribute_hidden;
+
+static inline void __attribute__((always_inline))
+__lll_mutex_lock(int *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_cond_lock (int *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_mutex_timedlock(futex, abstime) \
+ __lll_mutex_timedlock (&(futex), abstime)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock (int *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock_force (int *futex)
+{
+ (void) atomic_exchange_rel (futex, 0);
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
+
+
+#define lll_mutex_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Type for lock object. */
+typedef int lll_lock_t;
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+#define lll_trylock(lock) lll_mutex_trylock (lock)
+#define lll_lock(lock) lll_mutex_lock (lock)
+#define lll_unlock(lock) lll_mutex_unlock (lock)
+#define lll_islocked(lock) lll_mutex_islocked (lock)
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+
+/* Conditional variable handling. */
+
+extern void __lll_cond_wait (pthread_cond_t *cond)
+ attribute_hidden;
+extern int __lll_cond_timedwait (pthread_cond_t *cond,
+ const struct timespec *abstime)
+ attribute_hidden;
+extern void __lll_cond_wake (pthread_cond_t *cond)
+ attribute_hidden;
+extern void __lll_cond_broadcast (pthread_cond_t *cond)
+ attribute_hidden;
+
+#define lll_cond_wait(cond) \
+ __lll_cond_wait (cond)
+#define lll_cond_timedwait(cond, abstime) \
+ __lll_cond_timedwait (cond, abstime)
+#define lll_cond_wake(cond) \
+ __lll_cond_wake (cond)
+#define lll_cond_broadcast(cond) \
+ __lll_cond_broadcast (cond)
+
+#endif /* lowlevellock.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S b/nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S
new file mode 100644
index 0000000000..fe2b81bc1f
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S
@@ -0,0 +1,37 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tls.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Negate it. */ \
+ sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ beqz v0, 1f; /* If we are the parent... */ \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Re-negate it. */ \
+ sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
+1:
+
+#include <../sysdeps/unix/sysv/linux/mips/vfork.S>
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c b/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c
new file mode 100644
index 0000000000..649b752f54
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c
@@ -0,0 +1,94 @@
+/* Copyright (C) 2003, 2004, 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX);
+}
+
+
+int
+__pthread_once (once_control, init_routine)
+ pthread_once_t *once_control;
+ void (*init_routine) (void);
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, newval);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
new file mode 100644
index 0000000000..02508e2155
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
@@ -0,0 +1,170 @@
+/* Copyright (C) 2003, 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; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <sysdeps/generic/sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.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; \
+ L(pseudo_start): \
+ cfi_startproc; \
+ 99: la t9,__syscall_error; \
+ jr t9; \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ .set noreorder; \
+ .cpload t9; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ .set noreorder; \
+ .cpload t9; \
+ .set reorder; \
+ SINGLE_THREAD_P(v1); \
+ bne zero, v1, 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); \
+ cfi_rel_offset (ra, 28); \
+ sw gp, 32(sp); \
+ cfi_rel_offset (gp, 32); \
+ 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 */ \
+ .set noreorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ RESTORESTK; \
+ L(pseudo_end): \
+ .set reorder;
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
+
+#endif
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0);
+# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4);
+# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8);
+# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12);
+# define PUSHARGS_5 PUSHARGS_4 /* handled 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; cfi_adjust_cfa_offset(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); \
+ SAVESTK_0; \
+ sw t0, 16(sp)
+
+# define SAVESTK_6 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp)
+
+# define SAVESTK_7 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ lw t2, 24(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp); \
+ sw t2, 24(sp)
+
+# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
+
+
+/* We use jalr rather than jal. This means that the assembler will not
+ automatically restore $gp (in case libc has multiple GOTs) so we must
+ do it manually - which we have to do anyway since we don't use .cprestore.
+ It also shuts up the assembler warning about not using .cprestore. */
+# ifdef IS_IN_libpthread
+# define CENABLE la t9, __pthread_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __pthread_disable_asynccancel; jalr t9;
+# elif defined IS_IN_librt
+# define CENABLE la t9, __librt_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __librt_disable_asynccancel; jalr t9;
+# else
+# define CENABLE la t9, __libc_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __libc_disable_asynccancel; jalr t9;
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ READ_THREAD_POINTER(reg); \
+ lw reg, MULTIPLE_THREADS_OFFSET(reg)
+#endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/mips/vfork.S b/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
new file mode 100644
index 0000000000..874a2e2bf4
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -0,0 +1,42 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tls.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Negate it. */ \
+ bnez a2, 1f; /* If it was zero... */ \
+ lui a2, 0x8000; /* use 0x80000000 instead. */ \
+1: sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ beqz v0, 1f; /* If we are the parent... */ \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Re-negate it. */ \
+ lui a0, 0x8000; /* Load 0x80000000... */ \
+ bne a2, a0, 2f; /* ... compare against it... */ \
+ li a2, 0; /* ... use 0 instead. */ \
+2: sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
+1:
+
+#include <../sysdeps/unix/sysv/linux/mips/vfork.S>
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index d5c9345558..3a49e25dd2 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -48,12 +48,16 @@ __lll_mutex_lock_wait:
xorq %r10, %r10 /* No timeout. */
movl $2, %edx
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
cmpl %edx, %eax /* NB: %edx == 2 */
jne 2f
-1: movq $SYS_futex, %rax
+1: movl $SYS_futex, %eax
syscall
2: movl %edx, %eax
@@ -93,7 +97,7 @@ __lll_mutex_timedlock_wait:
1:
/* Get current time. */
movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
/* This is a regular function call, all caller-save registers
might be clobbered. */
@@ -101,7 +105,7 @@ __lll_mutex_timedlock_wait:
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -126,9 +130,13 @@ __lll_mutex_timedlock_wait:
je 8f
movq %rsp, %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rcx
@@ -195,9 +203,9 @@ __lll_mutex_unlock_wake:
pushq %rdx
movl $0, (%rdi)
- movq $FUTEX_WAKE, %rsi
+ movl $FUTEX_WAKE, %esi
movl $1, %edx /* Wake one thread. */
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
popq %rdx
@@ -222,13 +230,13 @@ __lll_timedwait_tid:
/* Get current time. */
2: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -248,9 +256,13 @@ __lll_timedwait_tid:
jz 4f
movq %rsp, %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
cmpl $0, (%rdi)
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
index e1593f32ff..fa8125dd87 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -63,9 +63,14 @@ pthread_barrier_wait:
/* Wait for the remaining threads. The call will return immediately
if the CURR_EVENT memory has meanwhile been changed. */
-7: xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+7:
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
xorq %r10, %r10
-8: movq $SYS_futex, %rax
+8: movl $SYS_futex, %eax
syscall
/* Don't return on spurious wakeups. The syscall does not change
@@ -110,8 +115,8 @@ pthread_barrier_wait:
/* Wake up all waiters. The count is a signed number in the kernel
so 0x7fffffff is the highest value. */
movl $0x7fffffff, %edx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
/* Increment LEFT. If this brings the count back to the
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
index e8d7bd9bb6..72e7bc5b24 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -81,10 +81,10 @@ __pthread_cond_broadcast:
je 9f
/* Wake up all threads. */
- movq $FUTEX_CMP_REQUEUE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_CMP_REQUEUE, %esi
+ movl $SYS_futex, %eax
movl $1, %edx
- movq $0x7fffffff, %r10
+ movl $0x7fffffff, %r10d
syscall
/* For any kind of error, which mainly is EAGAIN, we try again
@@ -128,9 +128,9 @@ __pthread_cond_broadcast:
jmp 8b
9: /* The futex requeue functionality is not available. */
- movq $0x7fffffff, %rdx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $0x7fffffff, %edx
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
jmp 10b
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
index 62bb74cc1a..de9e109f45 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -66,9 +66,9 @@ __pthread_cond_signal:
addl $1, (%rdi)
/* Wake up one thread. */
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
- movq $1, %rdx
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
+ movl $1, %edx
syscall
/* Unlock. */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
index 67bec6caa7..ad3ae1e76e 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -56,7 +56,7 @@ __pthread_cond_timedwait:
.Lsubq:
cmpq $1000000000, 8(%rdx)
- movq $EINVAL, %rax
+ movl $EINVAL, %eax
jae 18f
/* Stack frame:
@@ -102,7 +102,7 @@ __pthread_cond_timedwait:
/* Unlock the mutex. */
2: movq 16(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
callq __pthread_mutex_unlock_usercnt
testl %eax, %eax
@@ -141,7 +141,7 @@ __pthread_cond_timedwait:
/* Only clocks 0 and 1 are allowed so far. Both are handled in the
kernel. */
leaq 24(%rsp), %rsi
- movq $__NR_clock_gettime, %rax
+ movl $__NR_clock_gettime, %eax
syscall
# ifndef __ASSUME_POSIX_TIMERS
cmpq $-ENOSYS, %rax
@@ -155,13 +155,13 @@ __pthread_cond_timedwait:
subq 32(%rsp), %rdx
#else
leaq 24(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 32(%rsp), %rax
- movq $1000, %rdx
+ movl $1000, %edx
mul %rdx /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdx
@@ -195,10 +195,14 @@ __pthread_cond_timedwait:
movl %eax, (%rsp)
leaq 24(%rsp), %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdx
addq $cond_futex, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %r14
@@ -237,7 +241,7 @@ __pthread_cond_timedwait:
13: incq wakeup_seq(%rdi)
incl cond_futex(%rdi)
- movq $ETIMEDOUT, %r14
+ movl $ETIMEDOUT, %r14d
jmp 14f
23: xorq %r14, %r14
@@ -256,8 +260,8 @@ __pthread_cond_timedwait:
jne 25f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $cond_nwaiters, %rdi
@@ -349,13 +353,13 @@ __pthread_cond_timedwait:
#if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
/* clock_gettime not available. */
19: leaq 24(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 32(%rsp), %rax
- movq $1000, %rdx
+ movl $1000, %edx
mul %rdx /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdx
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
index f5de0a280c..b837d466b1 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -82,12 +82,12 @@ __condvar_cleanup:
jne 4f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $cond_nwaiters, %rdi
- movq $1, %r12
+ movl $1, %r12d
4: LOCK
#if cond_lock == 0
@@ -105,9 +105,9 @@ __condvar_cleanup:
2: testq %r12, %r12
jnz 5f
addq $cond_futex, %rdi
- movq $FUTEX_WAKE, %rsi
+ movl $FUTEX_WAKE, %esi
movl $0x7fffffff, %edx
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
5: movq 16(%r8), %rdi
@@ -170,7 +170,7 @@ __pthread_cond_wait:
/* Unlock the mutex. */
2: movq 16(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
callq __pthread_mutex_unlock_usercnt
testl %eax, %eax
@@ -215,8 +215,12 @@ __pthread_cond_wait:
xorq %r10, %r10
movq %r12, %rdx
addq $cond_futex-cond_lock, %rdi
- movq $SYS_futex, %rax
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
+ movl $SYS_futex, %eax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
syscall
movl (%rsp), %edi
@@ -262,8 +266,8 @@ __pthread_cond_wait:
jne 17f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $cond_nwaiters, %rdi
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
index 3fec0f4205..6bf8d095ba 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -74,8 +74,12 @@ __pthread_once:
jnz 3f /* Different for generation -> run initializer. */
/* Somebody else got here first. Wait. */
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
jmp 6b
@@ -98,12 +102,12 @@ __pthread_once:
/* Wake up all other threads. */
movl $0x7fffffff, %edx
movl $FUTEX_WAKE, %esi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
4: addq $8, %rsp
.Ladd:
- xorq %rax, %rax
+ xorl %eax, %eax
retq
.size __pthread_once,.-__pthread_once
@@ -124,8 +128,8 @@ clear_once_control:
movl $0, (%rdi)
movl $0x7fffffff, %edx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
movq %r8, %rdi
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
index 43c8cae34c..5e9d8fb1d6 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -74,8 +74,12 @@ __pthread_rwlock_rdlock:
jne 10f
11: addq $READERS_WAKEUP, %rdi
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
subq $READERS_WAKEUP, %rdi
@@ -94,7 +98,7 @@ __pthread_rwlock_rdlock:
13: decl READERS_QUEUED(%rdi)
jmp 2b
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
incl NR_READERS(%rdi)
je 8f
9: LOCK
@@ -122,7 +126,7 @@ __pthread_rwlock_rdlock:
14: cmpl %fs:TID, %eax
jne 3b
/* Deadlock detected. */
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
@@ -137,12 +141,12 @@ __pthread_rwlock_rdlock:
/* Overflow. */
8: decl NR_READERS(%rdi)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
/* Overflow. */
4: decl READERS_QUEUED(%rdi)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
index aadc90c974..b44660418a 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -90,13 +90,13 @@ pthread_rwlock_timedrdlock:
/* Get current time. */
11: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdi
@@ -112,11 +112,15 @@ pthread_rwlock_timedrdlock:
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %rsp, %r10
movl %r14d, %edx
leaq READERS_WAKEUP(%r12), %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rdx
17:
@@ -136,11 +140,11 @@ pthread_rwlock_timedrdlock:
cmpq $-ETIMEDOUT, %rdx
jne 2b
-18: movq $ETIMEDOUT, %rdx
+18: movl $ETIMEDOUT, %edx
jmp 9f
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
incl NR_READERS(%r12)
je 8f
9: LOCK
@@ -168,7 +172,7 @@ pthread_rwlock_timedrdlock:
14: cmpl %fs:TID, %eax
jne 3b
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
@@ -182,12 +186,12 @@ pthread_rwlock_timedrdlock:
/* Overflow. */
8: decl NR_READERS(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
/* Overflow. */
4: decl READERS_QUEUED(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
@@ -211,6 +215,6 @@ pthread_rwlock_timedrdlock:
16: movq $-ETIMEDOUT, %rdx
jmp 17b
-19: movq $EINVAL, %rdx
+19: movl $EINVAL, %edx
jmp 9b
.size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
index ccaef47070..525e5b6b93 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -86,13 +86,13 @@ pthread_rwlock_timedwrlock:
/* Get current time. */
11: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdi
@@ -108,11 +108,15 @@ pthread_rwlock_timedwrlock:
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %rsp, %r10
movl %r14d, %edx
leaq WRITERS_WAKEUP(%r12), %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rdx
17:
@@ -132,11 +136,11 @@ pthread_rwlock_timedwrlock:
cmpq $-ETIMEDOUT, %rdx
jne 2b
-18: movq $ETIMEDOUT, %rdx
+18: movl $ETIMEDOUT, %edx
jmp 9f
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
movl %fs:TID, %eax
movl %eax, WRITER(%r12)
9: LOCK
@@ -164,7 +168,7 @@ pthread_rwlock_timedwrlock:
14: cmpl %fs:TID, %eax
jne 3b
-20: movq $EDEADLK, %rdx
+20: movl $EDEADLK, %edx
jmp 9b
6:
@@ -178,7 +182,7 @@ pthread_rwlock_timedwrlock:
/* Overflow. */
4: decl WRITERS_QUEUED(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
@@ -202,6 +206,6 @@ pthread_rwlock_timedwrlock:
16: movq $-ETIMEDOUT, %rdx
jmp 17b
-19: movq $EINVAL, %rdx
+19: movl $EINVAL, %edx
jmp 9b
.size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
index ac69fc0eae..3a6b9f0bad 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -56,7 +56,7 @@ __pthread_rwlock_unlock:
5: movl $0, WRITER(%rdi)
- movq $1, %rsi
+ movl $1, %esi
leaq WRITERS_WAKEUP(%rdi), %r10
movq %rsi, %rdx
cmpl $0, WRITERS_QUEUED(%rdi)
@@ -78,11 +78,11 @@ __pthread_rwlock_unlock:
#endif
jne 7f
-8: movq $SYS_futex, %rax
+8: movl $SYS_futex, %eax
movq %r10, %rdi
syscall
- xorq %rax, %rax
+ xorl %eax, %eax
retq
.align 16
@@ -94,7 +94,7 @@ __pthread_rwlock_unlock:
#endif
jne 3f
-4: xorq %rax, %rax
+4: xorl %eax, %eax
retq
1:
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
index 1fcb07eaef..0e82f890aa 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -72,8 +72,12 @@ __pthread_rwlock_wrlock:
jne 10f
11: addq $WRITERS_WAKEUP, %rdi
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
subq $WRITERS_WAKEUP, %rdi
@@ -92,7 +96,7 @@ __pthread_rwlock_wrlock:
13: decl WRITERS_QUEUED(%rdi)
jmp 2b
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
movl %fs:TID, %eax
movl %eax, WRITER(%rdi)
9: LOCK
@@ -119,7 +123,7 @@ __pthread_rwlock_wrlock:
14: cmpl %fs:TID, %eax
jne 3b
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
index 21ec6fd226..7f608a5974 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -41,8 +41,8 @@ sem_post:
LOCK
xaddl %edx, (%rdi)
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
incl %edx
syscall
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
index d90e03b55b..c44d3f5e77 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -82,14 +82,14 @@ sem_timedwait:
7: call __pthread_enable_asynccancel
movl %eax, 16(%rsp)
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq %rsp, %rdi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -107,8 +107,8 @@ sem_timedwait:
movq %rsp, %r10
movq %r12, %rdi
- xorq %rsi, %rsi
- movq $SYS_futex, %rax
+ xorl %esi, %esi
+ movl $SYS_futex, %eax
xorl %edx, %edx
syscall
movq %rax, %r14
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
index 76957bc139..63ecd063ab 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -77,7 +77,7 @@ sem_wait:
movl %eax, %r8d
xorq %r10, %r10
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
movq %r13, %rdi
movq %r10, %rsi
movq %r10, %rdx
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
index d47c1b80dc..97debaba99 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* 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.
@@ -48,7 +48,7 @@
POPARGS_##args \
/* The return value from CENABLE is argument for CDISABLE. */ \
movq %rax, (%rsp); \
- movq $SYS_ify (syscall_name), %rax; \
+ movl $SYS_ify (syscall_name), %eax; \
syscall; \
movq (%rsp), %rdi; \
/* Save %rax since it's the error code from the syscall. */ \