@@ -74,6 +74,7 @@ routines = \
pthread_condattr_destroy \
pthread_condattr_init \
pthread_equal \
+ pthread_exit \
pthread_getaffinity \
pthread_getattr_np \
pthread_getschedparam \
@@ -134,7 +135,6 @@ libpthread-routines = \
pthread_condattr_setpshared \
pthread_create \
pthread_detach \
- pthread_exit \
pthread_getattr_default_np \
pthread_getconcurrency \
pthread_getcpuclockid \
@@ -312,7 +312,13 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-thread-affinity-sched \
tst-pthread-defaultattr-free \
tst-pthread-attr-sigmask \
- tst-pthread-timedlock-lockloop
+ tst-pthread-timedlock-lockloop \
+ tst-pthread_exit-nothreads \
+ tst-pthread_exit-nothreads-static \
+
+tests-nolibpthread = \
+ tst-pthread_exit-nothreads \
+ tst-pthread_exit-nothreads-static \
tests-container = tst-pthread-getattr
@@ -437,7 +443,8 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
tests-static += tst-stackguard1-static \
tst-cancel24-static \
tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
- tst-sem12-static tst-cond11-static
+ tst-sem12-static tst-cond11-static \
+ tst-pthread_exit-nothreads-static
tests += tst-cancel24-static
@@ -118,6 +118,7 @@ libc {
__pthread_cleanup_upto;
__pthread_cond_destroy; # Used by the C11 threads.
__pthread_cond_init; # Used by the C11 threads.
+ __pthread_exit;
__pthread_force_elision;
__pthread_getattr_default_np;
__pthread_keys;
@@ -157,7 +158,6 @@ libpthread {
pthread_cond_wait;
pthread_create;
pthread_detach;
- pthread_exit;
pthread_getspecific;
pthread_join;
pthread_key_create;
@@ -41,17 +41,6 @@ name decl \
return PTHFCT_CALL (ptr_##name, params); \
}
-/* Same as FORWARD2, only without return. */
-#define FORWARD_NORETURN(name, rettype, decl, params, defaction) \
-rettype \
-name decl \
-{ \
- if (!__libc_pthread_functions_init) \
- defaction; \
- \
- PTHFCT_CALL (ptr_##name, params); \
-}
-
#define FORWARD(name, decl, params, defretval) \
FORWARD2 (name, int, decl, params, return defretval)
@@ -103,11 +92,6 @@ versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
GLIBC_2_3_2);
-FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval),
- exit (EXIT_SUCCESS))
-strong_alias (__pthread_exit, pthread_exit);
-
-
FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
FORWARD (pthread_mutex_init,
@@ -80,7 +80,6 @@ static const struct pthread_functions pthread_functions =
.ptr___pthread_cond_wait_2_0 = __pthread_cond_wait_2_0,
.ptr___pthread_cond_timedwait_2_0 = __pthread_cond_timedwait_2_0,
# endif
- .ptr___pthread_exit = __pthread_exit,
.ptr_pthread_mutex_destroy = __pthread_mutex_destroy,
.ptr_pthread_mutex_init = __pthread_mutex_init,
.ptr_pthread_mutex_lock = __pthread_mutex_lock,
@@ -535,6 +535,7 @@ extern int __pthread_detach (pthread_t th);
extern int __pthread_cancel (pthread_t th);
extern int __pthread_kill (pthread_t threadid, int signo);
extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
+libc_hidden_proto (__pthread_exit)
extern int __pthread_join (pthread_t threadid, void **thread_return);
extern int __pthread_setcanceltype (int type, int *oldtype);
extern int __pthread_enable_asynccancel (void) attribute_hidden;
@@ -36,8 +36,11 @@ __pthread_exit (void *value)
__do_cancel ();
}
+libc_hidden_def (__pthread_exit)
weak_alias (__pthread_exit, pthread_exit)
-/* After a thread terminates, __libc_start_main decrements
- __nptl_nthreads defined in pthread_create.c. */
-PTHREAD_STATIC_FN_REQUIRE (__pthread_create)
+/* Ensure that the unwinder is always linked in (the __pthread_unwind
+ reference from __do_cancel is weak). Use ___pthread_unwind_next
+ (three underscores) to produce a strong reference to the same
+ file. */
+PTHREAD_STATIC_FN_REQUIRE (___pthread_unwind_next)
new file mode 100644
@@ -0,0 +1,19 @@
+/* Check that pthread_exit works if there are no threads. Static version.
+ Copyright (C) 2021 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "tst-pthread_exit-nothreads.c"
new file mode 100644
@@ -0,0 +1,28 @@
+/* Check that pthread_exit works if there are no threads.
+ Copyright (C) 2021 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, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+
+static int
+do_test (void)
+{
+ pthread_exit (NULL);
+ return 1; /* Not reached. */
+}
+
+#include <support/test-driver.c>
@@ -41,7 +41,6 @@ struct pthread_functions
int (*ptr___pthread_cond_timedwait_2_0) (pthread_cond_2_0_t *,
pthread_mutex_t *,
const struct timespec *);
- void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__));
int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *);
int (*ptr_pthread_mutex_init) (pthread_mutex_t *,
const pthread_mutexattr_t *);
@@ -111,7 +111,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
# Files which must not be linked with libpthread.
-tests-nolibpthread = tst-unload
+tests-nolibpthread += tst-unload
# GCC-4.9 compiles 'sprintf(NULL, ...)' into UD2 on x86_64 without -fno-builtin
CFLAGS-tst-cleanup2.c += -fno-builtin
@@ -56,7 +56,6 @@ GLIBC_2.17 pthread_condattr_setclock F
GLIBC_2.17 pthread_condattr_setpshared F
GLIBC_2.17 pthread_create F
GLIBC_2.17 pthread_detach F
-GLIBC_2.17 pthread_exit F
GLIBC_2.17 pthread_getconcurrency F
GLIBC_2.17 pthread_getcpuclockid F
GLIBC_2.17 pthread_getname_np F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -71,7 +71,6 @@ GLIBC_2.32 pthread_condattr_setclock F
GLIBC_2.32 pthread_condattr_setpshared F
GLIBC_2.32 pthread_create F
GLIBC_2.32 pthread_detach F
-GLIBC_2.32 pthread_exit F
GLIBC_2.32 pthread_getattr_default_np F
GLIBC_2.32 pthread_getconcurrency F
GLIBC_2.32 pthread_getcpuclockid F
@@ -90,7 +90,6 @@ GLIBC_2.4 pthread_condattr_setclock F
GLIBC_2.4 pthread_condattr_setpshared F
GLIBC_2.4 pthread_create F
GLIBC_2.4 pthread_detach F
-GLIBC_2.4 pthread_exit F
GLIBC_2.4 pthread_getconcurrency F
GLIBC_2.4 pthread_getcpuclockid F
GLIBC_2.4 pthread_getspecific F
@@ -90,7 +90,6 @@ GLIBC_2.4 pthread_condattr_setclock F
GLIBC_2.4 pthread_condattr_setpshared F
GLIBC_2.4 pthread_create F
GLIBC_2.4 pthread_detach F
-GLIBC_2.4 pthread_exit F
GLIBC_2.4 pthread_getconcurrency F
GLIBC_2.4 pthread_getcpuclockid F
GLIBC_2.4 pthread_getspecific F
@@ -69,7 +69,6 @@ GLIBC_2.29 pthread_condattr_setclock F
GLIBC_2.29 pthread_condattr_setpshared F
GLIBC_2.29 pthread_create F
GLIBC_2.29 pthread_detach F
-GLIBC_2.29 pthread_exit F
GLIBC_2.29 pthread_getattr_default_np F
GLIBC_2.29 pthread_getconcurrency F
GLIBC_2.29 pthread_getcpuclockid F
@@ -56,7 +56,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -56,7 +56,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -90,7 +90,6 @@ GLIBC_2.4 pthread_condattr_setclock F
GLIBC_2.4 pthread_condattr_setpshared F
GLIBC_2.4 pthread_create F
GLIBC_2.4 pthread_detach F
-GLIBC_2.4 pthread_exit F
GLIBC_2.4 pthread_getconcurrency F
GLIBC_2.4 pthread_getcpuclockid F
GLIBC_2.4 pthread_getspecific F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -56,7 +56,6 @@ GLIBC_2.18 pthread_condattr_setclock F
GLIBC_2.18 pthread_condattr_setpshared F
GLIBC_2.18 pthread_create F
GLIBC_2.18 pthread_detach F
-GLIBC_2.18 pthread_exit F
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_getconcurrency F
GLIBC_2.18 pthread_getcpuclockid F
@@ -56,7 +56,6 @@ GLIBC_2.18 pthread_condattr_setclock F
GLIBC_2.18 pthread_condattr_setpshared F
GLIBC_2.18 pthread_create F
GLIBC_2.18 pthread_detach F
-GLIBC_2.18 pthread_exit F
GLIBC_2.18 pthread_getattr_default_np F
GLIBC_2.18 pthread_getconcurrency F
GLIBC_2.18 pthread_getcpuclockid F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -56,7 +56,6 @@ GLIBC_2.21 pthread_condattr_setclock F
GLIBC_2.21 pthread_condattr_setpshared F
GLIBC_2.21 pthread_create F
GLIBC_2.21 pthread_detach F
-GLIBC_2.21 pthread_exit F
GLIBC_2.21 pthread_getattr_default_np F
GLIBC_2.21 pthread_getconcurrency F
GLIBC_2.21 pthread_getcpuclockid F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -76,7 +76,6 @@ GLIBC_2.3 pthread_condattr_getpshared F
GLIBC_2.3 pthread_condattr_setpshared F
GLIBC_2.3 pthread_create F
GLIBC_2.3 pthread_detach F
-GLIBC_2.3 pthread_exit F
GLIBC_2.3 pthread_getconcurrency F
GLIBC_2.3 pthread_getcpuclockid F
GLIBC_2.3 pthread_getspecific F
@@ -56,7 +56,6 @@ GLIBC_2.17 pthread_condattr_setclock F
GLIBC_2.17 pthread_condattr_setpshared F
GLIBC_2.17 pthread_create F
GLIBC_2.17 pthread_detach F
-GLIBC_2.17 pthread_exit F
GLIBC_2.17 pthread_getconcurrency F
GLIBC_2.17 pthread_getcpuclockid F
GLIBC_2.17 pthread_getname_np F
@@ -71,7 +71,6 @@ GLIBC_2.33 pthread_condattr_setclock F
GLIBC_2.33 pthread_condattr_setpshared F
GLIBC_2.33 pthread_create F
GLIBC_2.33 pthread_detach F
-GLIBC_2.33 pthread_exit F
GLIBC_2.33 pthread_getattr_default_np F
GLIBC_2.33 pthread_getconcurrency F
GLIBC_2.33 pthread_getcpuclockid F
@@ -56,7 +56,6 @@ GLIBC_2.27 pthread_condattr_setclock F
GLIBC_2.27 pthread_condattr_setpshared F
GLIBC_2.27 pthread_create F
GLIBC_2.27 pthread_detach F
-GLIBC_2.27 pthread_exit F
GLIBC_2.27 pthread_getattr_default_np F
GLIBC_2.27 pthread_getconcurrency F
GLIBC_2.27 pthread_getcpuclockid F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -57,7 +57,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -56,7 +56,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -56,7 +56,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -25,7 +25,6 @@ GLIBC_2.0 pthread_cond_timedwait F
GLIBC_2.0 pthread_cond_wait F
GLIBC_2.0 pthread_create F
GLIBC_2.0 pthread_detach F
-GLIBC_2.0 pthread_exit F
GLIBC_2.0 pthread_getspecific F
GLIBC_2.0 pthread_join F
GLIBC_2.0 pthread_key_create F
@@ -56,7 +56,6 @@ GLIBC_2.2 pthread_condattr_getpshared F
GLIBC_2.2 pthread_condattr_setpshared F
GLIBC_2.2 pthread_create F
GLIBC_2.2 pthread_detach F
-GLIBC_2.2 pthread_exit F
GLIBC_2.2 pthread_getconcurrency F
GLIBC_2.2 pthread_getcpuclockid F
GLIBC_2.2 pthread_getspecific F
@@ -56,7 +56,6 @@ GLIBC_2.2.5 pthread_condattr_getpshared F
GLIBC_2.2.5 pthread_condattr_setpshared F
GLIBC_2.2.5 pthread_create F
GLIBC_2.2.5 pthread_detach F
-GLIBC_2.2.5 pthread_exit F
GLIBC_2.2.5 pthread_getconcurrency F
GLIBC_2.2.5 pthread_getcpuclockid F
GLIBC_2.2.5 pthread_getspecific F
@@ -56,7 +56,6 @@ GLIBC_2.16 pthread_condattr_setclock F
GLIBC_2.16 pthread_condattr_setpshared F
GLIBC_2.16 pthread_create F
GLIBC_2.16 pthread_detach F
-GLIBC_2.16 pthread_exit F
GLIBC_2.16 pthread_getconcurrency F
GLIBC_2.16 pthread_getcpuclockid F
GLIBC_2.16 pthread_getname_np F