diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-03-17 03:17:36 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-03-17 03:17:36 +0100 |
commit | f8baf2a2242029600beb213d3f042e7c0482e502 (patch) | |
tree | 43df708e6da8a0cb7520bb218d6ebfcecfe54c86 /mach | |
parent | NEWS: Mention the locale data changes (bug 22848, 22937, 22963). (diff) | |
download | glibc-f8baf2a2242029600beb213d3f042e7c0482e502.tar.gz glibc-f8baf2a2242029600beb213d3f042e7c0482e502.tar.bz2 glibc-f8baf2a2242029600beb213d3f042e7c0482e502.zip |
hurd: add TLS support
* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR):
Define macro.
* sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro.
* sysdeps/mach/i386/thread_state.h
(MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to
i386_THREAD_STATE.
(MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of
i386_THREAD_STATE.
(MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use
i386_REGS_SEGS_STATE instead of i386_THREAD_STATE.
* sysdeps/mach/hurd/i386/tls.h (TCB_ALIGNMENT, HURD_SEL_LDT): New
macros.
(_hurd_tls_fork): Add original thread parameter, Duplicate existing LDT
descriptor instead of creating a new one.
(_hurd_tls_new): New function, creates a new descriptor and updates tcb.
* mach/setup-thread.c: Include <ldsodefs.h>.
(__mach_setup_thread): Call _dl_allocate_tls, pass
MACHINE_NEW_THREAD_STATE_FLAVOR to __thread_set_state instead of
MACHINE_THREAD_STATE_FLAVOR, before getting
MACHINE_THREAD_STATE_FLAVOR, calling _hurd_tls_new, and setting
MACHINE_THREAD_STATE_FLAVOR with the result.
* hurd/hurdfault.c (_hurdsig_fault_init): Call
MACHINE_THREAD_STATE_FIX_NEW.
* sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread
too. Add original thread parameter.
Diffstat (limited to 'mach')
-rw-r--r-- | mach/setup-thread.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/mach/setup-thread.c b/mach/setup-thread.c index 2eeacc2c2e..6716813825 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -19,6 +19,7 @@ #include <thread_state.h> #include <string.h> #include <mach/machine/vm_param.h> +#include <ldsodefs.h> #include "sysdep.h" /* Defines stack direction. */ #define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */ @@ -41,6 +42,7 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, vm_address_t stack; vm_size_t size; int anywhere; + tcbhead_t *tcb; size = stack_size ? *stack_size ? : STACK_SIZE : STACK_SIZE; stack = stack_base ? *stack_base ? : 0 : 0; @@ -50,6 +52,10 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, if (error) return error; + tcb = _dl_allocate_tls(NULL); + if (tcb == NULL) + return KERN_RESOURCE_SHORTAGE; + if (stack_size) *stack_size = size; @@ -72,8 +78,21 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE)) return error; - return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, - (natural_t *) &ts, tssize); + if (error = __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR, + (natural_t *) &ts, tssize)) + return error; + + if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, + (natural_t *) &ts, &tssize)) + return error; + assert (tssize == MACHINE_THREAD_STATE_COUNT); + + _hurd_tls_new(thread, &ts, tcb); + + error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, + (natural_t *) &ts, tssize); + + return error; } weak_alias (__mach_setup_thread, mach_setup_thread) |