From 6a8c1091fdc978b0e369f4ca3f58a07c2f8b9d33 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 1 Mar 2006 06:55:57 +0000 Subject: Updated to fedora-glibc-20060301T0647 --- nptl/ChangeLog | 98 +++++++++- nptl/Makeconfig | 6 +- nptl/Makefile | 9 +- nptl/Versions | 3 + nptl/configure | 9 +- nptl/descr.h | 9 +- nptl/lowlevellock.h | 90 +++++++++ nptl/pt-raise.c | 31 +++ nptl/pthreadP.h | 17 +- nptl/pthread_mutex_getprioceiling.c | 33 ++++ nptl/pthread_mutex_init.c | 28 ++- nptl/pthread_mutex_setprioceiling.c | 55 ++++++ nptl/pthread_mutexattr_getprioceiling.c | 37 ++++ nptl/pthread_mutexattr_getprotocol.c | 37 ++++ nptl/pthread_mutexattr_setprioceiling.c | 39 ++++ nptl/pthread_mutexattr_setprotocol.c | 41 ++++ nptl/sysdeps/generic/lowlevellock.h | 89 --------- nptl/sysdeps/generic/pt-raise.c | 30 --- nptl/sysdeps/mips/Makefile | 25 --- nptl/sysdeps/mips/nptl-sysdep.S | 2 - nptl/sysdeps/mips/pthread_spin_lock.S | 37 ---- nptl/sysdeps/mips/pthread_spin_trylock.S | 41 ---- nptl/sysdeps/mips/pthreaddef.h | 39 ---- nptl/sysdeps/mips/tcb-offsets.sym | 11 -- nptl/sysdeps/mips/tls.h | 161 --------------- nptl/sysdeps/pthread/Makefile | 4 +- nptl/sysdeps/pthread/Subdirs | 1 + nptl/sysdeps/pthread/pthread.h | 47 +++++ nptl/sysdeps/unix/sysv/linux/aio_misc.h | 1 + nptl/sysdeps/unix/sysv/linux/alpha/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h | 7 +- nptl/sysdeps/unix/sysv/linux/i386/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/i386/vfork.S | 19 +- nptl/sysdeps/unix/sysv/linux/ia64/clone2.S | 11 +- nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h | 6 +- .../unix/sysv/linux/mips/bits/pthreadtypes.h | 202 ------------------- nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h | 40 ---- nptl/sysdeps/unix/sysv/linux/mips/clone.S | 2 - nptl/sysdeps/unix/sysv/linux/mips/createthread.c | 24 --- nptl/sysdeps/unix/sysv/linux/mips/fork.c | 1 - nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h | 216 --------------------- nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S | 37 ---- nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c | 94 --------- nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 170 ---------------- nptl/sysdeps/unix/sysv/linux/mips/vfork.S | 42 ---- .../unix/sysv/linux/powerpc/powerpc32/clone.S | 12 +- .../unix/sysv/linux/powerpc/powerpc64/clone.S | 12 +- nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h | 6 +- nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/sh/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h | 2 +- nptl/sysdeps/unix/sysv/linux/sleep.c | 12 +- nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/x86_64/clone.S | 11 +- nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S | 16 +- nptl/tst-robust1.c | 114 ++++++++--- 58 files changed, 806 insertions(+), 1357 deletions(-) create mode 100644 nptl/lowlevellock.h create mode 100644 nptl/pt-raise.c create mode 100644 nptl/pthread_mutex_getprioceiling.c create mode 100644 nptl/pthread_mutex_setprioceiling.c create mode 100644 nptl/pthread_mutexattr_getprioceiling.c create mode 100644 nptl/pthread_mutexattr_getprotocol.c create mode 100644 nptl/pthread_mutexattr_setprioceiling.c create mode 100644 nptl/pthread_mutexattr_setprotocol.c delete mode 100644 nptl/sysdeps/generic/lowlevellock.h delete mode 100644 nptl/sysdeps/generic/pt-raise.c delete mode 100644 nptl/sysdeps/mips/Makefile delete mode 100644 nptl/sysdeps/mips/nptl-sysdep.S delete mode 100644 nptl/sysdeps/mips/pthread_spin_lock.S delete mode 100644 nptl/sysdeps/mips/pthread_spin_trylock.S delete mode 100644 nptl/sysdeps/mips/pthreaddef.h delete mode 100644 nptl/sysdeps/mips/tcb-offsets.sym delete mode 100644 nptl/sysdeps/mips/tls.h delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/clone.S delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/createthread.c delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/fork.c delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h delete mode 100644 nptl/sysdeps/unix/sysv/linux/mips/vfork.S (limited to 'nptl') diff --git a/nptl/ChangeLog b/nptl/ChangeLog index bb29a14906..3c65aab301 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,98 @@ +2006-02-28 H.J. Lu + + * sysdeps/unix/sysv/linux/ia64/clone2.S: Include + instead of . + +2006-02-27 Jakub Jelinek + + * Makefile (libpthread-routines): Add + pthread_mutexattr_[sg]etprotocol, pthread_mutexattr_[sg]etprioceiling + and pthread_mutex_[sg]etprioceiling. + * Versions (GLIBC_2.4): Export pthread_mutexattr_getprotocol, + pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling, + pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling and + pthread_mutex_setprioceiling. + * sysdeps/pthread/pthread.h (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, + PTHREAD_PRIO_PROTECT): New enum values. + (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol, + pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling, + pthread_mutex_getprioceiling, pthread_mutex_setprioceiling): New + prototypes. + * pthreadP.h (PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP, + PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP): New enum values. + (PTHREAD_MUTEX_PRIO_CEILING_SHIFT, PTHREAD_MUTEX_PRIO_CEILING_MASK): + Define. + (PTHREAD_MUTEXATTR_PROTOCOL_SHIFT, PTHREAD_MUTEXATTR_PROTOCOL_MASK, + PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT, + PTHREAD_MUTEXATTR_PRIO_CEILING_MASK): Define. + (PTHREAD_MUTEXATTR_FLAG_BITS): Or in PTHREAD_MUTEXATTR_PROTOCOL_MASK + and PTHREAD_MUTEXATTR_PRIO_CEILING_MASK. + * pthread_mutex_init.c (__pthread_mutex_init): For the time being + return ENOTSUP for PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT + protocol mutexes. + * pthread_mutex_getprioceiling.c: New file. + * pthread_mutex_setprioceiling.c: New file. + * pthread_mutexattr_getprioceiling.c: New file. + * pthread_mutexattr_setprioceiling.c: New file. + * pthread_mutexattr_getprotocol.c: New file. + * pthread_mutexattr_setprotocol.c: New file. + +2006-02-27 Daniel Jacobowitz + + * sysdeps/unix/sysv/linux/aio_misc.h: Include . + +2006-02-27 Roland McGrath + + * sysdeps/pthread/Subdirs: List nptl here too. + * configure (libc_add_on_canonical): New variable. + + * sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h: Use #include_next. + + * sysdeps/unix/sysv/linux/sleep.c: Use #include_next after #include of + self to get main source tree's file. + * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise. + * sysdeps/unix/sysv/linux/i386/clone.S: Likewise. + * sysdeps/unix/sysv/linux/i386/vfork.S: Likewise. + * sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise. + * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise. + * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise. + * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise. + * sysdeps/unix/sysv/linux/sh/clone.S: Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise. + * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise. + * sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise. + + * Makefile: Use $(sysdirs) in vpath directive. + + * sysdeps/pthread/Makefile (CFLAGS-libc-start.c): Variable removed. + (CPPFLAGS-timer_routines.c): Likewise. + + * Makeconfig (includes): Variable removed. + +2006-02-26 Roland McGrath + + * sysdeps/generic/pt-raise.c: Moved to ... + * pt-raise.c: ... here. + * sysdeps/generic/lowlevellock.h: Moved to ... + * lowlevellock.h: ... here. + +2006-02-23 Roland McGrath + + * descr.h (struct pthread): Add final member `end_padding'. + (PTHREAD_STRUCT_END_PADDING): Use it. + +2006-02-20 Roland McGrath + + * sysdeps/mips: Directory removed, saved in ports repository. + * sysdeps/unix/sysv/linux/mips: Likewise. + +2006-02-18 Ulrich Drepper + + * tst-robust1.c: Add second mutex to check that the mutex list is + handled correctly. + 2006-02-17 Jakub Jelinek * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_mutex_dead, @@ -48,7 +143,7 @@ 2006-02-15 Ulrich Drepper - * pthreadp.h: Define PTHREAD_MUTEX_INCONSISTENT instead of + * pthreadP.h: Define PTHREAD_MUTEX_INCONSISTENT instead of PTHREAD_MUTEX_OWNERDEAD. (PTHREAD_MUTEX_ROBUST_PRIVATE_NP): Define as 16, not 256. Define FUTEX_WAITERS, FUTEX_OWNER_DIED, FUTEX_TID_MASK. @@ -85,6 +180,7 @@ but the owner for all robust mutex types. * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Define __pthread_list_t and __pthread_slist_t. Use them in pthread_mutex_t. + * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise. * sysdeps/pthread/pthread.h: Adjust mutex initializers. * sysdeps/unix/sysv/linux/i386/not-cancel.h: Define openat_not_cancel, diff --git a/nptl/Makeconfig b/nptl/Makeconfig index 681d76f61f..54e2f65b01 100644 --- a/nptl/Makeconfig +++ b/nptl/Makeconfig @@ -1,4 +1,4 @@ -# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2005,2006 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper , 2002. @@ -28,7 +28,3 @@ static-thread-library = $(common-objpfx)nptl/libpthread.a bounded-thread-library = $(common-objpfx)nptl/libpthread_b.a rpath-dirs += nptl - -ifneq ($(subdir),nptl) -includes += -I$(..)nptl -endif diff --git a/nptl/Makefile b/nptl/Makefile index 60203cd114..31b5ace92e 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -118,7 +118,12 @@ libpthread-routines = init vars events version \ pthread_attr_getaffinity pthread_attr_setaffinity \ pthread_mutexattr_getrobust pthread_mutexattr_setrobust \ pthread_mutex_consistent \ - cleanup_routine unwind-forcedunwind + cleanup_routine unwind-forcedunwind \ + pthread_mutexattr_getprotocol \ + pthread_mutexattr_setprotocol \ + pthread_mutexattr_getprioceiling \ + pthread_mutexattr_setprioceiling \ + pthread_mutex_getprioceiling pthread_mutex_setprioceiling # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ @@ -532,7 +537,7 @@ $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a endif ifeq ($(build-shared),yes) -vpath pt-initfini.c $(full_config_sysdirs) +vpath pt-initfini.c $(sysdirs) $(objpfx)pt-initfini.s: pt-initfini.c $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \ diff --git a/nptl/Versions b/nptl/Versions index 2b4dd01ab5..54b9b9c6a5 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -235,6 +235,9 @@ libpthread { GLIBC_2.4 { pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np; pthread_mutex_consistent_np; + pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol; + pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling; + pthread_mutex_getprioceiling; pthread_mutex_setprioceiling; }; GLIBC_PRIVATE { diff --git a/nptl/configure b/nptl/configure index 3ad635f48d..1ce3caec6e 100644 --- a/nptl/configure +++ b/nptl/configure @@ -1,6 +1,5 @@ -# This is only to keep the GNU C library configure mechanism happy. # This is a shell script fragment sourced by the main configure script. -# We have nothing we need to add here. -# -# Perhaps some day we will need a real configuration script for different -# kernel versions or so. +# We're obliged to give here the canonical name that will be used to +# as a subdirectory to search for in other add-ons' sysdeps trees. + +libc_add_on_canonical=nptl diff --git a/nptl/descr.h b/nptl/descr.h index d5491c1355..80251b920b 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -305,12 +305,11 @@ struct pthread /* Resolver state. */ struct __res_state res; - /* If you add fields after the res field above, please adjust - the following macro. */ -#define PTHREAD_STRUCT_END_PADDING \ - (sizeof (struct pthread) - offsetof (struct pthread, res) \ - - sizeof (((struct pthread *) 0)->res)) + /* This member must be last. */ + char end_padding[]; +#define PTHREAD_STRUCT_END_PADDING \ + (sizeof (struct pthread) - offsetof (struct pthread, end_padding)) } __attribute ((aligned (TCB_ALIGNMENT))); diff --git a/nptl/lowlevellock.h b/nptl/lowlevellock.h new file mode 100644 index 0000000000..338da39990 --- /dev/null +++ b/nptl/lowlevellock.h @@ -0,0 +1,90 @@ +/* Low level locking macros used in NPTL implementation. Stub version. + Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + +/* Implement generic mutex. Basic futex syscall support is required: + + lll_futex_wait(futex, value) - call sys_futex with FUTEX_WAIT + and third parameter VALUE + + lll_futex_wake(futex, value) - call sys_futex with FUTEX_WAKE + and third parameter VALUE +*/ + + +/* Mutex lock counter: + bit 31 clear means unlocked; + bit 31 set means locked. + + All code that looks at bit 31 first increases the 'number of + interested threads' usage counter, which is in bits 0-30. + + All negative mutex values indicate that the mutex is still locked. */ + + +static inline void +__generic_mutex_lock (int *mutex) +{ + unsigned int v; + + /* Bit 31 was clear, we got the mutex. (this is the fastpath). */ + if (atomic_bit_test_set (mutex, 31) == 0) + return; + + atomic_increment (mutex); + + while (1) + { + if (atomic_bit_test_set (mutex, 31) == 0) + { + atomic_decrement (mutex); + return; + } + + /* We have to wait now. First make sure the futex value we are + monitoring is truly negative (i.e. locked). */ + v = *mutex; + if (v >= 0) + continue; + + lll_futex_wait (mutex, v); + } +} + + +static inline void +__generic_mutex_unlock (int *mutex) +{ + /* Adding 0x80000000 to the counter results in 0 if and only if + there are not other interested threads - we can return (this is + the fastpath). */ + if (atomic_add_zero (mutex, 0x80000000)) + return; + + /* There are other threads waiting for this mutex, wake one of them + up. */ + lll_futex_wake (mutex, 1); +} + + +#define lll_mutex_lock(futex) __generic_mutex_lock (&(futex)) +#define lll_mutex_unlock(futex) __generic_mutex_unlock (&(futex)) diff --git a/nptl/pt-raise.c b/nptl/pt-raise.c new file mode 100644 index 0000000000..a72cf85502 --- /dev/null +++ b/nptl/pt-raise.c @@ -0,0 +1,31 @@ +/* ISO C raise function for libpthread. + Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + +int +raise (sig) + int sig; +{ + /* This is what POSIX says must happen. */ + return pthread_kill (pthread_self (), sig); +} diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 77d8f5ad24..a4d6d1a1ae 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -66,15 +66,24 @@ enum PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP - = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP + = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP = 32, + PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP = 64 }; +#define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 16 +#define PTHREAD_MUTEX_PRIO_CEILING_MASK 0x00ff0000 /* Flags in mutex attr. */ -#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 -#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 +#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28 +#define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000 +#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 16 +#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00ff0000 +#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 +#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 #define PTHREAD_MUTEXATTR_FLAG_BITS \ - (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED) + (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \ + | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) /* Bits used in robust mutex implementation. */ diff --git a/nptl/pthread_mutex_getprioceiling.c b/nptl/pthread_mutex_getprioceiling.c new file mode 100644 index 0000000000..4d1bc28431 --- /dev/null +++ b/nptl/pthread_mutex_getprioceiling.c @@ -0,0 +1,33 @@ +/* Get current priority ceiling of pthread_mutex_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutex_getprioceiling (mutex, prioceiling) + const pthread_mutex_t *mutex; + int *prioceiling; +{ + *prioceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK) + >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + + return 0; +} diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 17d1c99575..f984d90ae4 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -46,6 +46,11 @@ __pthread_mutex_init (mutex, mutexattr) if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0 && (imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0) return ENOTSUP; + // XXX For now we don't support priority inherited or priority protected + // XXX mutexes. + if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + != (PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)) + return ENOTSUP; /* Clear the whole variable. */ memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T); @@ -54,6 +59,27 @@ __pthread_mutex_init (mutex, mutexattr) mutex->__data.__kind = imutexattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS; if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0) mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_PRIVATE_NP; + switch ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT) + { + case PTHREAD_PRIO_INHERIT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP; + break; + case PTHREAD_PRIO_PROTECT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP; + if (PTHREAD_MUTEX_PRIO_CEILING_MASK + == PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + mutex->__data.__kind |= (imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK); + else + mutex->__data.__kind |= ((imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT) + << PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + break; + default: + break; + } /* Default values: mutex not used yet. */ // mutex->__count = 0; already done by memset diff --git a/nptl/pthread_mutex_setprioceiling.c b/nptl/pthread_mutex_setprioceiling.c new file mode 100644 index 0000000000..999b635ac1 --- /dev/null +++ b/nptl/pthread_mutex_setprioceiling.c @@ -0,0 +1,55 @@ +/* Set current priority ceiling of pthread_mutex_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 +#include + + +int +pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling) + pthread_mutex_t *mutex; + int prioceiling; + int *old_ceiling; +{ + /* The low bits of __kind aren't ever changed after pthread_mutex_init, + so we don't need a lock yet. */ + if ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP) == 0) + return EINVAL; + + if (prioceiling < 0 || __builtin_expect (prioceiling > 255, 0)) + return EINVAL; + + /* XXX This needs to lock with TID, but shouldn't obey priority protect + protocol. */ + /* lll_xxx_mutex_lock (mutex->__data.__lock); */ + + if (old_ceiling != NULL) + *old_ceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK) + >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + + int newkind = (mutex->__data.__kind & ~PTHREAD_MUTEX_PRIO_CEILING_MASK); + mutex->__data.__kind = newkind + | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT); + + /* XXX This needs to unlock the above special kind of lock. */ + /* lll_xxx_mutex_unlock (mutex->__data.__lock); */ + + return 0; +} diff --git a/nptl/pthread_mutexattr_getprioceiling.c b/nptl/pthread_mutexattr_getprioceiling.c new file mode 100644 index 0000000000..da1beabf46 --- /dev/null +++ b/nptl/pthread_mutexattr_getprioceiling.c @@ -0,0 +1,37 @@ +/* Get priority ceiling setting from pthread_mutexattr_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_getprioceiling (attr, prioceiling) + const pthread_mutexattr_t *attr; + int *prioceiling; +{ + const struct pthread_mutexattr *iattr; + + iattr = (const struct pthread_mutexattr *) attr; + + *prioceiling = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT); + + return 0; +} diff --git a/nptl/pthread_mutexattr_getprotocol.c b/nptl/pthread_mutexattr_getprotocol.c new file mode 100644 index 0000000000..0c28699c87 --- /dev/null +++ b/nptl/pthread_mutexattr_getprotocol.c @@ -0,0 +1,37 @@ +/* Get priority protocol setting from pthread_mutexattr_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_getprotocol (attr, protocol) + const pthread_mutexattr_t *attr; + int *protocol; +{ + const struct pthread_mutexattr *iattr; + + iattr = (const struct pthread_mutexattr *) attr; + + *protocol = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT); + + return 0; +} diff --git a/nptl/pthread_mutexattr_setprioceiling.c b/nptl/pthread_mutexattr_setprioceiling.c new file mode 100644 index 0000000000..6c15b46833 --- /dev/null +++ b/nptl/pthread_mutexattr_setprioceiling.c @@ -0,0 +1,39 @@ +/* Change priority ceiling setting in pthread_mutexattr_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 +#include + + +int +pthread_mutexattr_setprioceiling (attr, prioceiling) + pthread_mutexattr_t *attr; + int prioceiling; +{ + if (prioceiling < 0 || __builtin_expect (prioceiling > 255, 0)) + return EINVAL; + + struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr; + + iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + | (prioceiling << PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT)); + + return 0; +} diff --git a/nptl/pthread_mutexattr_setprotocol.c b/nptl/pthread_mutexattr_setprotocol.c new file mode 100644 index 0000000000..191231244e --- /dev/null +++ b/nptl/pthread_mutexattr_setprotocol.c @@ -0,0 +1,41 @@ +/* Change priority protocol setting in pthread_mutexattr_t. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 +#include + + +int +pthread_mutexattr_setprotocol (attr, protocol) + pthread_mutexattr_t *attr; + int protocol; +{ + if (protocol != PTHREAD_PRIO_NONE + && protocol != PTHREAD_PRIO_INHERIT + && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0)) + return EINVAL; + + struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr; + + iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PROTOCOL_MASK) + | (protocol << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)); + + return 0; +} diff --git a/nptl/sysdeps/generic/lowlevellock.h b/nptl/sysdeps/generic/lowlevellock.h deleted file mode 100644 index 7f95daadad..0000000000 --- a/nptl/sysdeps/generic/lowlevellock.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 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, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - - -/* Implement generic mutex. Basic futex syscall support is required: - - lll_futex_wait(futex, value) - call sys_futex with FUTEX_WAIT - and third parameter VALUE - - lll_futex_wake(futex, value) - call sys_futex with FUTEX_WAKE - and third parameter VALUE -*/ - - -/* Mutex lock counter: - bit 31 clear means unlocked; - bit 31 set means locked. - - All code that looks at bit 31 first increases the 'number of - interested threads' usage counter, which is in bits 0-30. - - All negative mutex values indicate that the mutex is still locked. */ - - -static inline void -__generic_mutex_lock (int *mutex) -{ - unsigned int v; - - /* Bit 31 was clear, we got the mutex. (this is the fastpath). */ - if (atomic_bit_test_set (mutex, 31) == 0) - return; - - atomic_increment (mutex); - - while (1) - { - if (atomic_bit_test_set (mutex, 31) == 0) - { - atomic_decrement (mutex); - return; - } - - /* We have to wait now. First make sure the futex value we are - monitoring is truly negative (i.e. locked). */ - v = *mutex; - if (v >= 0) - continue; - - lll_futex_wait (mutex, v); - } -} - - -static inline void -__generic_mutex_unlock (int *mutex) -{ - /* Adding 0x80000000 to the counter results in 0 if and only if - there are not other interested threads - we can return (this is - the fastpath). */ - if (atomic_add_zero (mutex, 0x80000000)) - return; - - /* There are other threads waiting for this mutex, wake one of them - up. */ - lll_futex_wake (mutex, 1); -} - - -#define lll_mutex_lock(futex) __generic_mutex_lock (&(futex)) -#define lll_mutex_unlock(futex) __generic_mutex_unlock (&(futex)) diff --git a/nptl/sysdeps/generic/pt-raise.c b/nptl/sysdeps/generic/pt-raise.c deleted file mode 100644 index 59d9590e6e..0000000000 --- a/nptl/sysdeps/generic/pt-raise.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 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, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include - - -int -raise (sig) - int sig; -{ - /* This is what POSIX says must happen. */ - return pthread_kill (pthread_self (), sig); -} diff --git a/nptl/sysdeps/mips/Makefile b/nptl/sysdeps/mips/Makefile deleted file mode 100644 index d0c59a5091..0000000000 --- a/nptl/sysdeps/mips/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# 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/nptl-sysdep.S b/nptl/sysdeps/mips/nptl-sysdep.S deleted file mode 100644 index 3f5c2a364a..0000000000 --- a/nptl/sysdeps/mips/nptl-sysdep.S +++ /dev/null @@ -1,2 +0,0 @@ -/* Pull in __syscall_error. */ -#include diff --git a/nptl/sysdeps/mips/pthread_spin_lock.S b/nptl/sysdeps/mips/pthread_spin_lock.S deleted file mode 100644 index d5f2a72340..0000000000 --- a/nptl/sysdeps/mips/pthread_spin_lock.S +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 -#include -#include - -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 deleted file mode 100644 index 9c6e740f0f..0000000000 --- a/nptl/sysdeps/mips/pthread_spin_trylock.S +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 -#include -#define _ERRNO_H 1 -#include -#include - -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 deleted file mode 100644 index e72b4bc58d..0000000000 --- a/nptl/sysdeps/mips/pthreaddef.h +++ /dev/null @@ -1,39 +0,0 @@ -/* 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 deleted file mode 100644 index e0e71dc430..0000000000 --- a/nptl/sysdeps/mips/tcb-offsets.sym +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - --- - --- 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 deleted file mode 100644 index 1cef161010..0000000000 --- a/nptl/sysdeps/mips/tls.h +++ /dev/null @@ -1,161 +0,0 @@ -/* 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 - -#ifndef __ASSEMBLER__ -# include -# include -# include - -/* 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 - -# 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 - -/* The TP points to the start of the thread blocks. */ -# define TLS_DTV_AT_TP 1 - -/* Get the thread descriptor definition. */ -# include - -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/pthread/Makefile b/nptl/sysdeps/pthread/Makefile index 207e10fad2..72550d74a7 100644 --- a/nptl/sysdeps/pthread/Makefile +++ b/nptl/sysdeps/pthread/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2004,2006 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper , 2002. @@ -18,7 +18,6 @@ # 02111-1307 USA. ifeq ($(subdir),csu) -CFLAGS-libc-start.c += -I../nptl routines += unwind-resume shared-only-routines += unwind-resume CFLAGS-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables @@ -31,7 +30,6 @@ endif ifeq ($(subdir),rt) librt-sysdep_routines += timer_routines librt-cancellation rt-unwind-resume librt-shared-only-routines += rt-unwind-resume -CPPFLAGS-timer_routines.c = -I../nptl CFLAGS-librt-cancellation.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-rt-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables diff --git a/nptl/sysdeps/pthread/Subdirs b/nptl/sysdeps/pthread/Subdirs index 4d1f4d876b..36266c1e69 100644 --- a/nptl/sysdeps/pthread/Subdirs +++ b/nptl/sysdeps/pthread/Subdirs @@ -1 +1,2 @@ +nptl nptl_db diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h index f4935e07b4..e03c374c71 100644 --- a/nptl/sysdeps/pthread/pthread.h +++ b/nptl/sysdeps/pthread/pthread.h @@ -71,6 +71,17 @@ enum #endif +#ifdef __USE_UNIX98 +/* Mutex protocols. */ +enum +{ + PTHREAD_PRIO_NONE, + PTHREAD_PRIO_INHERIT, + PTHREAD_PRIO_PROTECT +}; +#endif + + /* Mutex initializers. */ #if __WORDSIZE == 64 # define PTHREAD_MUTEX_INITIALIZER \ @@ -711,6 +722,22 @@ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW; +#ifdef __USE_UNIX98 +/* Get the priority ceiling of MUTEX. */ +extern int pthread_mutex_getprioceiling (__const pthread_mutex_t * + __restrict __mutex, + int *__restrict __prioceiling) + __THROW; + +/* Set the priority ceiling of MUTEX to PRIOCEILING, return old + priority ceiling value in *OLD_CEILING. */ +extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, + int __prioceiling, + int *__restrict __old_ceiling) + __THROW; +#endif + + #ifdef __USE_GNU /* Declare the state protected by MUTEX as consistent. */ extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) __THROW; @@ -745,6 +772,26 @@ extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict PTHREAD_MUTEX_DEFAULT). */ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) __THROW; + +/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */ +extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __protocol) __THROW; + +/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either + PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */ +extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, + int __protocol) __THROW; + +/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */ +extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __prioceiling) + __THROW; + +/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */ +extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, + int __prioceiling) __THROW; #endif #ifdef __USE_GNU diff --git a/nptl/sysdeps/unix/sysv/linux/aio_misc.h b/nptl/sysdeps/unix/sysv/linux/aio_misc.h index 7b0bac75f2..50064c44c1 100644 --- a/nptl/sysdeps/unix/sysv/linux/aio_misc.h +++ b/nptl/sysdeps/unix/sysv/linux/aio_misc.h @@ -22,6 +22,7 @@ # include # include # include +# include # define aio_start_notify_thread __aio_start_notify_thread # define aio_create_helper_thread __aio_create_helper_thread diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/clone.S b/nptl/sysdeps/unix/sysv/linux/alpha/clone.S index eea1cbeed1..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/alpha/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/alpha/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h index 55c464cdc6..1a2e8cbb07 100644 --- a/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h @@ -201,13 +201,14 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) -__lll_robust_mutex_unlock (int *futex) +__lll_robust_mutex_unlock (int *futex, int mask) { int val = atomic_exchange_rel (futex, 0); - if (__builtin_expect (val & FUTEX_WAITERS, 0)) + if (__builtin_expect (val & mask, 0)) lll_futex_wake (futex, 1); } -#define lll_robust_mutex_unlock(futex) __lll_robust_mutex_unlock(&(futex)) +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS) static inline void __attribute__ ((always_inline)) diff --git a/nptl/sysdeps/unix/sysv/linux/i386/clone.S b/nptl/sysdeps/unix/sysv/linux/i386/clone.S index 95c17f18e4..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S index 52336102c7..37f0842051 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1999,2002,2004,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 @@ -16,10 +16,17 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else + +# include /* Save the PID value. */ -#define SAVE_PID \ +# define SAVE_PID \ movl %gs:PID, %edx; \ movl %edx, %eax; \ negl %eax; \ @@ -28,11 +35,11 @@ 1: movl %eax, %gs:PID /* Restore the old PID value in the parent. */ -#define RESTORE_PID \ +# define RESTORE_PID \ testl %eax, %eax; \ je 1f; \ movl %edx, %gs:PID; \ 1: - -#include +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S index 8664056f27..91f28bab37 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S +++ b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h index e07570a939..ece9a7fc72 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h @@ -120,7 +120,7 @@ extern int __lll_robust_lock_wait (int *futex) attribute_hidden; if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ __val = __lll_robust_lock_wait (__futex); \ __val; \ - })) + }) #define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) @@ -142,7 +142,7 @@ extern int __lll_robust_lock_wait (int *futex) attribute_hidden; if (atomic_compare_and_exchange_bool_acq (__futex, __id, 0) != 0) \ __val = __lll_robust_lock_wait (__futex); \ __val; \ - })) + }) #define lll_robust_mutex_cond_lock(futex, id) \ __lll_robust_mutex_cond_lock (&(futex), id) @@ -174,7 +174,7 @@ extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ __val = __lll_robust_timedlock_wait (__futex, abstime); \ __val; \ - })) + }) #define lll_robust_mutex_timedlock(futex, abstime, id) \ __lll_robust_mutex_timedlock (&(futex), abstime, id) diff --git a/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h deleted file mode 100644 index d5e89a9364..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h +++ /dev/null @@ -1,202 +0,0 @@ -/* Machine-specific pthread type layouts. MIPS version. - Copyright (C) 2005, 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, 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 __pthread_mutex_s - { - 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 - int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; -# define __PTHREAD_MUTEX_HAVE_PREV 1 -#else - unsigned int __nusers; - __extension__ union - { - int __spins; - struct __pthread_mutex_s *__next; - }; -#endif - } __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 deleted file mode 100644 index c4440f9e9e..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 directly; include 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 deleted file mode 100644 index 80c265bf6c..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/clone.S +++ /dev/null @@ -1,2 +0,0 @@ -#define RESET_PID -#include diff --git a/nptl/sysdeps/unix/sysv/linux/mips/createthread.c b/nptl/sysdeps/unix/sysv/linux/mips/createthread.c deleted file mode 100644 index 5b2234f470..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/createthread.c +++ /dev/null @@ -1,24 +0,0 @@ -/* 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 diff --git a/nptl/sysdeps/unix/sysv/linux/mips/fork.c b/nptl/sysdeps/unix/sysv/linux/mips/fork.c deleted file mode 100644 index 06b7e1c69f..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/fork.c +++ /dev/null @@ -1 +0,0 @@ -#include "../i386/fork.c" diff --git a/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h deleted file mode 100644 index 7edb28794f..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h +++ /dev/null @@ -1,216 +0,0 @@ -/* 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 -#include -#include -#include -#include - - -#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 deleted file mode 100644 index fe2b81bc1f..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/pt-vfork.S +++ /dev/null @@ -1,37 +0,0 @@ -/* 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 - -/* 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 deleted file mode 100644 index 649b752f54..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 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 - - -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 deleted file mode 100644 index 02508e2155..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h +++ /dev/null @@ -1,170 +0,0 @@ -/* 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 -#include -#include -#ifndef __ASSEMBLER__ -# include -#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 deleted file mode 100644 index 874a2e2bf4..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/mips/vfork.S +++ /dev/null @@ -1,42 +0,0 @@ -/* 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 - -/* 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/powerpc/powerpc32/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S index e19579e842..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S @@ -1,3 +1,9 @@ -#define RESET_PID -#include -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S index f87adf4737..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S @@ -1,3 +1,9 @@ -#define RESET_PID -#include -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h index 612be091b0..6baab90f56 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h @@ -276,17 +276,17 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) -__lll_robust_mutex_unlock (int *futex) +__lll_robust_mutex_unlock (int *futex, int mask) { int oldval; int newval = 0; lll_compare_and_swap (futex, oldval, newval, "slr %2,%2"); - if (oldval & FUTEX_WAITERS) + if (oldval & mask) lll_futex_wake (futex, 1); } #define lll_robust_mutex_unlock(futex) \ - __lll_robust_mutex_unlock(&(futex)) + __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS) static inline void diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S index 682f94dae8..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S index 87ee2e1846..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sh/clone.S b/nptl/sysdeps/unix/sysv/linux/sh/clone.S index 62a11972d8..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h index 8cdcac5560..90be7bd8d0 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h @@ -1,4 +1,4 @@ /* 4 instruction cycles not accessing cache and TLB are needed after trapa instruction to avoid an SH-4 silicon bug. */ #define NEED_SYSCALL_INST_PAD -#include +#include_next diff --git a/nptl/sysdeps/unix/sysv/linux/sleep.c b/nptl/sysdeps/unix/sysv/linux/sleep.c index c56b49b39f..2dce3210ca 100644 --- a/nptl/sysdeps/unix/sysv/linux/sleep.c +++ b/nptl/sysdeps/unix/sysv/linux/sleep.c @@ -1,2 +1,10 @@ -#include -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +/* This defines the CANCELLATION_P macro, which sleep.c checks for. */ +# include +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S index da6197c00d..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S index 410f32017a..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S b/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S index dfa6adb3e2..675a997e97 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S @@ -1,2 +1,9 @@ -#define RESET_PID -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else +# define RESET_PID +# include_next +#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S b/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S index f68d40439e..9a9912ca85 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S @@ -16,9 +16,16 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include +/* We want an #include_next, but we are the main source file. + So, #include ourselves and in that incarnation we can use #include_next. */ +#ifndef INCLUDED_SELF +# define INCLUDED_SELF +# include +#else -#define SAVE_PID \ +# include + +# define SAVE_PID \ movl %fs:PID, %esi; \ movl $0x80000000, %ecx; \ movl %esi, %edx; \ @@ -26,10 +33,11 @@ cmove %ecx, %edx; \ movl %edx, %fs:PID -#define RESTORE_PID \ +# define RESTORE_PID \ testq %rax, %rax; \ je 1f; \ movl %esi, %fs:PID; \ 1: -#include +# include_next +#endif diff --git a/nptl/tst-robust1.c b/nptl/tst-robust1.c index 13267a5efd..9806ca467a 100644 --- a/nptl/tst-robust1.c +++ b/nptl/tst-robust1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2005. @@ -23,7 +23,8 @@ #include -static pthread_mutex_t m; +static pthread_mutex_t m1; +static pthread_mutex_t m2; static pthread_barrier_t b; @@ -43,10 +44,17 @@ tf (void *arg) exit (1); } - int e = LOCK (&m); + int e = LOCK (&m1); if (e != 0) { - printf ("%ld: child: mutex_lock failed with error %d\n", round, e); + printf ("%ld: child: mutex_lock m1 failed with error %d\n", round, e); + exit (1); + } + + e = LOCK (&m2); + if (e != 0) + { + printf ("%ld: child: mutex_lock m2 failed with error %d\n", round, e); exit (1); } @@ -90,9 +98,15 @@ do_test (void) return 1; } #ifndef NOT_CONSISTENT - if (pthread_mutex_init (&m, &a) != 0) + if (pthread_mutex_init (&m1, &a) != 0) { - puts ("mutex_init failed"); + puts ("mutex_init m1 failed"); + return 1; + } + + if (pthread_mutex_init (&m2, &a) != 0) + { + puts ("mutex_init m2 failed"); return 1; } #endif @@ -106,9 +120,14 @@ do_test (void) for (long int round = 1; round < 5; ++round) { #ifdef NOT_CONSISTENT - if (pthread_mutex_init (&m, &a) != 0) + if (pthread_mutex_init (&m1 , &a) != 0) + { + puts ("mutex_init m1 failed"); + return 1; + } + if (pthread_mutex_init (&m2 , &a) != 0) { - puts ("mutex_init failed"); + puts ("mutex_init m2 failed"); return 1; } #endif @@ -157,15 +176,27 @@ do_test (void) } } - e = LOCK (&m); + e = LOCK (&m1); if (e == 0) { - printf ("%ld: parent: mutex_lock succeeded\n", round); + printf ("%ld: parent: mutex_lock m1 succeeded\n", round); return 1; } if (e != EOWNERDEAD) { - printf ("%ld: parent: mutex_lock returned wrong code\n", round); + printf ("%ld: parent: mutex_lock m1 returned wrong code\n", round); + return 1; + } + + e = LOCK (&m2); + if (e == 0) + { + printf ("%ld: parent: mutex_lock m2 succeeded\n", round); + return 1; + } + if (e != EOWNERDEAD) + { + printf ("%ld: parent: mutex_lock m2 returned wrong code\n", round); return 1; } @@ -187,47 +218,86 @@ do_test (void) #endif #ifndef NOT_CONSISTENT - e = pthread_mutex_consistent_np (&m); + e = pthread_mutex_consistent_np (&m1); if (e != 0) { - printf ("%ld: mutex_consistent failed with error %d\n", round, e); + printf ("%ld: mutex_consistent m1 failed with error %d\n", round, e); + return 1; + } + + e = pthread_mutex_consistent_np (&m2); + if (e != 0) + { + printf ("%ld: mutex_consistent m2 failed with error %d\n", round, e); return 1; } #endif - e = pthread_mutex_unlock (&m); + e = pthread_mutex_unlock (&m1); + if (e != 0) + { + printf ("%ld: mutex_unlock m1 failed\n", round); + return 1; + } + + e = pthread_mutex_unlock (&m2); if (e != 0) { - printf ("%ld: mutex_unlocked failed\n", round); + printf ("%ld: mutex_unlock m2 failed\n", round); return 1; } #ifdef NOT_CONSISTENT - e = LOCK (&m); + e = LOCK (&m1); + if (e == 0) + { + printf ("%ld: locking inconsistent mutex m1 succeeded\n", round); + return 1; + } + if (e != ENOTRECOVERABLE) + { + printf ("%ld: locking inconsistent mutex m1 failed with error %d\n", + round, e); + return 1; + } + + if (pthread_mutex_destroy (&m1) != 0) + { + puts ("mutex_destroy m1 failed"); + return 1; + } + + e = LOCK (&m2); if (e == 0) { - printf ("%ld: locking inconsistent mutex succeeded\n", round); + printf ("%ld: locking inconsistent mutex m2 succeeded\n", round); return 1; } if (e != ENOTRECOVERABLE) { - printf ("%ld: locking inconsistent mutex failed with error %d\n", + printf ("%ld: locking inconsistent mutex m2 failed with error %d\n", round, e); return 1; } - if (pthread_mutex_destroy (&m) != 0) + if (pthread_mutex_destroy (&m2) != 0) { - puts ("mutex_destroy failed"); + puts ("mutex_destroy m2 failed"); return 1; } #endif } #ifndef NOT_CONSISTENT - if (pthread_mutex_destroy (&m) != 0) + if (pthread_mutex_destroy (&m1) != 0) + { + puts ("mutex_destroy m1 failed"); + return 1; + } + + if (pthread_mutex_destroy (&m2) != 0) { - puts ("mutex_destroy failed"); + puts ("mutex_destroy m2 failed"); return 1; } #endif -- cgit 1.4.1