aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-04-21 19:49:50 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-04-21 19:49:50 +0200
commit1f2e5bfe48ae7a0a74896d7f3019d976c1647e56 (patch)
tree103c889d6d7a47e9e3be01325aaaa5d532ed75a6 /nptl
parentf79f2065817e080f65f3c3a2fee966f5a97f1746 (diff)
downloadglibc-1f2e5bfe48ae7a0a74896d7f3019d976c1647e56.tar
glibc-1f2e5bfe48ae7a0a74896d7f3019d976c1647e56.tar.gz
glibc-1f2e5bfe48ae7a0a74896d7f3019d976c1647e56.tar.bz2
glibc-1f2e5bfe48ae7a0a74896d7f3019d976c1647e56.zip
nptl: Move legacy cancelation handling into libc as compat symbols
This affects _pthread_cleanup_pop, _pthread_cleanup_pop_restore, _pthread_cleanup_push, _pthread_cleanup_push_defer. The symbols have been moved using scripts/move-symbol-to-libc.py. No new symbol versions are added because the symbols are turned into compatibility symbols at the same time. __pthread_cleanup_pop and __pthread_cleanup_push are added as GLIBC_PRIVATE symbols because they are also used internally, for glibc's own cancellation handling. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile15
-rw-r--r--nptl/Versions10
-rw-r--r--nptl/cleanup_compat.c18
-rw-r--r--nptl/cleanup_defer_compat.c20
-rw-r--r--nptl/pthreadP.h17
-rw-r--r--nptl/tst-cleanup4.c5
-rw-r--r--nptl/tst-cleanup4aux.c5
7 files changed, 60 insertions, 30 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index 9bb9c6f3da..6815871ef4 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -30,6 +30,8 @@ extra-libs-others := $(extra-libs)
routines = \
alloca_cutoff \
+ cleanup_compat \
+ cleanup_defer_compat \
cleanup_routine \
elision-conf \
elision-lock \
@@ -84,9 +86,7 @@ static-only-routines = pthread_atfork
libpthread-routines = \
cancellation \
cleanup \
- cleanup_compat \
cleanup_defer \
- cleanup_defer_compat \
events \
flockfile \
ftrylockfile \
@@ -293,7 +293,6 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-tsd3 tst-tsd4 \
tst-cancel4_1 tst-cancel4_2 \
tst-cancel7 tst-cancel17 tst-cancel24 \
- tst-cleanup4 \
tst-signal3 \
tst-exec4 tst-exec5 \
tst-stack2 tst-stack3 tst-stack4 \
@@ -381,7 +380,7 @@ endif
LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
-tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4
+tests += tst-cancelx7 tst-cancelx17
ifeq ($(build-shared),yes)
tests += tst-compat-forwarder tst-audit-threads
@@ -401,6 +400,14 @@ extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
tst-cleanup4aux.o tst-cleanupx4aux.o
test-extras += tst-cleanup4aux tst-cleanupx4aux
+# This test exercises compat symbols removed in glibc 2.34.
+ifdef have-GLIBC_2.33
+tests += tst-cleanup4
+ifeq ($(build-shared),yes)
+tests += tst-cleanupx4
+endif
+endif
+
tst-tls3mod.so-no-z-defs = yes
tst-tls5mod.so-no-z-defs = yes
tst-tls5moda.so-no-z-defs = yes
diff --git a/nptl/Versions b/nptl/Versions
index 2e5a964b11..deba8ce214 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -1,5 +1,9 @@
libc {
GLIBC_2.0 {
+ _pthread_cleanup_pop;
+ _pthread_cleanup_pop_restore;
+ _pthread_cleanup_push;
+ _pthread_cleanup_push_defer;
pthread_attr_destroy;
pthread_attr_getdetachstate;
pthread_attr_getinheritsched;
@@ -102,6 +106,8 @@ libc {
__pthread_attr_init;
__pthread_attr_setaffinity_np;
__pthread_attr_setsigmask_internal;
+ __pthread_cleanup_pop;
+ __pthread_cleanup_push;
__pthread_cond_destroy; # Used by the C11 threads.
__pthread_cond_init; # Used by the C11 threads.
__pthread_force_elision;
@@ -131,10 +137,6 @@ libpthread {
__pthread_once;
__pthread_setspecific;
_exit;
- _pthread_cleanup_pop;
- _pthread_cleanup_pop_restore;
- _pthread_cleanup_push;
- _pthread_cleanup_push_defer;
flockfile;
ftrylockfile;
funlockfile;
diff --git a/nptl/cleanup_compat.c b/nptl/cleanup_compat.c
index fec88c2f86..1a757cf06a 100644
--- a/nptl/cleanup_compat.c
+++ b/nptl/cleanup_compat.c
@@ -16,12 +16,12 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <shlib-compat.h>
#include <stdlib.h>
#include "pthreadP.h"
-
void
-_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+__pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
void (*routine) (void *), void *arg)
{
struct pthread *self = THREAD_SELF;
@@ -32,11 +32,10 @@ _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
THREAD_SETMEM (self, cleanup, buffer);
}
-strong_alias (_pthread_cleanup_push, __pthread_cleanup_push)
-
+libc_hidden_def (__pthread_cleanup_push)
void
-_pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, int execute)
+__pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, int execute)
{
struct pthread *self __attribute ((unused)) = THREAD_SELF;
@@ -47,4 +46,11 @@ _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, int execute)
if (execute)
buffer->__routine (buffer->__arg);
}
-strong_alias (_pthread_cleanup_pop, __pthread_cleanup_pop)
+libc_hidden_def (__pthread_cleanup_pop)
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libpthread, __pthread_cleanup_push, _pthread_cleanup_push,
+ GLIBC_2_0);
+compat_symbol (libpthread, __pthread_cleanup_pop, _pthread_cleanup_pop,
+ GLIBC_2_0);
+#endif
diff --git a/nptl/cleanup_defer_compat.c b/nptl/cleanup_defer_compat.c
index 1957318208..238eb46ee4 100644
--- a/nptl/cleanup_defer_compat.c
+++ b/nptl/cleanup_defer_compat.c
@@ -16,10 +16,13 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include "pthreadP.h"
-#include <libc-lock.h>
+#include <shlib-compat.h>
-void
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
+# include "pthreadP.h"
+# include <libc-lock.h>
+
+void attribute_compat_text_section
_pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
void (*routine) (void *), void *arg)
{
@@ -27,10 +30,10 @@ _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
buffer->__arg = arg;
__libc_cleanup_push_defer (buffer);
}
-strong_alias (_pthread_cleanup_push_defer, __pthread_cleanup_push_defer)
-
+compat_symbol (libpthread, _pthread_cleanup_push_defer,
+ _pthread_cleanup_push_defer, GLIBC_2_0);
-void
+void attribute_compat_text_section
_pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
int execute)
{
@@ -41,4 +44,7 @@ _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
if (execute)
buffer->__routine (buffer->__arg);
}
-strong_alias (_pthread_cleanup_pop_restore, __pthread_cleanup_pop_restore)
+compat_symbol (libpthread, _pthread_cleanup_pop_restore,
+ _pthread_cleanup_pop_restore, GLIBC_2_0);
+
+#endif /* OTHER_SHLIB_COMPAT */
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 2653e0f1b3..9cc968222f 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -591,11 +591,10 @@ libc_hidden_proto (__pthread_attr_setsigmask_internal)
extern __typeof (pthread_attr_getsigmask_np) __pthread_attr_getsigmask_np;
libc_hidden_proto (__pthread_attr_getsigmask_np)
-#if IS_IN (libpthread)
/* Special versions which use non-exported functions. */
extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
- void (*routine) (void *), void *arg)
- attribute_hidden;
+ void (*routine) (void *), void *arg);
+libc_hidden_proto (__pthread_cleanup_push)
/* Replace cleanup macros defined in <pthread.h> with internal
versions that don't depend on unwind info and better support
@@ -606,12 +605,13 @@ extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
__pthread_cleanup_push (&_buffer, (routine), (arg));
extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
- int execute) attribute_hidden;
+ int execute);
+libc_hidden_proto (__pthread_cleanup_pop)
# undef pthread_cleanup_pop
# define pthread_cleanup_pop(execute) \
__pthread_cleanup_pop (&_buffer, (execute)); }
-# if defined __EXCEPTIONS && !defined __cplusplus
+#if defined __EXCEPTIONS && !defined __cplusplus
/* Structure to hold the cleanup handler information. */
struct __pthread_cleanup_combined_frame
{
@@ -652,7 +652,7 @@ __pthread_cleanup_combined_routine_voidptr (void *__arg)
}
}
-# define pthread_cleanup_combined_push(routine, arg) \
+# define pthread_cleanup_combined_push(routine, arg) \
do { \
void (*__cancel_routine) (void *) = (routine); \
struct __pthread_cleanup_combined_frame __clframe \
@@ -663,15 +663,14 @@ __pthread_cleanup_combined_routine_voidptr (void *__arg)
__pthread_cleanup_combined_routine_voidptr, \
&__clframe);
-# define pthread_cleanup_combined_pop(execute) \
+# define pthread_cleanup_combined_pop(execute) \
__pthread_cleanup_pop (&__clframe.__buffer, 0); \
__clframe.__do_it = 0; \
if (execute) \
__cancel_routine (__clframe.__cancel_arg); \
} while (0)
-# endif
-#endif
+#endif /* __EXCEPTIONS && !defined __cplusplus */
extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
void (*routine) (void *), void *arg);
diff --git a/nptl/tst-cleanup4.c b/nptl/tst-cleanup4.c
index 24c062db1a..4a275ed950 100644
--- a/nptl/tst-cleanup4.c
+++ b/nptl/tst-cleanup4.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <pthread.h>
+#include <shlib-compat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -25,8 +26,12 @@
extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg);
+compat_symbol_reference (libpthread, _pthread_cleanup_push,
+ _pthread_cleanup_push, GLIBC_2_0);
extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
int __execute);
+compat_symbol_reference (libpthread, _pthread_cleanup_pop,
+ _pthread_cleanup_pop, GLIBC_2_0);
static int fds[2];
static pthread_barrier_t b2;
diff --git a/nptl/tst-cleanup4aux.c b/nptl/tst-cleanup4aux.c
index d20730ddf2..6c7356e763 100644
--- a/nptl/tst-cleanup4aux.c
+++ b/nptl/tst-cleanup4aux.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <pthread.h>
+#include <shlib-compat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -24,8 +25,12 @@
extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *),
void *__arg);
+compat_symbol_reference (libpthread, _pthread_cleanup_push,
+ _pthread_cleanup_push, GLIBC_2_0);
extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
int __execute);
+compat_symbol_reference (libpthread, _pthread_cleanup_pop,
+ _pthread_cleanup_pop, GLIBC_2_0);
extern void clh (void *arg);
extern void fn0 (void);