aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/pthread
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2014-06-09 12:52:55 -0700
committerRoland McGrath <roland@hack.frob.com>2014-06-09 12:52:55 -0700
commit962b744d06c1df8653570f32c03da572801e4b6b (patch)
tree408556ab7597eba9480e1bd53379681c01c2a55b /nptl/sysdeps/pthread
parent2976feab1f37ad7b4e06b253f0a2e844505217da (diff)
downloadglibc-962b744d06c1df8653570f32c03da572801e4b6b.tar
glibc-962b744d06c1df8653570f32c03da572801e4b6b.tar.gz
glibc-962b744d06c1df8653570f32c03da572801e4b6b.tar.bz2
glibc-962b744d06c1df8653570f32c03da572801e4b6b.zip
Start cleaning up TLS initial value for pthread_create.
Diffstat (limited to 'nptl/sysdeps/pthread')
-rw-r--r--nptl/sysdeps/pthread/createthread.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index e1856f7b1c..28c1ea67d3 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -30,10 +30,18 @@
#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
-/* Unless otherwise specified, the thread "register" is going to be
- initialized with a pointer to the TCB. */
-#ifndef TLS_VALUE
-# define TLS_VALUE pd
+/* The <tls.h> header should define the macro TLS_DEFINE_INIT_TP such that:
+ TLS_DEFINE_INIT_TP (VAR, PD);
+ Declares and initializes a variable VAR with the value that should
+ be passed to the OS thread creation function (e.g. clone) to initialize
+ its TLS state for the 'struct pthread *' PD. */
+#ifndef TLS_DEFINE_INIT_TP
+/* For a transitional period while all the <tls.h> implementations are
+ getting updated, we define it using the old TLS_VALUE macro. */
+# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = TLS_VALUE
+# ifndef TLS_VALUE
+# define TLS_VALUE pd
+# endif
#endif
#ifndef ARCH_CLONE
@@ -52,9 +60,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
int clone_flags, int (*fct) (void *), STACK_VARIABLES_PARMS,
int stopped)
{
-#ifdef PREPARE_CREATE
- PREPARE_CREATE;
-#endif
+ TLS_DEFINE_INIT_TP (tp, pd);
if (__glibc_unlikely (stopped != 0))
/* We make sure the thread does not run far by forcing it to get a
@@ -73,7 +79,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
atomic_increment (&__nptl_nthreads);
int rc = ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags,
- pd, &pd->tid, TLS_VALUE, &pd->tid);
+ pd, &pd->tid, tp, &pd->tid);
if (__glibc_unlikely (rc == -1))
{