]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: add gscope support
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 4 Mar 2018 18:11:26 +0000 (19:11 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 11 Mar 2018 12:06:33 +0000 (13:06 +0100)
* 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 <atomic.h>.
[!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.

21 files changed:
elf/dl-support.c
sysdeps/aarch64/nptl/tls.h
sysdeps/alpha/nptl/tls.h
sysdeps/arm/nptl/tls.h
sysdeps/generic/ldsodefs.h
sysdeps/generic/tls.h
sysdeps/hppa/nptl/tls.h
sysdeps/i386/nptl/tls.h
sysdeps/ia64/nptl/tls.h
sysdeps/m68k/nptl/tls.h
sysdeps/mach/hurd/tls.h
sysdeps/microblaze/nptl/tls.h
sysdeps/mips/nptl/tls.h
sysdeps/nios2/nptl/tls.h
sysdeps/powerpc/nptl/tls.h
sysdeps/riscv/nptl/tls.h
sysdeps/s390/nptl/tls.h
sysdeps/sh/nptl/tls.h
sysdeps/sparc/nptl/tls.h
sysdeps/tile/nptl/tls.h
sysdeps/x86_64/nptl/tls.h

index 114f77a8e5553565de2100ce891147070cc58e3c..b5f10d5aa54900b5b71d89b4cd9e8f9bd0396f05 100644 (file)
@@ -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
index ac39c2404558912a647b805b13bb20d3c413424e..200334f84a2ba0564a84c1243c9b6b261bba0f5d 100644 (file)
@@ -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
index 084aba931bf2265e9808dca158c8b0df5492a05f..482c8f855c307976053f07340d8782e0f4884529 100644 (file)
@@ -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
index bbe2cd885e201b3c0c9a2ead7fce5105f4758f9a..ca0352dafc237ffdcc87b2a289b9448c2a1eb8a7 100644 (file)
@@ -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
index 5e1b24ecb512780e0510bb97126d184517158fd1..d3013f6ec69df5fe1fdf1dea50a066e68c6020df 100644 (file)
@@ -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__
index e66b8fd08f0bb19033ce2138fc38a099a8e6c01a..01cbbeb7ba7e8e9571e34d7212d7e09dd0f8a6dd 100644 (file)
      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.
   */
index a64b150420b4293d0cfa5c7bd97c2447fc72a0bb..2b94e346c103292eb9d1367354fe3160bb69ce9b 100644 (file)
@@ -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
index fcda135b7cf7dfee38cbde24cfa828a612980d64..8ca092469269c7075401f104f37674775b7a3c0c 100644 (file)
@@ -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
index 80738f53573e08105340eddb9068b9eaa1cfcc86..8760ee3b3ae8af2dbb2663288eeb0c7bbe3dcb33 100644 (file)
@@ -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
index cadeb84c9ace5d9da0e54ed1f946cda6adf5ea01..53be3a02cc3ddf44c42de8a9bfdc951b27cc082c 100644 (file)
@@ -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
index faff87c7b583796ffec8acffcd1ee9fabda49e2c..67c657b65560a3481b42fb83dfe78ca26fa2cf7d 100644 (file)
@@ -27,6 +27,7 @@
 # include <sysdep.h>
 # include <mach/mig_errors.h>
 # include <mach.h>
+# include <atomic.h>
 
 
 /* This is the size of the initial TCB.  */
 # 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 */
 
 
index aa5e2dd970e7cff3b1d43422ed9e88b049166767..8b489740f24f6ea6ddd8b041e5792695225a9c37 100644 (file)
@@ -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
index 5f8cd2158c1f7916d0cce275a104f66cc3803021..777432fe1a080ffd707531d1082bec89c6e4f313 100644 (file)
@@ -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
index 47c7a877dc0553623d22ae859a8ffb62a6dedc95..6fedb2a556ab915fa5f9a0dd505538695b251288 100644 (file)
@@ -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
index 2418998d344eb36645908740eba991e2ce5e9c09..f88fed5ecf9c1be26912dac212953bb12e1889d6 100644 (file)
@@ -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
index 4c92afc58b509a03a588a1d79dd9cc5d976d3c9f..7745d59044559e79e9a2e095c8caed21d425b550 100644 (file)
@@ -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
index 63411e51b007d7be422657c8134bf4205a507e15..37692e96ed803f4aaa61448ef439945b8f46434d 100644 (file)
@@ -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
index adb35eaf7d77971cb434a58413819c8638c09d28..2585312f27cf1f4e0bd06981628393946b65b265 100644 (file)
@@ -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
index d8548f3573886079c5dc9dee2c74b287ede76461..8a547f138e8a391e5c116600abb4438cd7c4b0e2 100644 (file)
@@ -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
index 2cb30592f069543103d25c810ba646335840e57b..45d6c53e218d372570f933a1544af71ac65fb739 100644 (file)
@@ -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
index bdd02376f985b102ea76b54fb5b4f0f4fcbc19bb..059f9675a0c40cd29286929f207ac4f6fc0e3fff 100644 (file)
@@ -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