summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-06-01 21:48:44 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-06-01 21:48:44 +0200
commit76a7dc16fab8853ef9230447fa98c70a3619dc6d (patch)
tree0709b42770249df2ffe71d97107033b78ba2e2a2
parentcc66d2cfb32983f36921b8e0f6d6568486e471ac (diff)
parentdd8cbb15da8a2d4912a7f54781537e01032f6556 (diff)
Merge commit 'refs/top-bases/t/gsync-libc-merge' into t/gsync-libc-merge
-rw-r--r--hurd/hurd/fd.h2
-rw-r--r--hurd/sysvshm.c3
-rw-r--r--mach/setup-thread.c10
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c11
-rw-r--r--sysdeps/mach/hurd/i386/tls.h21
-rw-r--r--sysdeps/mach/hurd/profil.c2
-rw-r--r--sysdeps/mach/hurd/setitimer.c2
-rw-r--r--sysdeps/mach/thread_state.h2
8 files changed, 32 insertions, 21 deletions
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h
index a4adc553ec..bd6001b310 100644
--- a/hurd/hurd/fd.h
+++ b/hurd/hurd/fd.h
@@ -203,7 +203,7 @@ __hurd_dfail (int fd, error_t err)
/* Likewise, but do not raise SIGPIPE on EPIPE if flags contain
MSG_NOSIGNAL. */
-exern int __hurd_sockfail (int fd, int flags, error_t err);
+extern int __hurd_sockfail (int fd, int flags, error_t err);
#ifdef __USE_EXTERN_INLINES
_HURD_FD_H_EXTERN_INLINE int
diff --git a/hurd/sysvshm.c b/hurd/sysvshm.c
index 5d538a6373..e049345135 100644
--- a/hurd/sysvshm.c
+++ b/hurd/sysvshm.c
@@ -26,6 +26,7 @@
#include <dirent.h>
#include <sys/stat.h>
#include <sys/shm.h>
+#include <hurdlock.h>
/* Description of an shm attachment. */
@@ -45,7 +46,7 @@ struct sysvshm_attach
static struct sysvshm_attach *sysvshm_list;
/* A lock to protect the linked list of shared memory attachments. */
-static struct mutex sysvshm_lock = MUTEX_INITIALIZER;
+static unsigned int sysvshm_lock = LLL_INITIALIZER;
/* Adds a segment attachment. */
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