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 <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.
This commit is contained in:
Samuel Thibault 2018-03-04 19:11:26 +01:00
parent 0d13dfa17b
commit a5df0318ef
21 changed files with 50 additions and 0 deletions

View 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

View 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

View 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

View 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

View 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__

View File

@ -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.
*/

View 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

View 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

View 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

View 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

View 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. */
@ -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 */

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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