diff options
Diffstat (limited to 'libpthread/linuxthreads')
21 files changed, 111 insertions, 50 deletions
diff --git a/libpthread/linuxthreads/descr.h b/libpthread/linuxthreads/descr.h index f99638396..0f50d4deb 100644 --- a/libpthread/linuxthreads/descr.h +++ b/libpthread/linuxthreads/descr.h @@ -130,7 +130,7 @@ struct _pthread_descr_struct void *__padding[16]; } p_header; # define p_multiple_threads p_header.data.multiple_threads -#elif TLS_MULTIPLE_THREADS_IN_TCB +#elif defined TLS_MULTIPLE_THREADS_IN_TCB && TLS_MULTIPLE_THREADS_IN_TCB int p_multiple_threads; #endif diff --git a/libpthread/linuxthreads/internals.h b/libpthread/linuxthreads/internals.h index c8e4262d6..8e270e37a 100644 --- a/libpthread/linuxthreads/internals.h +++ b/libpthread/linuxthreads/internals.h @@ -531,9 +531,9 @@ weak_extern (__pthread_thread_self) # define __manager_thread __pthread_manager_threadp #endif -extern __always_inline pthread_descr +static __always_inline pthread_descr check_thread_self (void); -extern __always_inline pthread_descr +static __always_inline pthread_descr check_thread_self (void) { pthread_descr self = thread_self (); diff --git a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h index 853ac6f04..97c38394b 100644 --- a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h @@ -23,8 +23,10 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif #ifdef __linux__ @@ -33,9 +35,6 @@ # include <machine/pal.h> #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Get some notion of the current stack. Need not be exactly the top of the stack, just something somewhere in the current frame. */ #define CURRENT_STACK_FRAME stack_pointer diff --git a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h index a4c2f314c..9ffc8bdc4 100644 --- a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h @@ -22,13 +22,12 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* This will not work on ARM1 or ARM2 because SWP is lacking on those machines. Unfortunately we have no way to detect this at compile time; let's hope nobody tries to use one. */ diff --git a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h new file mode 100644 index 000000000..903a7ed54 --- /dev/null +++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h @@ -0,0 +1,73 @@ +/* Machine-dependent pthreads configuration and inline functions. + * + * Copyright (C) 2005-2007 Atmel Corporation + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License. See the file "COPYING.LIB" in the main directory of this + * archive for more details. + */ +#ifndef _PT_MACHINE_H +#define _PT_MACHINE_H 1 + +#include <features.h> + +#ifndef PT_EI +# define PT_EI __extern_always_inline +#endif + +static inline int +_test_and_set (int *p, int v) __THROW +{ + int result; + + __asm__ __volatile__( + "/* Inline test and set */\n" + " xchg %[old], %[mem], %[new]" + : [old] "=&r"(result) + : [mem] "r"(p), [new] "r"(v) + : "memory"); + + return result; +} + +extern long int testandset (int *spinlock); +extern int __compare_and_swap (long int *p, long int oldval, long int newval); + +/* Spinlock implementation; required. */ +PT_EI long int +testandset (int *spinlock) +{ + return _test_and_set(spinlock, 1); +} + + +/* Get some notion of the current stack. Need not be exactly the top + of the stack, just something somewhere in the current frame. */ +#define CURRENT_STACK_FRAME stack_pointer +register char * stack_pointer __asm__ ("sp"); + +/* Compare-and-swap for semaphores. */ + +#define HAS_COMPARE_AND_SWAP +PT_EI int +__compare_and_swap(long int *p, long int oldval, long int newval) +{ + int result; + + __asm__ __volatile__( + "/* Inline compare and swap */\n" + "1: ssrf 5\n" + " ld.w %[result], %[mem]\n" + " eor %[result], %[old]\n" + " brne 2f\n" + " stcond %[mem], %[new]\n" + " brne 1b\n" + "2:" + : [result] "=&r"(result), [mem] "=m"(*p) + : "m"(*p), [new] "r"(newval), [old] "r"(oldval) + : "cc", "memory"); + + return result == 0; +} + +#endif /* pt-machine.h */ diff --git a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h index 431da7101..33cf57908 100644 --- a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h @@ -21,13 +21,12 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - PT_EI long int testandset (int *spinlock) { diff --git a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h index abc25c4ca..780af7b96 100644 --- a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h @@ -22,15 +22,13 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> #include <bits/initspin.h> #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Get some notion of the current stack. Need not be exactly the top of the stack, just something somewhere in the current frame. */ #define CURRENT_STACK_FRAME stack_pointer diff --git a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h index 1c75bf980..222d44a3f 100644 --- a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h @@ -23,7 +23,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif #include "kernel-features.h" diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h index 8483d4ef6..f96452599 100644 --- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h @@ -29,12 +29,13 @@ #ifndef __ASSEMBLER__ #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif +/* extern long int testandset (int *spinlock); extern int __compare_and_swap (long int *p, long int oldval, long int newval); - +*/ /* Get some notion of the current stack. Need not be exactly the top of the stack, just something somewhere in the current frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) diff --git a/libpthread/linuxthreads/sysdeps/i386/useldt.h b/libpthread/linuxthreads/sysdeps/i386/useldt.h index a2eb53fed..fa9a2a528 100644 --- a/libpthread/linuxthreads/sysdeps/i386/useldt.h +++ b/libpthread/linuxthreads/sysdeps/i386/useldt.h @@ -87,7 +87,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t); because we inherited the value set up in the main thread by TLS setup. We need to extract that value and set up the same segment in this thread. */ -#if USE_TLS +#if defined (USE_TLS) && USE_TLS # define DO_SET_THREAD_AREA_REUSE(nr) 1 #else /* Without TLS, we do the initialization of the main thread, where NR == 0. */ diff --git a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h index be1d37986..e36468a74 100644 --- a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h @@ -21,15 +21,13 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> #include <ia64intrin.h> #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Make sure gcc doesn't try to be clever and move things around on us. We need to use _exactly_ the address the user gave us, not some alias that contains the same information. */ diff --git a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h index ad524d6d2..a13c06946 100644 --- a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h @@ -22,13 +22,12 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) diff --git a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h index 96f7a7f8c..0ab7ac13f 100644 --- a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h @@ -24,17 +24,14 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> #include <sgidefs.h> #include <sys/tas.h> #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - - /* Spinlock implementation; required. */ PT_EI long int diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h index 8363d16d0..bfb13df67 100644 --- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h @@ -26,7 +26,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h index 562e69fa1..d7ed84108 100644 --- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h @@ -25,7 +25,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h index 398332965..d52d600ad 100644 --- a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h @@ -23,7 +23,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h index 49f8ae2b9..187e1f872 100644 --- a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h @@ -23,7 +23,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h b/libpthread/linuxthreads/sysdeps/sh/pt-machine.h index 02545e6b4..4ec87ad89 100644 --- a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/sh/pt-machine.h @@ -22,14 +22,13 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +#include <features.h> + #ifndef __ASSEMBLER__ #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h index 322a52051..43c05f2a6 100644 --- a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h @@ -23,7 +23,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h index f65c13be1..815d70e8d 100644 --- a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h @@ -23,7 +23,7 @@ #define _PT_MACHINE_H 1 #ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h index b30ab8518..23615dbd8 100644 --- a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h @@ -21,6 +21,8 @@ #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 +# include <features.h> + #ifndef __ASSEMBLER__ # include <stddef.h> /* For offsetof. */ # include <stdlib.h> /* For abort(). */ @@ -28,12 +30,9 @@ # ifndef PT_EI -# define PT_EI extern inline __attribute__ ((always_inline)) +# define PT_EI __extern_always_inline # endif -extern long int testandset (int *spinlock); -extern int __compare_and_swap (long int *p, long int oldval, long int newval); - /* Get some notion of the current stack. Need not be exactly the top of the stack, just something somewhere in the current frame. */ # define CURRENT_STACK_FRAME stack_pointer |
