diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-08-01 00:10:03 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-08-01 00:10:03 +0200 |
commit | 42fc12ef7345855ed6e2f23f863a16f43c2a8078 (patch) | |
tree | 2db81f345f73ecdfb94bba9936a9dd0661b40bc8 /mach/setup-thread.c | |
parent | d4b54bdff0064c36097dd5468f8aca9257472e9a (diff) | |
download | glibc-42fc12ef7345855ed6e2f23f863a16f43c2a8078.zip glibc-42fc12ef7345855ed6e2f23f863a16f43c2a8078.tar.gz glibc-42fc12ef7345855ed6e2f23f863a16f43c2a8078.tar.bz2 |
hurd: Fix exec usage of mach_setup_thread
Exec needs that mach_setup_thread does *not* set up TLS since it works on
another task, so we have to split this into mach_setup_tls.
* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
(__mach_setup_tls): ... new function.
(mach_setup_tls): New alias.
* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
__mach_setup_thread.
* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
* mach/Versions [libc] (mach_setup_tls): Add symbol.
* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
Diffstat (limited to 'mach/setup-thread.c')
-rw-r--r-- | mach/setup-thread.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/mach/setup-thread.c b/mach/setup-thread.c index 79ec432..ce60a73 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -42,7 +42,6 @@ __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; @@ -52,10 +51,6 @@ __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; @@ -78,9 +73,24 @@ __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; - if (error = __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR, - (natural_t *) &ts, tssize)) - return error; + return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR, + (natural_t *) &ts, tssize); +} + +weak_alias (__mach_setup_thread, mach_setup_thread) + +/* Give THREAD a TLS area. */ +kern_return_t +__mach_setup_tls (thread_t thread) +{ + kern_return_t error; + struct machine_thread_state ts; + mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; + tcbhead_t *tcb; + + tcb = _dl_allocate_tls (NULL); + if (tcb == NULL) + return KERN_RESOURCE_SHORTAGE; if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, (natural_t *) &ts, &tssize)) @@ -91,8 +101,7 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc, error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, (natural_t *) &ts, tssize); - return error; } -weak_alias (__mach_setup_thread, mach_setup_thread) +weak_alias (__mach_setup_tls, mach_setup_tls) |