From: Samuel Thibault Date: Sun, 4 Mar 2018 18:11:26 +0000 (+0100) Subject: hurd: add gscope support X-Git-Tag: glibc-2.28~485 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5df0318ef30a4dcff3fa2cb82265f641813d9ea;p=thirdparty%2Fglibc.git hurd: add gscope support * elf/dl-support.c [!THREAD_GSCOPE_IN_TCB] (_dl_thread_gscope_count): Define variable. * sysdeps/generic/ldsodefs.h [!THREAD_GSCOPE_IN_TCB] (struct rtld_global): Add _dl_thread_gscope_count member. * sysdeps/mach/hurd/tls.h: Include . [!defined __ASSEMBLER__] (THREAD_GSCOPE_GLOBAL, THREAD_GSCOPE_SET_FLAG, THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define macros. * sysdeps/generic/tls.h: Document THREAD_GSCOPE_IN_TCB. * sysdeps/aarch64/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/alpha/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/arm/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/hppa/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/i386/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/ia64/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/m68k/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/microblaze/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/mips/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/nios2/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/powerpc/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/riscv/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/s390/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/sh/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/sparc/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/tile/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. * sysdeps/x86_64/nptl/tls.h: Define THREAD_GSCOPE_IN_TCB to 1. --- diff --git a/elf/dl-support.c b/elf/dl-support.c index 114f77a8e55..b5f10d5aa54 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -188,6 +188,9 @@ int (*_dl_make_stack_executable_hook) (void **) = _dl_make_stack_executable; /* Function in libpthread to wait for termination of lookups. */ void (*_dl_wait_lookup_done) (void); +#if !THREAD_GSCOPE_IN_TCB +int _dl_thread_gscope_count; +#endif struct dl_scope_free_list *_dl_scope_free_list; #ifdef NEED_DL_SYSINFO diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h index ac39c240455..200334f84a2 100644 --- a/sysdeps/aarch64/nptl/tls.h +++ b/sysdeps/aarch64/nptl/tls.h @@ -109,6 +109,7 @@ typedef struct descr->member[idx] = (value) /* Get and set the global scope generation counter in struct pthread. */ +# define THREAD_GSCOPE_IN_TCB 1 # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h index 084aba931bf..482c8f855c3 100644 --- a/sysdeps/alpha/nptl/tls.h +++ b/sysdeps/alpha/nptl/tls.h @@ -103,6 +103,7 @@ typedef struct descr->member[idx] = (value) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/arm/nptl/tls.h b/sysdeps/arm/nptl/tls.h index bbe2cd885e2..ca0352dafc2 100644 --- a/sysdeps/arm/nptl/tls.h +++ b/sysdeps/arm/nptl/tls.h @@ -100,6 +100,7 @@ typedef struct descr->member[idx] = (value) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 5e1b24ecb51..d3013f6ec69 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -435,6 +435,9 @@ struct rtld_global size_t count; void *list[50]; } *_dl_scope_free_list; +#if !THREAD_GSCOPE_IN_TCB + EXTERN int _dl_thread_gscope_count; +#endif #ifdef SHARED }; # define __rtld_global_attribute__ diff --git a/sysdeps/generic/tls.h b/sysdeps/generic/tls.h index e66b8fd08f0..01cbbeb7ba7 100644 --- a/sysdeps/generic/tls.h +++ b/sysdeps/generic/tls.h @@ -71,4 +71,10 @@ This macro returns the address of the DTV of the current thread. This normally is done using the thread register which points to the dtv or the TCB (from which the DTV can found). + + + THREAD_GSCOPE_IN_TCB + + This should be set to 1 if the global scope flag is stored within the TCB. + When set to 0, GL(_dl_thread_gscope_count) will be defined to store it. */ diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h index a64b150420b..2b94e346c10 100644 --- a/sysdeps/hppa/nptl/tls.h +++ b/sysdeps/hppa/nptl/tls.h @@ -134,6 +134,7 @@ static inline void __set_cr27(struct pthread *cr27) } /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h index fcda135b7cf..8ca09246926 100644 --- a/sysdeps/i386/nptl/tls.h +++ b/sysdeps/i386/nptl/tls.h @@ -411,6 +411,7 @@ tls_fill_user_desc (union user_desc_init *desc, /* Get and set the global scope generation counter in the TCB head. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h index 80738f53573..8760ee3b3ae 100644 --- a/sysdeps/ia64/nptl/tls.h +++ b/sysdeps/ia64/nptl/tls.h @@ -155,6 +155,7 @@ register struct pthread *__thread_self __asm__("r13"); = THREAD_GET_POINTER_GUARD ()) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h index cadeb84c9ac..53be3a02cc3 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -134,6 +134,7 @@ extern void * __m68k_read_tp (void); # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h index faff87c7b58..67c657b6556 100644 --- a/sysdeps/mach/hurd/tls.h +++ b/sysdeps/mach/hurd/tls.h @@ -27,6 +27,7 @@ # include # include # include +# include /* This is the size of the initial TCB. */ @@ -51,6 +52,26 @@ # define GET_DTV(descr) \ (((tcbhead_t *) (descr))->dtv) +/* Global scope switch support. */ +#define THREAD_GSCOPE_IN_TCB 0 +#define THREAD_GSCOPE_GLOBAL +#define THREAD_GSCOPE_SET_FLAG() \ + atomic_exchange_and_add_acq (&GL(dl_thread_gscope_count), 1) +#define THREAD_GSCOPE_RESET_FLAG() \ + do \ + if (atomic_exchange_and_add_rel (&GL(dl_thread_gscope_count), -1) == 1) \ + lll_wake (&GL(dl_thread_gscope_count), 0); \ + while (0) +#define THREAD_GSCOPE_WAIT() \ + do \ + { \ + int count; \ + atomic_write_barrier (); \ + while ((count = GL(dl_thread_gscope_count))) \ + lll_wait (&GL(dl_thread_gscope_count), count, 0); \ + } \ + while (0) + #endif /* !ASSEMBLER */ diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h index aa5e2dd970e..8b489740f24 100644 --- a/sysdeps/microblaze/nptl/tls.h +++ b/sysdeps/microblaze/nptl/tls.h @@ -116,6 +116,7 @@ typedef struct (descr->member[idx] = (value)) /* Get and set the global scope generation counter in struct pthread. */ +# define THREAD_GSCOPE_IN_TCB 1 # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index 5f8cd2158c1..777432fe1a0 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -159,6 +159,7 @@ typedef struct # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h index 47c7a877dc0..6fedb2a556a 100644 --- a/sysdeps/nios2/nptl/tls.h +++ b/sysdeps/nios2/nptl/tls.h @@ -137,6 +137,7 @@ register struct pthread *__thread_self __asm__("r23"); # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h index 2418998d344..f88fed5ecf9 100644 --- a/sysdeps/powerpc/nptl/tls.h +++ b/sysdeps/powerpc/nptl/tls.h @@ -236,6 +236,7 @@ register void *__thread_register __asm__ ("r13"); # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h index 4c92afc58b5..7745d590445 100644 --- a/sysdeps/riscv/nptl/tls.h +++ b/sysdeps/riscv/nptl/tls.h @@ -118,6 +118,7 @@ typedef struct # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +# define THREAD_GSCOPE_IN_TCB 1 # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h index 63411e51b00..37692e96ed8 100644 --- a/sysdeps/s390/nptl/tls.h +++ b/sysdeps/s390/nptl/tls.h @@ -169,6 +169,7 @@ typedef struct #define THREAD_COPY_POINTER_GUARD(descr) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h index adb35eaf7d7..2585312f27c 100644 --- a/sysdeps/sh/nptl/tls.h +++ b/sysdeps/sh/nptl/tls.h @@ -141,6 +141,7 @@ typedef struct ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;}) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h index d8548f35738..8a547f138e8 100644 --- a/sysdeps/sparc/nptl/tls.h +++ b/sysdeps/sparc/nptl/tls.h @@ -141,6 +141,7 @@ register struct pthread *__thread_self __asm__("%g7"); ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ()) /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/tile/nptl/tls.h b/sysdeps/tile/nptl/tls.h index 2cb30592f06..45d6c53e218 100644 --- a/sysdeps/tile/nptl/tls.h +++ b/sysdeps/tile/nptl/tls.h @@ -157,6 +157,7 @@ register void *__thread_pointer asm ("tp"); # define NO_TLS_OFFSET -1 /* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_IN_TCB 1 #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1 #define THREAD_GSCOPE_FLAG_WAIT 2 diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h index bdd02376f98..059f9675a0c 100644 --- a/sysdeps/x86_64/nptl/tls.h +++ b/sysdeps/x86_64/nptl/tls.h @@ -343,6 +343,7 @@ typedef struct /* Get and set the global scope generation counter in the TCB head. */ +# define THREAD_GSCOPE_IN_TCB 1 # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2