This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch sthibaul/hurd-builds updated. glibc-2.26.9000-1153-gd0dfa61
- From: sthibaul at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 18 Jan 2018 22:54:01 -0000
- Subject: GNU C Library master sources branch sthibaul/hurd-builds updated. glibc-2.26.9000-1153-gd0dfa61
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, sthibaul/hurd-builds has been updated
via d0dfa617585427adc60d7d4a20680eb37aa494bd (commit)
via 3209623066118bcb4a1ca5923c9e0e0031eb0e56 (commit)
via 1dc344b396985231e5eb76293480c582c8e951f5 (commit)
via b80d1fdbcdacee7b3d38afcc5d956f2987fcef33 (commit)
via 787fc35a7e54deb741fdcfab97c2a108b6610904 (commit)
via eadfb402d89f7a5d7f49685057dd79dec02acfd4 (commit)
via e9707e448f0e1611ef4aa545660475751da86d55 (commit)
via f38fb56ed198f166cd6fe881854c88556fc2b3b3 (commit)
via c1d1e6630212e4a4a43ef5bbbf1214878d6c6847 (commit)
via c6c9691d422df78271b99f6dccbf2e2e9992be93 (commit)
via b3e58a16a784cce0d4ea1c7699950e30174f1842 (commit)
via 1d53efdf4a442844d17cf796ebb079d1a9e9a13f (commit)
via 7d59b281cc064677056d129f8f16d6229b61d396 (commit)
via 9b4b153b5b7476f5bc907d12a25c5003dc887ec1 (commit)
via 216d758170d67eb647ccde202ab7756a20101e33 (commit)
via 902d7abaf9a54dbbca2450dac6116b0f4c69b428 (commit)
from 8e448310d74b283c5cd02b9ed7fb997b47bf9b22 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d0dfa617585427adc60d7d4a20680eb37aa494bd
commit d0dfa617585427adc60d7d4a20680eb37aa494bd
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:53:22 2018 +0100
t2.25/tls
Fix tls support for glibc 2.25
* csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call
__libc_setup_tls.
* sysdeps/mach/hurd/i386/init-first.c (init): Call __libc_setup_tls.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 605222f..8e92cc0 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -193,8 +193,10 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
/* Perform IREL{,A} relocations. */
ARCH_SETUP_IREL ();
+#ifndef __GNU__
/* The stack guard goes into the TCB, so initialize it early. */
__libc_setup_tls ();
+#endif
/* In some architectures, IREL{,A} relocations happen after TLS setup in
order to let IFUNC resolvers benefit from TCB information, e.g. powerpc's
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 82b9cb2..d75f24c 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -196,7 +196,8 @@ init (int *data)
assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0);
}
- /* We need to setup TLS before starting the signal thread. */
+ /* We need to setup TLS before starting sigthread and set stack guard. */
+ __libc_setup_tls ();
extern void __pthread_initialize_minimal (void);
if (__pthread_initialize_minimal != NULL)
__pthread_initialize_minimal ();
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3209623066118bcb4a1ca5923c9e0e0031eb0e56
commit 3209623066118bcb4a1ca5923c9e0e0031eb0e56
Author: Samuel Thibault <samuel.thibault@gnu.org>
Date: Thu Jan 18 23:49:53 2018 +0100
t/tls
hurd: add TLS support
2009-07-30 Samuel Thibault <samuel.thibault@gnu.org>
Add TLS support: __mach_setup_tls allocates and sets
architecture state for the TLS area. i386 fork needs to
propagate the segment kernel definitions.
* sysdeps/mach/hurd/bits/libc-lock.h [_LIBC - 0]: Include <tls.h>
* sysdeps/mach/hurd/tls.h: Include <stdint.h> and <sysdep.h>
* include/errno.h (__GNU__): Do not define TLS errno for now.
* sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New
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 (__i386_selector_is_ldt): New
macro.
(_hurd_tls_init): Use kern_return_t error type. Use
__i386_selector_is_ldt to test for LDT segment type.
(_hurd_tls_fork): Use kern_return_t error type. Duplicate existing LDT
descriptor instead of creating a new one.
(_hurd_tls_new): New function, creates a new descriptor and updates tcb.
* mach/mach.h (__mach_setup_tls,mach_setup_tls): Add declarations.
* mach/setup-thread.c: Include <ldsodefs.h>.
(__mach_setup_thread): Use MACHINE_NEW_THREAD_STATE_FLAVOR instead of
MACHINE_THREAD_STATE_FLAVOR.
(__mach_setup_tls): New function.
* hurd/hurdfault.c (_hurdsig_fault_init): Call
MACHINE_THREAD_STATE_FIX_NEW.
* sysdeps/mach/hurd/profil.c (update_waiter): Call __mach_setup_tls.
* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Call
__mach_setup_tls.
* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls.
* sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for
sigthread. Pass kernel thread to _hurd_tls_fork.
* sysdeps/mach/hurd/i386/init-first.c (init): Move ELF header parsing
after getting up the environment pointer. Call
__pthread_initialize_minimal.
* csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call
__pthread_initialize_minimal.
diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c
index b5a4056..794def7 100644
--- a/hurd/hurdfault.c
+++ b/hurd/hurdfault.c
@@ -204,6 +204,8 @@ _hurdsig_fault_init (void)
/* This state will be restored when we fault.
It runs the function above. */
memset (&state, 0, sizeof state);
+
+ MACHINE_THREAD_STATE_FIX_NEW (&state);
MACHINE_THREAD_STATE_SET_PC (&state, faulted);
MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack);
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index 4f5bb9a..3e587a4 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -1266,6 +1266,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
(vm_address_t *) &__hurd_sigthread_stack_base,
&stacksize);
assert_perror (err);
+ err = __mach_setup_tls (_hurd_msgport_thread);
+ assert_perror (err);
__hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
__hurd_sigthread_variables =
diff --git a/include/errno.h b/include/errno.h
index 3c3d228..89353aa 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -24,13 +24,15 @@ extern int rtld_errno attribute_hidden;
# include <tls.h>
-# undef errno
-# if IS_IN (libc)
-# define errno __libc_errno
-# else
-# define errno errno /* For #ifndef errno tests. */
-# endif
+# if !defined __GNU__
+# undef errno
+# if IS_IN (libc)
+# define errno __libc_errno
+# else
+# define errno errno /* For #ifndef errno tests. */
+# endif
extern __thread int errno attribute_tls_model_ie;
+# endif
# endif /* IS_IN_LIB */
diff --git a/mach/mach.h b/mach/mach.h
index 684be91..93398b0 100644
--- a/mach/mach.h
+++ b/mach/mach.h
@@ -96,5 +96,8 @@ kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc,
vm_address_t *stack_base,
vm_size_t *stack_size);
+/* Give THREAD a TLS area. */
+kern_return_t __mach_setup_tls (thread_t thread);
+kern_return_t mach_setup_tls (thread_t thread);
#endif /* mach.h */
diff --git a/mach/setup-thread.c b/mach/setup-thread.c
index 2eeacc2..972b355 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. */
@@ -72,8 +73,35 @@ __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,
+ 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;
+
+ 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 == NULL)
+ return KERN_RESOURCE_SHORTAGE;
+
+ _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_tls, mach_setup_tls)
diff --git a/sysdeps/generic/thread_state.h b/sysdeps/generic/thread_state.h
index 32994c3..7c61dbc 100644
--- a/sysdeps/generic/thread_state.h
+++ b/sysdeps/generic/thread_state.h
@@ -22,6 +22,7 @@
/* Replace <machine> with "i386" or "mips" or whatever. */
+#define MACHINE_NEW_THREAD_STATE_FLAVOR <machine>_NEW_THREAD_STATE
#define MACHINE_THREAD_STATE_FLAVOR <machine>_THREAD_STATE
#define MACHINE_THREAD_STATE_COUNT <machine>_THREAD_STATE_COUNT
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
index fe3f544..984ef60 100644
--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
@@ -536,6 +536,11 @@ __fork (void)
#endif
MACHINE_THREAD_STATE_SET_PC (&state,
(unsigned long int) _hurd_msgport_receive);
+
+ /* Do special thread setup for TLS if needed. */
+ if (err = _hurd_tls_fork (sigthread, _hurd_msgport_thread, &state))
+ LOSE;
+
if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
(natural_t *) &state, statecount))
LOSE;
@@ -546,7 +551,7 @@ __fork (void)
_hurd_longjmp_thread_state (&state, env, 1);
/* Do special thread setup for TLS if needed. */
- if (err = _hurd_tls_fork (thread, &state))
+ if (err = _hurd_tls_fork (thread, ss->thread, &state))
LOSE;
if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 965b53c..82b9cb2 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -109,32 +109,10 @@ 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])
- {
-#ifndef SHARED
- /* With a new enough linker (binutils-2.23 or better),
- the magic __ehdr_start symbol will be available and
- __libc_start_main will have done this that way already. */
- if (_dl_phdr == NULL)
- {
- /* We may need to see our own phdrs, e.g. for TLS setup.
- Try the usual kludge to find the headers without help from
- the exec server. */
- extern const void __executable_start;
- const ElfW(Ehdr) *const ehdr = &__executable_start;
- _dl_phdr = (const void *) ehdr + ehdr->e_phoff;
- _dl_phnum = ehdr->e_phnum;
- assert (ehdr->e_phentsize == sizeof (ElfW(Phdr)));
- }
-#endif
- return;
- }
+ return;
#ifndef SHARED
__libc_enable_secure = d->flags & EXEC_SECURE;
-
- _dl_phdr = (ElfW(Phdr) *) d->phdr;
- _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr));
- assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0);
#endif
_hurd_init_dtable = d->dtable;
@@ -190,6 +168,40 @@ init (int *data)
++envp;
d = (void *) ++envp;
+#ifndef SHARED
+ /* If we are the bootstrap task started by the kernel,
+ then after the environment pointers there is no Hurd
+ data block; the argument strings start there. */
+ if ((void *) d == argv[0])
+ {
+ /* With a new enough linker (binutils-2.23 or better),
+ the magic __ehdr_start symbol will be available and
+ __libc_start_main will have done this that way already. */
+ if (_dl_phdr == NULL)
+ {
+ /* We may need to see our own phdrs, e.g. for TLS setup.
+ Try the usual kludge to find the headers without help from
+ the exec server. */
+ extern const void __executable_start;
+ const ElfW(Ehdr) *const ehdr = &__executable_start;
+ _dl_phdr = (const void *) ehdr + ehdr->e_phoff;
+ _dl_phnum = ehdr->e_phnum;
+ assert (ehdr->e_phentsize == sizeof (ElfW(Phdr)));
+ }
+ }
+ else
+ {
+ _dl_phdr = (ElfW(Phdr) *) d->phdr;
+ _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr));
+ assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0);
+ }
+
+ /* 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
+
/* The user might have defined a value for this, to get more variables.
Otherwise it will be zero on startup. We must make sure it is set
properly before before cthreads initialization, so cthreads can know
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index b194a49..0ff0474 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
@@ -52,6 +52,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
@@ -62,6 +71,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>
@@ -93,7 +104,7 @@ _hurd_tls_init (tcbhead_t *tcb)
/* Get the first available selector. */
int sel = -1;
- error_t err = __i386_set_gdt (tcb->self, &sel, desc);
+ kern_return_t err = __i386_set_gdt (tcb->self, &sel, desc);
if (err == MIG_BAD_ID)
{
/* Old kernel, use a per-thread LDT. */
@@ -141,9 +152,40 @@ _hurd_tls_init (tcbhead_t *tcb)
# include <mach/machine/thread_status.h>
-/* Set up TLS in the new thread of a fork child, copying from our own. */
-static inline error_t __attribute__ ((unused))
-_hurd_tls_fork (thread_t child, struct i386_thread_state *state)
+/* Set up TLS in the new thread of a fork child, copying from the original. */
+static inline kern_return_t __attribute__ ((unused))
+_hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state)
+{
+ /* Fetch the selector set by _hurd_tls_init. */
+ int sel;
+ asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
+ if (sel == state->ds) /* _hurd_tls_init was never called. */
+ return 0;
+
+ struct descriptor desc, *_desc = &desc;
+ kern_return_t err;
+ unsigned int count = 1;
+
+ 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);
+
+ assert_perror (err);
+ if (err)
+ return err;
+
+ if (__glibc_unlikely (__i386_selector_is_ldt(sel)))
+ err = __i386_set_ldt (child, sel, &desc, 1);
+ else
+ err = __i386_set_gdt (child, &sel, desc);
+
+ state->gs = sel;
+ return err;
+}
+
+static inline kern_return_t __attribute__ ((unused))
+_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb)
{
/* Fetch the selector set by _hurd_tls_init. */
int sel;
@@ -151,11 +193,13 @@ _hurd_tls_fork (thread_t child, struct i386_thread_state *state)
if (sel == state->ds) /* _hurd_tls_init was never called. */
return 0;
- tcbhead_t *const tcb = THREAD_SELF;
HURD_TLS_DESC_DECL (desc, tcb);
- error_t err;
+ kern_return_t err;
+
+ tcb->tcb = tcb;
+ tcb->self = child;
- if (__builtin_expect (sel, 0x50) & 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/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
index d240ca7..0c68759 100644
--- a/sysdeps/mach/hurd/i386/trampoline.c
+++ b/sysdeps/mach/hurd/i386/trampoline.c
@@ -62,7 +62,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
sizeof (state->basic));
memcpy (&state->fpu, &ss->context->sc_i386_float_state,
sizeof (state->fpu));
- state->set |= (1 << i386_THREAD_STATE) | (1 << i386_FLOAT_STATE);
+ state->set |= (1 << i386_REGS_SEGS_STATE) | (1 << i386_FLOAT_STATE);
}
}
diff --git a/sysdeps/mach/hurd/libc-lock.h b/sysdeps/mach/hurd/libc-lock.h
index 371912e..2811b64 100644
--- a/sysdeps/mach/hurd/libc-lock.h
+++ b/sysdeps/mach/hurd/libc-lock.h
@@ -20,6 +20,9 @@
#define _LIBC_LOCK_H 1
#if (_LIBC - 0) || (_CTHREADS_ - 0)
+# if (_LIBC - 0)
+# include <tls.h>
+# endif
#include <cthreads.h>
#include <hurd/threadvar.h>
diff --git a/sysdeps/mach/hurd/profil.c b/sysdeps/mach/hurd/profil.c
index 1323457..7206345 100644
--- a/sysdeps/mach/hurd/profil.c
+++ b/sysdeps/mach/hurd/profil.c
@@ -70,6 +70,8 @@ update_waiter (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
if (! err)
err = __mach_setup_thread (__mach_task_self (), profile_thread,
&profile_waiter, NULL, NULL);
+ if (! err)
+ err = __mach_setup_tls (profile_thread);
}
else
err = 0;
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index a0d2941..ab18028 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -221,11 +221,12 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old,
goto out;
_hurd_itimer_thread_stack_base = 0; /* Anywhere. */
_hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */
- if (err = __mach_setup_thread (__mach_task_self (),
+ if ((err = __mach_setup_thread (__mach_task_self (),
_hurd_itimer_thread,
&timer_thread,
&_hurd_itimer_thread_stack_base,
&_hurd_itimer_thread_stack_size))
+ || (err = __mach_setup_tls (_hurd_itimer_thread)))
{
__thread_terminate (_hurd_itimer_thread);
_hurd_itimer_thread = MACH_PORT_NULL;
diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/i386/thread_state.h
index 56d91df..45910f5 100644
--- a/sysdeps/mach/i386/thread_state.h
+++ b/sysdeps/mach/i386/thread_state.h
@@ -21,7 +21,8 @@
#include <mach/machine/thread_status.h>
-#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE
+#define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE
+#define MACHINE_THREAD_STATE_FLAVOR i386_REGS_SEGS_STATE
#define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT
#define machine_thread_state i386_thread_state
@@ -30,6 +31,14 @@
#define SP uesp
#define SYSRETURN eax
+#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \
+ asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \
+ asm ("mov %%ds, %w0" : "=q" ((ts)->ds)); \
+ asm ("mov %%es, %w0" : "=q" ((ts)->es)); \
+ asm ("mov %%fs, %w0" : "=q" ((ts)->fs)); \
+ asm ("mov %%gs, %w0" : "=q" ((ts)->gs)); \
+} while(0)
+
struct machine_thread_all_state
{
int set; /* Mask of bits (1 << FLAVOR). */
diff --git a/sysdeps/mach/thread_state.h b/sysdeps/mach/thread_state.h
index bc4feef..b1c4e88 100644
--- a/sysdeps/mach/thread_state.h
+++ b/sysdeps/mach/thread_state.h
@@ -37,6 +37,9 @@
((ts)->SP = (unsigned long int) (stack) + (size))
#endif
#endif
+#ifndef MACHINE_THREAD_STATE_FIX_NEW
+# define MACHINE_THREAD_STATE_FIX_NEW(ts)
+#endif
/* These functions are of use in machine-dependent signal trampoline
implementations. */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1dc344b396985231e5eb76293480c582c8e951f5
commit 1dc344b396985231e5eb76293480c582c8e951f5
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:43:58 2018 +0100
t/tlsdesc.sym
i386 version of tlsdesc.sym for GNU Hurd.
diff --git a/sysdeps/mach/hurd/i386/tlsdesc.sym b/sysdeps/mach/hurd/i386/tlsdesc.sym
new file mode 100644
index 0000000..a358f7e
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/tlsdesc.sym
@@ -0,0 +1,19 @@
+#include <stddef.h>
+#include <sysdep.h>
+#include <tls.h>
+#include <link.h>
+#include <dl-tlsdesc.h>
+
+--
+
+-- We have to override sysdeps/i386/tlsdesc.sym to adapt to our libpthread.
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+
+DTV_OFFSET offsetof(tcbhead_t, dtv)
+
+TLSDESC_ARG offsetof(struct tlsdesc, arg)
+
+TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count)
+TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_module)
+TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_offset)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b80d1fdbcdacee7b3d38afcc5d956f2987fcef33
commit b80d1fdbcdacee7b3d38afcc5d956f2987fcef33
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:42:17 2018 +0100
t/gai_misc
Add a hurd version of threaded gai_misc.h
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/sysdeps/mach/hurd/gai_misc.h b/sysdeps/mach/hurd/gai_misc.h
new file mode 100644
index 0000000..ee8117f
--- /dev/null
+++ b/sysdeps/mach/hurd/gai_misc.h
@@ -0,0 +1,44 @@
+#include <signal.h>
+#include <pthread.h>
+
+#define gai_start_notify_thread __gai_start_notify_thread
+#define gai_create_helper_thread __gai_create_helper_thread
+
+extern inline void
+__gai_start_notify_thread (void)
+{
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigprocmask(SIG_SETMASK, &ss, NULL);
+}
+
+extern inline int
+__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
+ void *arg)
+{
+ pthread_attr_t attr;
+
+ /* Make sure the thread is created detached. */
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+
+ /* The helper thread needs only very little resources. */
+ (void) pthread_attr_setstacksize (&attr, 0x10000);
+
+ /* Block all signals in the helper thread. To do this thoroughly we
+ temporarily have to block all signals here. */
+ sigset_t ss;
+ sigset_t oss;
+ sigfillset (&ss);
+ sigprocmask(SIG_SETMASK, &ss, &oss);
+
+ int ret = pthread_create (threadp, &attr, tf, arg);
+
+ /* Restore the signal mask. */
+ sigprocmask(SIG_SETMASK, &oss, NULL);
+
+ (void) pthread_attr_destroy (&attr);
+ return ret;
+}
+
+#include_next <gai_misc.h>
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=787fc35a7e54deb741fdcfab97c2a108b6610904
commit 787fc35a7e54deb741fdcfab97c2a108b6610904
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:41:29 2018 +0100
t/allocalim
hurd: Fix allocalim build
* sysdeps/pthread/allocalim.h [!PTHREAD_STACK_MIN]: Do not check size
against PTHREAD_STACK_MIN.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/sysdeps/pthread/allocalim.h b/sysdeps/pthread/allocalim.h
index b265d6f..4b42172 100644
--- a/sysdeps/pthread/allocalim.h
+++ b/sysdeps/pthread/allocalim.h
@@ -24,6 +24,9 @@ extern __always_inline
int
__libc_use_alloca (size_t size)
{
- return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1)
- || __builtin_expect (__libc_alloca_cutoff (size), 1));
+ return (
+#ifdef PTHREAD_STACK_MIN
+ __builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1) ||
+#endif
+ __builtin_expect (__libc_alloca_cutoff (size), 1));
}
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=eadfb402d89f7a5d7f49685057dd79dec02acfd4
commit eadfb402d89f7a5d7f49685057dd79dec02acfd4
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:39:27 2018 +0100
t/no-hp-timing
We don't have support for hp timing for now, even the i686 variant, which needs
to know the CPU speed.
Copied from sysdeps/generic/hp-timing.h
2010-08-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
* sysdeps/mach/hurd/hp-timing.h: New file.
diff --git a/sysdeps/mach/hurd/hp-timing.h b/sysdeps/mach/hurd/hp-timing.h
new file mode 100644
index 0000000..1246e21
--- /dev/null
+++ b/sysdeps/mach/hurd/hp-timing.h
@@ -0,0 +1,42 @@
+/* High precision, low overhead timing functions. Generic version.
+ Copyright (C) 1998-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _HP_TIMING_H
+#define _HP_TIMING_H 1
+
+/* We don't have support for high precision timing for now. */
+
+/* Provide dummy definitions. */
+#define HP_TIMING_AVAIL (0)
+#define HP_SMALL_TIMING_AVAIL (0)
+#define HP_TIMING_INLINE (0)
+typedef int hp_timing_t;
+#define HP_TIMING_ZERO(Var)
+#define HP_TIMING_NOW(var)
+#define HP_TIMING_DIFF_INIT()
+#define HP_TIMING_DIFF(Diff, Start, End)
+#define HP_TIMING_ACCUM(Sum, Diff)
+#define HP_TIMING_ACCUM_NT(Sum, Diff)
+#define HP_TIMING_PRINT(Buf, Len, Val)
+
+/* Since this implementation is not available we tell the user about it. */
+#define HP_TIMING_NONAVAIL 1
+
+#endif /* hp-timing.h */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=e9707e448f0e1611ef4aa545660475751da86d55
commit e9707e448f0e1611ef4aa545660475751da86d55
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:38:57 2018 +0100
t/posix_thread
Declare that we have a libpthread.
The additional version in Versions.def should be updated when we'd
actually get the libpthread commited into glibc (as well as in
libpthread/Versions).
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index f0d3373..f9adbcf 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -170,6 +170,10 @@ $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
endif
+ifeq ($(subdir),posix)
+CFLAGS-confstr.c += -DLIBPTHREAD_VERSION='"libpthread 0.3"'
+endif
+
# Override the generic Makeconfig values so we link against the RPC libs.
link-libc-static := -Wl,--start-group \
$(patsubst %,$(common-objpfx)%.a,\
diff --git a/sysdeps/mach/hurd/bits/local_lim.h b/sysdeps/mach/hurd/bits/local_lim.h
index 8a1af91..97f87ad 100644
--- a/sysdeps/mach/hurd/bits/local_lim.h
+++ b/sysdeps/mach/hurd/bits/local_lim.h
@@ -32,3 +32,12 @@
suitable, and `sysconf' will return a number at least as large. */
#define NGROUPS_MAX 256
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index f299e3f..5f08319 100644
--- a/sysdeps/mach/hurd/bits/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
@@ -71,24 +71,38 @@
/* XPG4.2 shared memory is not supported. */
#undef _XOPEN_SHM
-/* We do not have the POSIX threads interface. */
-#define _POSIX_THREADS -1
+/* Tell we have POSIX threads. */
+#define _POSIX_THREADS 200112L
/* We have the reentrant functions described in POSIX. */
#define _POSIX_REENTRANT_FUNCTIONS 1
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
-/* These are all things that won't be supported when _POSIX_THREADS is not. */
+/* We do not provide priority scheduling for threads. */
#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
-#define _POSIX_THREAD_ATTR_STACKSIZE -1
-#define _POSIX_THREAD_ATTR_STACKADDR -1
+
+/* We support user-defined stack sizes. */
+#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
+
+/* We support user-defined stacks. */
+#define _POSIX_THREAD_ATTR_STACKADDR 200112L
+
+/* We do not support priority inheritence. */
#define _POSIX_THREAD_PRIO_INHERIT -1
+
+/* We do not support priority protection. */
#define _POSIX_THREAD_PRIO_PROTECT -1
+
#ifdef __USE_XOPEN2K8
+/* We do not support priority inheritence for robust mutexes. */
# define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
+
+/* We do not support priority protection for robust mutexes. */
# define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
#endif
-#define _POSIX_SEMAPHORES -1
+
+/* We support POSIX.1b semaphores. */
+#define _POSIX_SEMAPHORES 200112L
/* Real-time signals are not yet supported. */
#define _POSIX_REALTIME_SIGNALS -1
@@ -121,17 +135,17 @@
/* GNU libc provides regular expression handling. */
#define _POSIX_REGEXP 1
-/* Reader/Writer locks are not available. */
-#define _POSIX_READER_WRITER_LOCKS -1
+/* Reader/Writer locks are available. */
+#define _POSIX_READER_WRITER_LOCKS 200112L
/* We have a POSIX shell. */
#define _POSIX_SHELL 1
-/* We cannot support the Timeouts option without _POSIX_THREADS. */
-#define _POSIX_TIMEOUTS -1
+/* We support the Timeouts option. */
+#define _POSIX_TIMEOUTS 200112L
-/* We do not support spinlocks. */
-#define _POSIX_SPIN_LOCKS -1
+/* We support spinlocks. */
+#define _POSIX_SPIN_LOCKS 200112L
/* The `spawn' function family is supported. */
#define _POSIX_SPAWN 200809L
@@ -139,8 +153,8 @@
/* We do not have POSIX timers, but could in future without ABI change. */
#define _POSIX_TIMERS 0
-/* The barrier functions are not available. */
-#define _POSIX_BARRIERS -1
+/* We support barrier functions. */
+#define _POSIX_BARRIERS 200112L
/* POSIX message queues could be available in future. */
#define _POSIX_MESSAGE_PASSING 0
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f38fb56ed198f166cd6fe881854c88556fc2b3b3
commit f38fb56ed198f166cd6fe881854c88556fc2b3b3
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:38:29 2018 +0100
t/libpthread_depends
libpthread needs to be built before modules which need it.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/nscd/Depend b/nscd/Depend
index 6c1aa44..c29ffb5 100644
--- a/nscd/Depend
+++ b/nscd/Depend
@@ -1 +1,2 @@
nptl
+libpthread
diff --git a/resolv/Depend b/resolv/Depend
index 6c1aa44..c29ffb5 100644
--- a/resolv/Depend
+++ b/resolv/Depend
@@ -1 +1,2 @@
nptl
+libpthread
diff --git a/rt/Depend b/rt/Depend
index 6c1aa44..c29ffb5 100644
--- a/rt/Depend
+++ b/rt/Depend
@@ -1 +1,2 @@
nptl
+libpthread
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c1d1e6630212e4a4a43ef5bbbf1214878d6c6847
commit c1d1e6630212e4a4a43ef5bbbf1214878d6c6847
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:35:12 2018 +0100
t/timer_routines
support timer routines
TODO: this is just browntape-fixing...
* sysdeps/pthread/timer_routines.c: Do not include nptl/pthreadP.h
Do not define some unused or unsupported functions.
diff --git a/sysdeps/pthread/timer_routines.c b/sysdeps/pthread/timer_routines.c
index f059beb..0f2de79 100644
--- a/sysdeps/pthread/timer_routines.c
+++ b/sysdeps/pthread/timer_routines.c
@@ -29,7 +29,7 @@
#include <sys/syscall.h>
#include "posix-timer.h"
-#include <nptl/pthreadP.h>
+//#include <nptl/pthreadP.h>
/* Number of threads used. */
@@ -395,6 +395,9 @@ thread_func (void *arg)
{
timespec_add (&timer->expirytime, &timer->expirytime,
&timer->value.it_interval);
+#ifndef DELAYTIMER_MAX
+#define DELAYTIMER_MAX INT_MAX
+#endif
if (timer->overrun_count < DELAYTIMER_MAX)
++timer->overrun_count;
}
@@ -481,7 +484,7 @@ __timer_thread_wakeup (struct thread_node *thread)
pthread_cond_broadcast (&thread->cond);
}
-
+#if 0
/* Compare two pthread_attr_t thread attributes for exact equality.
Returns 1 if they are equal, otherwise zero if they are not equal
or contain illegal values. This version is NPTL-specific for
@@ -506,6 +509,7 @@ thread_attr_compare (const pthread_attr_t *left, const pthread_attr_t *right)
&& memcmp (ileft->cpuset, iright->cpuset,
ileft->cpusetsize) == 0)));
}
+#endif
/* Search the list of active threads and find one which has matching
@@ -514,6 +518,7 @@ struct thread_node *
__timer_thread_find_matching (const pthread_attr_t *desired_attr,
clockid_t desired_clock_id)
{
+#if 0
struct list_head *iter = list_first (&thread_active_list);
while (iter != list_null (&thread_active_list))
@@ -526,6 +531,7 @@ __timer_thread_find_matching (const pthread_attr_t *desired_attr,
iter = list_next (iter);
}
+#endif
return NULL;
}
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c6c9691d422df78271b99f6dccbf2e2e9992be93
commit c6c9691d422df78271b99f6dccbf2e2e9992be93
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Thu Jan 18 23:32:42 2018 +0100
t/extern_inline
hurd: take __USE_EXTERN_INLINES into account
* hurd/hurd.h (__hurd_fail): Always declare function, and provide inline
version only if __USE_EXTERN_INLINES is defined.
* hurd/hurd/fd.h (_hurd_fd_get, _hurd_fd_error_signal, _hurd_fd_error,
__hurd_dfail, __hurd_sockfail): Likewise.
* mach/lock-intern.h (__spin_lock_init, __spin_lock, __mutex_lock,
__mutex_unlock, __mutex_trylock): Likewise.
* mach/mach/mig_support.h (__mig_strncpy): Likewise.
* sysdeps/generic/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* sysdeps/generic/machine-sp.h (__thread_stack_pointer): Likewise.
* sysdeps/mach/i386/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* hurd/hurd/port.h (_hurd_port_init, _hurd_port_locked_get,
_hurd_port_get, _hurd_port_free, _hurd_port_locked_set,
_hurd_port_set): Always declare functions, and provide inline version
only if __USE_EXTERN_INLINES is defined and _LIBC is defined and
NOT_IN_libc is not defined.
* hurd/hurd/signal.h (_hurd_self_sigstate, _hurd_critical_section_lock,
_hurd_critical_section_unlock): Likewise.
* hurd/hurd/threadvar.h (__hurd_threadvar_location_from_sp,
* __hurd_threadvar_location): Likewise.
* hurd/hurd/userlink.h (_hurd_userlink_link, _hurd_userlink_unlink,
_hurd_userlink_clear): Likewise.
* mach/spin-lock.c (__USE_EXTERN_INLINES): Define to 1.
* hurd/Versions (libc: GLIBC_2.19): Add _hurd_fd_error_signal,
_hurd_fd_error, __hurd_dfail, __hurd_sockfail,
__hurd_threadvar_location_from_sp, __hurd_threadvar_location,
_hurd_userlink_link, _hurd_userlink_unlink, _hurd_userlink_clear.
diff --git a/hurd/Versions b/hurd/Versions
index b059405..8b84f73 100644
--- a/hurd/Versions
+++ b/hurd/Versions
@@ -132,6 +132,12 @@ libc {
GLIBC_2.27 {
# "quasi-internal" functions
_hurd_exec_paths;
+ # These always existed as inlines but the real functions were not exported.
+ _hurd_fd_error_signal; _hurd_fd_error;
+ __hurd_dfail; __hurd_sockfail;
+ __hurd_threadvar_location_from_sp;
+ __hurd_threadvar_location;
+ _hurd_userlink_link; _hurd_userlink_unlink; _hurd_userlink_clear;
}
HURD_CTHREADS_0.3 {
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b3e58a16a784cce0d4ea1c7699950e30174f1842
commit b3e58a16a784cce0d4ea1c7699950e30174f1842
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:25:13 2018 +0100
t/grantpt
/media/Stalin/tmp/glibc.hurd.gnu-2/libc_pic.os: In function `pts_name':
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/login/../sysdeps/unix/grantpt.c:52: undefined reference to `__ptsname_internal'
collect2: ld returned 1 exit status
make[1]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/libc.so] Error 1
Cf. aa9890239a2aef81e64f3f22a31c7e01b6501f69
Need any of the checks (stat, etc.) that Linux' __ptsname_internal does?
Implement close_all_fds as in 139ee080b6b428240bf49f3e6361f3ac729f891a?
diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c
index 08748a3..c25794d 100644
--- a/sysdeps/mach/hurd/ptsname.c
+++ b/sysdeps/mach/hurd/ptsname.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <string.h>
+#include <sys/stat.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/term.h>
@@ -38,11 +39,10 @@ ptsname (int fd)
}
-/* Store at most BUFLEN characters of the pathname of the slave pseudo
- terminal associated with the master FD is open on in BUF.
- Return 0 on success, otherwise an error number. */
+/* We can't make use of STP, but do it that way for conformity with the Linux
+ version... */
int
-__ptsname_r (int fd, char *buf, size_t buflen)
+__ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
{
string_t peername;
size_t len;
@@ -61,4 +61,14 @@ __ptsname_r (int fd, char *buf, size_t buflen)
memcpy (buf, peername, len);
return 0;
}
+
+
+/* Store at most BUFLEN characters of the pathname of the slave pseudo
+ terminal associated with the master FD is open on in BUF.
+ Return 0 on success, otherwise an error number. */
+int
+__ptsname_r (int fd, char *buf, size_t buflen)
+{
+ return __ptsname_internal (fd, buf, buflen, NULL);
+}
weak_alias (__ptsname_r, ptsname_r)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1d53efdf4a442844d17cf796ebb079d1a9e9a13f
commit 1d53efdf4a442844d17cf796ebb079d1a9e9a13f
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:22:59 2018 +0100
t/gscope
Minimal gscope stuff.
glibc-2.8/debian/patches/hurd-i386/local-gscope.diff 3085
Written by Samuel Thibault.
---
I think that's the corresponding error message:
/media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_dependency':
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:106: undefined reference to `atomic_forced_read'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:109: undefined reference to `atomic_read_barrier'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:113: undefined reference to `atomic_forced_read'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:141: undefined reference to `THREAD_GSCOPE_RESET_FLAG'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:147: undefined reference to `atomic_forced_read'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:284: undefined reference to `THREAD_GSCOPE_SET_FLAG'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:261: undefined reference to `atomic_write_barrier'
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:250: undefined reference to `atomic_write_barrier'
/media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_to_global':
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:162: undefined reference to `atomic_write_barrier'
/media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `dl_open_worker':
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:478: undefined reference to `atomic_write_barrier'
collect2: ld returned 1 exit status
make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1
diff --git a/elf/dl-support.c b/elf/dl-support.c
index b5ba0d1..51bb649 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -188,6 +188,7 @@ int (*_dl_make_stack_executable_hook) (void **) = _dl_make_stack_executable;
/* Function in libpthread to wait for termination of lookups. */
void (*_dl_wait_lookup_done) (void);
+int volatile _dl_thread_gscope_count;
struct dl_scope_free_list *_dl_scope_free_list;
#ifdef NEED_DL_SYSINFO
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 0ea2786..bc7eaad 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -435,6 +435,7 @@ struct rtld_global
size_t count;
void *list[50];
} *_dl_scope_free_list;
+ EXTERN volatile int _dl_thread_gscope_count;
#ifdef SHARED
};
# define __rtld_global_attribute__
diff --git a/sysdeps/mach/hurd/sysdep-cancel.h b/sysdeps/mach/hurd/sysdep-cancel.h
new file mode 100644
index 0000000..ec55c73
--- /dev/null
+++ b/sysdeps/mach/hurd/sysdep-cancel.h
@@ -0,0 +1,9 @@
+#include <sysdep.h>
+
+/* Always multi-thread (since there's at least the sig handler), but no
+ handling enabled. */
+#define SINGLE_THREAD_P (0)
+#define RTLD_SINGLE_THREAD_P (0)
+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+#define LIBC_CANCEL_HANDLED() /* Nothing. */
diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h
index faff87c..dd303dc 100644
--- a/sysdeps/mach/hurd/tls.h
+++ b/sysdeps/mach/hurd/tls.h
@@ -53,5 +53,18 @@
#endif /* !ASSEMBLER */
+#ifndef __ASSEMBLER__
+#include <mach/mach_traps.h>
+#include <atomic.h>
+/* Temporary poor-man's global scope switch support: just busy-waits */
+#define THREAD_GSCOPE_SET_FLAG() \
+ asm volatile ("lock incl %0":"=m"(GL(dl_thread_gscope_count)))
+#define THREAD_GSCOPE_RESET_FLAG() \
+ asm volatile ("lock decl %0":"=m"(GL(dl_thread_gscope_count)))
+#define THREAD_GSCOPE_WAIT() \
+ while (GL(dl_thread_gscope_count)) { \
+ __swtch_pri (0); \
+ }
+#endif
#endif /* tls.h */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7d59b281cc064677056d129f8f16d6229b61d396
commit 7d59b281cc064677056d129f8f16d6229b61d396
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:21:19 2018 +0100
t/_dl_random
_dl_random
---
/media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `security_init':
/media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/rtld.c:844: undefined reference to `_dl_random'
/media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: relocation R_386_GOTOFF against undefined hidden symbol `_dl_random' can not be used when making a shared object
/media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 7f2ba8c..c46342b 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -64,6 +64,8 @@ rtld_hidden_data_def(__libc_stack_end)
hp_timing_t _dl_cpuclock_offset;
#endif
+/* TODO: this is never properly initialized in here. */
+void *_dl_random attribute_relro = NULL;
struct hurd_startup_data *_dl_hurd_data;
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9b4b153b5b7476f5bc907d12a25c5003dc887ec1
commit 9b4b153b5b7476f5bc907d12a25c5003dc887ec1
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:20:41 2018 +0100
t/pagesize
WIP. id:"87mxd9hl2n.fsf@kepler.schwinge.homeip.net"
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 114f77a..b5ba0d1 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -136,7 +136,7 @@ hp_timing_t _dl_cpuclock_offset;
void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls;
-size_t _dl_pagesize = EXEC_PAGESIZE;
+size_t _dl_pagesize = /* EXEC_PAGESIZE */ 4096;
int _dl_inhibit_cache;
diff --git a/elf/rtld.c b/elf/rtld.c
index 453f56e..25dc95d 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -271,7 +271,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
#endif
._dl_lazy = 1,
._dl_fpu_control = _FPU_DEFAULT,
- ._dl_pagesize = EXEC_PAGESIZE,
+ ._dl_pagesize = /* EXEC_PAGESIZE */ 4096,
._dl_inhibit_cache = 0,
/* Function pointers. */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=216d758170d67eb647ccde202ab7756a20101e33
commit 216d758170d67eb647ccde202ab7756a20101e33
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:19:02 2018 +0100
t/verify.h
2008-12-18 Thomas Schwinge <tschwinge@gnu.org>
* include/verify.h: New file, from gnulib.
TODO: Use it in all sensible places.
diff --git a/include/verify.h b/include/verify.h
new file mode 100644
index 0000000..3470500
--- /dev/null
+++ b/include/verify.h
@@ -0,0 +1,140 @@
+/* Compile-time assert-like macros.
+
+ Copyright (C) 2005-2015 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#ifndef VERIFY_H
+# define VERIFY_H 1
+
+/* Each of these macros verifies that its argument R is nonzero. To
+ be portable, R should be an integer constant expression. Unlike
+ assert (R), there is no run-time overhead.
+
+ There are two macros, since no single macro can be used in all
+ contexts in C. verify_true (R) is for scalar contexts, including
+ integer constant expression contexts. verify (R) is for declaration
+ contexts, e.g., the top level.
+
+ Symbols ending in "__" are private to this header.
+
+ The code below uses several ideas.
+
+ * The first step is ((R) ? 1 : -1). Given an expression R, of
+ integral or boolean or floating-point type, this yields an
+ expression of integral type, whose value is later verified to be
+ constant and nonnegative.
+
+ * Next this expression W is wrapped in a type
+ struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+ If W is negative, this yields a compile-time error. No compiler can
+ deal with a bit-field of negative size.
+
+ One might think that an array size check would have the same
+ effect, that is, that the type struct { unsigned int dummy[W]; }
+ would work as well. However, inside a function, some compilers
+ (such as C++ compilers and GNU C) allow local parameters and
+ variables inside array size expressions. With these compilers,
+ an array size check would not properly diagnose this misuse of
+ the verify macro:
+
+ void function (int n) { verify (n < 0); }
+
+ * For the verify macro, the struct verify_type__ will need to
+ somehow be embedded into a declaration. To be portable, this
+ declaration must declare an object, a constant, a function, or a
+ typedef name. If the declared entity uses the type directly,
+ such as in
+
+ struct dummy {...};
+ typedef struct {...} dummy;
+ extern struct {...} *dummy;
+ extern void dummy (struct {...} *);
+ extern struct {...} *dummy (void);
+
+ two uses of the verify macro would yield colliding declarations
+ if the entity names are not disambiguated. A workaround is to
+ attach the current line number to the entity name:
+
+ #define GL_CONCAT0(x, y) x##y
+ #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
+ extern struct {...} * GL_CONCAT(dummy,__LINE__);
+
+ But this has the problem that two invocations of verify from
+ within the same macro would collide, since the __LINE__ value
+ would be the same for both invocations.
+
+ A solution is to use the sizeof operator. It yields a number,
+ getting rid of the identity of the type. Declarations like
+
+ extern int dummy [sizeof (struct {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ can be repeated.
+
+ * Should the implementation use a named struct or an unnamed struct?
+ Which of the following alternatives can be used?
+
+ extern int dummy [sizeof (struct {...})];
+ extern int dummy [sizeof (struct verify_type__ {...})];
+ extern void dummy (int [sizeof (struct {...})]);
+ extern void dummy (int [sizeof (struct verify_type__ {...})]);
+ extern int (*dummy (void)) [sizeof (struct {...})];
+ extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+
+ In the second and sixth case, the struct type is exported to the
+ outer scope; two such declarations therefore collide. GCC warns
+ about the first, third, and fourth cases. So the only remaining
+ possibility is the fifth case:
+
+ extern int (*dummy (void)) [sizeof (struct {...})];
+
+ * This implementation exploits the fact that GCC does not warn about
+ the last declaration mentioned above. If a future version of GCC
+ introduces a warning for this, the problem could be worked around
+ by using code specialized to GCC, e.g.,:
+
+ #if 4 <= __GNUC__
+ # define verify(R) \
+ extern int (* verify_function__ (void)) \
+ [__builtin_constant_p (R) && (R) ? 1 : -1]
+ #endif
+
+ * In C++, any struct definition inside sizeof is invalid.
+ Use a template type to work around the problem. */
+
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+ Return 1. */
+
+# ifdef __cplusplus
+template <int w>
+ struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+# define verify_true(R) \
+ (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# else
+# define verify_true(R) \
+ (!!sizeof \
+ (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+ trailing ';'. */
+
+# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
+
+#endif
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=902d7abaf9a54dbbca2450dac6116b0f4c69b428
commit 902d7abaf9a54dbbca2450dac6116b0f4c69b428
Author: Thomas Schwinge <thomas@schwinge.name>
Date: Thu Jan 18 23:18:00 2018 +0100
t/fcntl-internal.h
2008-12-18 Thomas Schwinge <tschwinge@gnu.org>
* hurd/fcntl-internal.h: New file.
diff --git a/hurd/fcntl-internal.h b/hurd/fcntl-internal.h
new file mode 100644
index 0000000..5cd4542
--- /dev/null
+++ b/hurd/fcntl-internal.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 2008-2015 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <verify.h>
+
+/* Do some compile-time checks for the SOCK_* constants, which we rely on. */
+verify (SOCK_CLOEXEC == O_CLOEXEC);
+verify ((SOCK_MAX | SOCK_TYPE_MASK) == SOCK_TYPE_MASK);
+verify ((SOCK_CLOEXEC & SOCK_TYPE_MASK) == 0);
+verify ((SOCK_NONBLOCK & SOCK_TYPE_MASK) == 0);
+
+
+/* Helper functions for translating between O_* and SOCK_* flags. */
+
+__extern_always_inline
+int
+sock_to_o_flags (int in)
+{
+ int out = 0;
+
+ if (in & SOCK_NONBLOCK)
+ out |= O_NONBLOCK;
+ /* Others are passed through unfiltered. */
+ out |= in & ~(SOCK_NONBLOCK);
+
+ return out;
+}
+
+__extern_always_inline
+int
+o_to_sock_flags (int in)
+{
+ int out = 0;
+
+ if (in & O_NONBLOCK)
+ out |= SOCK_NONBLOCK;
+ /* Others are passed through unfiltered. */
+ out |= in & ~(O_NONBLOCK);
+
+ return out;
+}
-----------------------------------------------------------------------
Summary of changes:
csu/libc-start.c | 2 +
elf/dl-support.c | 3 +-
elf/rtld.c | 2 +-
hurd/Versions | 6 ++
hurd/fcntl-internal.h | 60 +++++++++++++++
hurd/hurdfault.c | 2 +
hurd/hurdsig.c | 2 +
include/errno.h | 14 ++--
include/verify.h | 140 +++++++++++++++++++++++++++++++++++
mach/mach.h | 3 +
mach/setup-thread.c | 30 +++++++-
nscd/Depend | 1 +
resolv/Depend | 1 +
rt/Depend | 1 +
sysdeps/generic/ldsodefs.h | 1 +
sysdeps/generic/thread_state.h | 1 +
sysdeps/mach/hurd/Makefile | 4 +
sysdeps/mach/hurd/bits/local_lim.h | 9 ++
sysdeps/mach/hurd/bits/posix_opt.h | 42 +++++++----
sysdeps/mach/hurd/dl-sysdep.c | 2 +
sysdeps/mach/hurd/fork.c | 7 ++-
sysdeps/mach/hurd/gai_misc.h | 44 +++++++++++
sysdeps/mach/hurd/hp-timing.h | 42 +++++++++++
sysdeps/mach/hurd/i386/init-first.c | 59 +++++++++------
sysdeps/mach/hurd/i386/tls.h | 58 +++++++++++++--
sysdeps/mach/hurd/i386/tlsdesc.sym | 19 +++++
sysdeps/mach/hurd/i386/trampoline.c | 2 +-
sysdeps/mach/hurd/libc-lock.h | 3 +
sysdeps/mach/hurd/profil.c | 2 +
sysdeps/mach/hurd/ptsname.c | 18 ++++-
sysdeps/mach/hurd/setitimer.c | 3 +-
sysdeps/mach/hurd/sysdep-cancel.h | 9 ++
sysdeps/mach/hurd/tls.h | 13 +++
sysdeps/mach/i386/thread_state.h | 11 +++-
sysdeps/mach/thread_state.h | 3 +
sysdeps/pthread/allocalim.h | 7 +-
sysdeps/pthread/timer_routines.c | 10 ++-
37 files changed, 571 insertions(+), 65 deletions(-)
create mode 100644 hurd/fcntl-internal.h
create mode 100644 include/verify.h
create mode 100644 sysdeps/mach/hurd/gai_misc.h
create mode 100644 sysdeps/mach/hurd/hp-timing.h
create mode 100644 sysdeps/mach/hurd/i386/tlsdesc.sym
create mode 100644 sysdeps/mach/hurd/sysdep-cancel.h
hooks/post-receive
--
GNU C Library master sources