special attention since 'errno' is not yet available and if the
operation can cause a failure 'errno' must not be touched. */
static inline bool __attribute__ ((unused))
-_hurd_tls_init (tcbhead_t *tcb)
+_hurd_tls_init (tcbhead_t *tcb, bool full)
{
HURD_TLS_DESC_DECL (desc, tcb);
thread_t self = __mach_thread_self ();
tcb->tcb = tcb;
/* We always at least start the sigthread anyway. */
tcb->multiple_threads = 1;
- /* Take over the reply port we've been using. */
- tcb->reply_port = __hurd_reply_port0;
+ if (full)
+ /* Take over the reply port we've been using. */
+ tcb->reply_port = __hurd_reply_port0;
/* Get the first available selector. */
int sel = -1;
/* Now install the new selector. */
asm volatile ("mov %w0, %%gs" :: "q" (sel));
- /* This port is now owned by the TCB. */
- __hurd_reply_port0 = MACH_PORT_NULL;
+ if (full)
+ /* This port is now owned by the TCB. */
+ __hurd_reply_port0 = MACH_PORT_NULL;
+#ifndef SHARED
+ else
+ __init1_desc = sel;
+#endif
out:
__mach_port_deallocate (__mach_task_self (), self);
return success;
}
-# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr))
+# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr), 1)
#else /* defined (SHARED) && !IS_IN (rtld) */
# define __LIBC_NO_TLS() 0
#endif
#ifndef SHARED
/* In the static case, we need to set up TLS early so that the stack
protection guard can be read at gs:0x14 by the gcc-generated snippets. */
- _hurd_tls_init (&__init1_tcbhead);
-
- /* Make sure __LIBC_NO_TLS () keeps evaluating to 1. */
-# ifndef __x86_64__
- asm ("movw %%gs,%w0" : "=m" (__init1_desc));
-# endif
+ _hurd_tls_init (&__init1_tcbhead, 0);
#endif
RUN_RELHOOK (_hurd_preinit_hook, ());
# define __LIBC_NO_TLS() __builtin_expect (!__libc_tls_initialized, 0)
static inline bool __attribute__ ((unused))
-_hurd_tls_init (tcbhead_t *tcb)
+_hurd_tls_init (tcbhead_t *tcb, bool full)
{
error_t err;
thread_t self = __mach_thread_self ();
/* We always at least start the sigthread anyway. */
tcb->multiple_threads = 1;
- /* Take over the reply port we've been using. */
- tcb->reply_port = __hurd_reply_port0;
+ if (full)
+ /* Take over the reply port we've been using. */
+ tcb->reply_port = __hurd_reply_port0;
err = _hurd_tls_new (self, tcb);
- if (err == 0)
+ if (err == 0 && full)
{
__libc_tls_initialized = 1;
/* This port is now owned by the TCB. */
return err == 0;
}
-# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr))
+# define TLS_INIT_TP(descr) _hurd_tls_init ((tcbhead_t *) (descr), 1)
# else /* defined (SHARED) && !IS_IN (rtld) */
# define __LIBC_NO_TLS() 0
# endif