diff options
-rw-r--r-- | mach/setup-thread.c | 10 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/init-first.c | 11 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/tls.h | 21 | ||||
-rw-r--r-- | sysdeps/mach/hurd/profil.c | 2 | ||||
-rw-r--r-- | sysdeps/mach/hurd/setitimer.c | 2 | ||||
-rw-r--r-- | sysdeps/mach/thread_state.h | 2 |
6 files changed, 29 insertions, 19 deletions
diff --git a/mach/setup-thread.c b/mach/setup-thread.c index 1505027feb..c1de3a1fb6 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -88,16 +88,16 @@ __mach_setup_tls (thread_t thread) 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)) return error; assert (tssize == MACHINE_THREAD_STATE_COUNT); - tcb = _dl_allocate_tls(NULL); - if (!tcb) - return KERN_RESOURCE_SHORTAGE; - - _hurd_tls_new(thread, &ts, tcb); + _hurd_tls_new (thread, &ts, tcb); error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, (natural_t *) &ts, tssize); diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index a068d028c6..5252f7f214 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -117,9 +117,7 @@ init1 (int argc, char *arg0, ...) then after the environment pointers there is no Hurd data block; the argument strings start there. */ if ((void *) d == argv[0]) - { - return; - } + return; #ifndef SHARED __libc_enable_secure = d->flags & EXEC_SECURE; @@ -197,9 +195,10 @@ init (int *data) assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); } - /* We need to setup TLS before starting sigthread */ - extern void __pthread_initialize_minimal(void); - __pthread_initialize_minimal(); + /* We need to setup TLS before starting the signal thread. */ + extern void __pthread_initialize_minimal (void); + if (__pthread_initialize_minimal != NULL) + __pthread_initialize_minimal (); #endif diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index b8e8b32e3b..1a55fdb752 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -66,6 +66,15 @@ typedef struct #define TLS_TCB_AT_TP 1 #define TLS_DTV_AT_TP 0 +/* Alignment requirement for TCB. + + Some processors such as Intel Atom pay a big penalty on every + access using a segment override if that segment's base is not + aligned to the size of a cache line. (See Intel 64 and IA-32 + Architectures Optimization Reference Manual, section 13.3.3.3, + "Segment Base".) On such machines, a cache line is 64 bytes. */ +#define TCB_ALIGNMENT 64 + #ifndef __ASSEMBLER__ /* Use i386-specific RPCs to arrange that %gs segment register prefix @@ -76,6 +85,8 @@ typedef struct # define __i386_set_gdt(thr, sel, desc) ((void) (thr), (void) (sel), (void) (desc), MIG_BAD_ID) # endif +#define __i386_selector_is_ldt(sel) (!!((sel) & 4)) + # include <errno.h> # include <assert.h> @@ -191,10 +202,10 @@ _hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state) return 0; struct descriptor desc, *_desc = &desc; - kern_return_t err; + error_t err; unsigned int count = 1; - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + if (__glibc_unlikely (__i386_selector_is_ldt(sel))) err = __i386_get_ldt (orig, sel, 1, &_desc, &count); else err = __i386_get_gdt (orig, sel, &desc); @@ -203,7 +214,7 @@ _hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state) if (err) return err; - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + if (__glibc_unlikely (__i386_selector_is_ldt(sel))) err = __i386_set_ldt (child, sel, &desc, 1); else err = __i386_set_gdt (child, &sel, desc); @@ -222,12 +233,12 @@ _hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) return 0; HURD_TLS_DESC_DECL (desc, tcb); - kern_return_t err; + error_t err; tcb->tcb = tcb; tcb->self = child; - if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + if (__glibc_unlikely (__i386_selector_is_ldt(sel))) err = __i386_set_ldt (child, sel, &desc, 1); else err = __i386_set_gdt (child, &sel, desc); diff --git a/sysdeps/mach/hurd/profil.c b/sysdeps/mach/hurd/profil.c index 5febfbc1d3..708ce1d4cd 100644 --- a/sysdeps/mach/hurd/profil.c +++ b/sysdeps/mach/hurd/profil.c @@ -69,7 +69,7 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale) err = __mach_setup_thread (__mach_task_self (), profile_thread, &profile_waiter, NULL, NULL); if (! err) - err = __mach_setup_tls(profile_thread); + err = __mach_setup_tls (profile_thread); } else err = 0; diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c index b3341b8d4e..48346e2eab 100644 --- a/sysdeps/mach/hurd/setitimer.c +++ b/sysdeps/mach/hurd/setitimer.c @@ -226,7 +226,7 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old, &timer_thread, &_hurd_itimer_thread_stack_base, &_hurd_itimer_thread_stack_size)) - || (err = __mach_setup_tls(_hurd_itimer_thread))) + || (err = __mach_setup_tls (_hurd_itimer_thread))) { __thread_terminate (_hurd_itimer_thread); _hurd_itimer_thread = MACH_PORT_NULL; diff --git a/sysdeps/mach/thread_state.h b/sysdeps/mach/thread_state.h index 0914b84244..c382eb995a 100644 --- a/sysdeps/mach/thread_state.h +++ b/sysdeps/mach/thread_state.h @@ -38,7 +38,7 @@ #endif #endif #ifndef MACHINE_THREAD_STATE_FIX_NEW -#define MACHINE_THREAD_STATE_FIX_NEW(ts) +# define MACHINE_THREAD_STATE_FIX_NEW(ts) #endif /* These functions are of use in machine-dependent signal trampoline |