diff options
author | Roland McGrath <roland@gnu.org> | 2004-09-22 21:21:10 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2004-09-22 21:21:10 +0000 |
commit | b5707b44d25d7af61b0338c2a2206c036eaf7337 (patch) | |
tree | d8b9e865cbc78d64835a63959370865a2a043223 /linuxthreads/sysdeps | |
parent | 4ff389feb39f2eb649530b843d478c80c27ab4cf (diff) | |
download | glibc-b5707b44d25d7af61b0338c2a2206c036eaf7337.tar.gz glibc-b5707b44d25d7af61b0338c2a2206c036eaf7337.tar.xz glibc-b5707b44d25d7af61b0338c2a2206c036eaf7337.zip |
Changes and additions migrated from cvs.devel.redhat.com:/cvs/devel/glibc to fedora-branch
Diffstat (limited to 'linuxthreads/sysdeps')
-rw-r--r-- | linuxthreads/sysdeps/alpha/tls.h | 46 | ||||
-rw-r--r-- | linuxthreads/sysdeps/i386/tls.h | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/ia64/tls.h | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/powerpc/tls.h | 12 | ||||
-rw-r--r-- | linuxthreads/sysdeps/pthread/Makefile | 12 | ||||
-rw-r--r-- | linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym | 13 | ||||
-rw-r--r-- | linuxthreads/sysdeps/s390/tls.h | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/sh/tls.h | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/sparc/tls.h | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/x86_64/tls.h | 9 |
10 files changed, 117 insertions, 20 deletions
diff --git a/linuxthreads/sysdeps/alpha/tls.h b/linuxthreads/sysdeps/alpha/tls.h index 261d333eb4..9e15318b79 100644 --- a/linuxthreads/sysdeps/alpha/tls.h +++ b/linuxthreads/sysdeps/alpha/tls.h @@ -53,54 +53,76 @@ typedef struct # include <sysdep.h> /* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +# define TLS_INIT_TCB_SIZE 0 /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (tcbhead_t) +# define TLS_TCB_SIZE 0 /* Alignment requirements for the TCB. */ -# define TLS_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_PRE_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) \ + + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) +# else +# include <nptl-struct-pthread.h> +# define TLS_PRE_TCB_SIZE \ + ((sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) \ + + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) +# endif /* The DTV is allocated at the TP; the TCB is placed elsewhere. */ # define TLS_DTV_AT_TP 1 +/* The following assumes that TP (R2 or R13) points to the end of the + TCB + 0x7000 (per the ABI). This implies that TCB address is + TP - 0x7000. As we define TLS_DTV_AT_TP we can + assume that the pthread struct is allocated immediately ahead of the + TCB. This implies that the pthread_descr address is + TP - (TLS_PRE_TCB_SIZE + 0x7000). */ +/* ??? PPC uses offset 0x7000; seems like a good idea for alpha too, + but binutils not yet changed to match. */ +# define TLS_TCB_OFFSET 0 + /* Install the dtv pointer. The pointer passed is to the element with index -1 which contain the length. */ # define INSTALL_DTV(TCBP, DTVP) \ - (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1) + (((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1) /* Install new dtv for current thread. */ # define INSTALL_NEW_DTV(DTV) \ - (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV)) + (THREAD_DTV() = (DTV)) /* Return dtv of given thread descriptor. */ # define GET_DTV(TCBP) \ - (((tcbhead_t *) (TCBP))->dtv) + (((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) \ - (__builtin_set_thread_pointer (TCBP), 0) + (__builtin_set_thread_pointer ((void *) (TCBP) + TLS_TCB_OFFSET), NULL) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ - (((tcbhead_t *)__builtin_thread_pointer ())->dtv) + (((tcbhead_t *) (__builtin_thread_pointer () - TLS_TCB_OFFSET))[-1].dtv) /* Return the thread descriptor for the current thread. */ # undef THREAD_SELF # define THREAD_SELF \ - ((pthread_descr)__builtin_thread_pointer () - 1) + ((pthread_descr) (__builtin_thread_pointer () \ + - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) # undef INIT_THREAD_SELF # define INIT_THREAD_SELF(DESCR, NR) \ - __builtin_set_thread_pointer ((struct _pthread_descr_struct *)(DESCR) + 1) + __builtin_set_thread_pointer ((char *)(DESCR) \ + + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE) /* Get the thread descriptor definition. */ # include <linuxthreads/descr.h> diff --git a/linuxthreads/sysdeps/i386/tls.h b/linuxthreads/sysdeps/i386/tls.h index 569a897474..84d87db359 100644 --- a/linuxthreads/sysdeps/i386/tls.h +++ b/linuxthreads/sysdeps/i386/tls.h @@ -81,7 +81,14 @@ typedef struct # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) diff --git a/linuxthreads/sysdeps/ia64/tls.h b/linuxthreads/sysdeps/ia64/tls.h index 3ec2eda783..6bdf819d8d 100644 --- a/linuxthreads/sysdeps/ia64/tls.h +++ b/linuxthreads/sysdeps/ia64/tls.h @@ -60,7 +60,14 @@ typedef struct # define TLS_TCB_SIZE sizeof (tcbhead_t) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_PRE_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) diff --git a/linuxthreads/sysdeps/powerpc/tls.h b/linuxthreads/sysdeps/powerpc/tls.h index f6eb48b434..fda953976e 100644 --- a/linuxthreads/sysdeps/powerpc/tls.h +++ b/linuxthreads/sysdeps/powerpc/tls.h @@ -64,11 +64,19 @@ typedef struct # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE \ +# ifndef IS_IN_rtld +# define TLS_PRE_TCB_SIZE \ (sizeof (struct _pthread_descr_struct) \ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) +# else +# include <nptl-struct-pthread.h> +# define TLS_PRE_TCB_SIZE \ + ((sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) \ + + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) +# endif -/* The following assumes that TP (R2 or R13) is points to the end of the +/* The following assumes that TP (R2 or R13) points to the end of the TCB + 0x7000 (per the ABI). This implies that TCB address is TP - 0x7000. As we define TLS_DTV_AT_TP we can assume that the pthread_descr is allocated immediately ahead of the diff --git a/linuxthreads/sysdeps/pthread/Makefile b/linuxthreads/sysdeps/pthread/Makefile index f73f40e9d9..6f5a296e3c 100644 --- a/linuxthreads/sysdeps/pthread/Makefile +++ b/linuxthreads/sysdeps/pthread/Makefile @@ -12,3 +12,15 @@ endif ifeq ($(subdir),posix) CFLAGS-confstr.c += -DLIBPTHREAD_VERSION="\"$(shell sed 's/\(.*\) by .*/\1/' ../linuxthreads/Banner)\"" endif + +ifeq ($(subdir),csu) +# Find out the size of NPTL struct pthread +ifneq (,$(wildcard $(..)nptl/descr.h)) +gen-as-const-headers += nptl-struct-pthread.sym +else +before-compile += $(common-objpfx)nptl-struct-pthread.h +common-generated += nptl-struct-pthread.h +$(common-objpfx)nptl-struct-pthread.h: + @echo '#define NPTL_STRUCT_PTHREAD_SIZE 0' > $@ +endif +endif diff --git a/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym b/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym new file mode 100644 index 0000000000..8df995270e --- /dev/null +++ b/linuxthreads/sysdeps/pthread/nptl-struct-pthread.sym @@ -0,0 +1,13 @@ +#ifdef HAVE_TLS_SUPPORT +# ifndef HAVE_FORCED_UNWIND +# define HAVE_FORCED_UNWIND 1 +# endif +# define __need_struct_pthread_size +# include <nptl/descr.h> +#endif + +-- + +#ifdef HAVE_TLS_SUPPORT +NPTL_STRUCT_PTHREAD_SIZE sizeof (struct pthread) +#endif diff --git a/linuxthreads/sysdeps/s390/tls.h b/linuxthreads/sysdeps/s390/tls.h index 41a83a72fb..f420195bd2 100644 --- a/linuxthreads/sysdeps/s390/tls.h +++ b/linuxthreads/sysdeps/s390/tls.h @@ -72,7 +72,14 @@ typedef struct # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) diff --git a/linuxthreads/sysdeps/sh/tls.h b/linuxthreads/sysdeps/sh/tls.h index 17a247c6b6..bc9d44fa85 100644 --- a/linuxthreads/sysdeps/sh/tls.h +++ b/linuxthreads/sysdeps/sh/tls.h @@ -64,7 +64,14 @@ typedef struct # define TLS_TCB_SIZE sizeof (tcbhead_t) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_PRE_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) diff --git a/linuxthreads/sysdeps/sparc/tls.h b/linuxthreads/sysdeps/sparc/tls.h index 6b1966fe1c..5053824058 100644 --- a/linuxthreads/sysdeps/sparc/tls.h +++ b/linuxthreads/sysdeps/sparc/tls.h @@ -64,7 +64,14 @@ typedef struct # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) diff --git a/linuxthreads/sysdeps/x86_64/tls.h b/linuxthreads/sysdeps/x86_64/tls.h index 63feebdb2c..d979bbd896 100644 --- a/linuxthreads/sysdeps/x86_64/tls.h +++ b/linuxthreads/sysdeps/x86_64/tls.h @@ -66,7 +66,14 @@ typedef struct # define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# ifndef IS_IN_rtld +# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct) +# else +# include <nptl-struct-pthread.h> +# define TLS_TCB_SIZE \ + (sizeof (struct _pthread_descr_struct) > NPTL_STRUCT_PTHREAD_SIZE \ + ? sizeof (struct _pthread_descr_struct) : NPTL_STRUCT_PTHREAD_SIZE) +# endif /* Alignment requirements for the TCB. */ # define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct) |