createthread.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Low-level thread creation for NPTL. Stub version.
  2. Copyright (C) 2014-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. /* See the comments in pthread_create.c for the requirements for these
  16. two macros and the create_thread function. */
  17. #define START_THREAD_DEFN \
  18. static void __attribute__ ((noreturn)) start_thread (void)
  19. #define START_THREAD_SELF THREAD_SELF
  20. static int
  21. create_thread (struct pthread *pd, const struct pthread_attr *attr,
  22. bool *stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran)
  23. {
  24. /* If the implementation needs to do some tweaks to the thread after
  25. it has been created at the OS level, it can set STOPPED_START here. */
  26. pd->stopped_start = *stopped_start;
  27. if (__glibc_unlikely (*stopped_start))
  28. /* See CONCURRENCY NOTES in nptl/pthread_create.c. */
  29. lll_lock (pd->lock, LLL_PRIVATE);
  30. return ENOSYS;
  31. /* It's started now, so if we fail below, we'll have to cancel it
  32. and let it clean itself up. */
  33. *thread_ran = true;
  34. return 0;
  35. }