NPTL thread creation
[glibc.git] / sysdeps / nacl / createthread.c
blob89a58a78070b49463b868ef21560d1bc6d9294a9
1 /* Low-level thread creation for NPTL. NaCl version.
2 Copyright (C) 2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <nacl-interfaces.h>
21 /* See the comments in pthread_create.c for the requirements for these
22 two macros and the create_thread function. */
24 #define START_THREAD_DEFN \
25 static void __attribute__ ((noreturn)) start_thread (void)
26 #define START_THREAD_SELF THREAD_SELF
28 /* pthread_create.c defines this using START_THREAD_DEFN
29 We need a forward declaration here so we can take its address. */
30 static void start_thread (void) __attribute__ ((noreturn));
32 static int
33 create_thread (struct pthread *pd, const struct pthread_attr *attr,
34 bool stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran)
36 pd->stopped_start = stopped_start;
37 if (__glibc_unlikely (stopped_start))
38 /* We make sure the thread does not run far by forcing it to get a
39 lock. We lock it here too so that the new thread cannot continue
40 until we tell it to. */
41 lll_lock (pd->lock, LLL_PRIVATE);
43 TLS_DEFINE_INIT_TP (tp, pd);
45 return __nacl_irt_thread.thread_create (&start_thread, stackaddr, tp);