hurd: add TLS support

System Internals / glibc - Samuel Thibault [ens-lyon.org] - 17 March 2018 02:17 EDT

- 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 . (__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.

f8baf2a224 hurd: add TLS support
ChangeLog | 32 ++++++++++++++++++++++
hurd/hurdfault.c | 1 +
mach/setup-thread.c | 23 ++++++++++++++--
sysdeps/generic/thread_state.h | 5 ++++
sysdeps/mach/hurd/fork.c | 7 ++++-
sysdeps/mach/hurd/i386/tls.h | 53 +++++++++++++++++++++++++++++++++----
sysdeps/mach/hurd/i386/trampoline.c | 2 +-
sysdeps/mach/i386/thread_state.h | 13 ++++++++-
sysdeps/mach/thread_state.h | 6 +++++
9 files changed, 132 insertions(+), 10 deletions(-)

Upstream: sourceware.org


  • Share