From: gfleury Date: Sat, 1 Feb 2025 08:02:02 +0000 (+0200) Subject: htl: move pthread_setcancelstate into libc. X-Git-Tag: glibc-2.42~534 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf51d18b9daf510de1997d4d87328c03103a6b68;p=thirdparty%2Fglibc.git htl: move pthread_setcancelstate into libc. sysdeps/pthread/sem_open.c: call pthread_setcancelstate directely since forward declaration is gone on hurd too Message-ID: <20250201080202.494671-1-gfleury@disroot.org> --- diff --git a/htl/Makefile b/htl/Makefile index d4418ab9f9..a4192a56b4 100644 --- a/htl/Makefile +++ b/htl/Makefile @@ -50,7 +50,6 @@ libpthread-routines := \ pt-join \ pt-spin-inlines \ pt-cleanup \ - pt-setcancelstate \ pt-testcancel \ pt-cancel \ pt-mutex-transfer-np \ @@ -203,6 +202,7 @@ routines := \ pt-nthreads \ pt-pthread_self \ pt-self pt-equal \ + pt-setcancelstate \ pt-setcanceltype \ pt-setschedparam \ pt-sigmask \ diff --git a/htl/Versions b/htl/Versions index 6801d12182..d8f1c7f437 100644 --- a/htl/Versions +++ b/htl/Versions @@ -56,6 +56,7 @@ libc { pthread_mutexattr_setprotocol; pthread_mutexattr_setpshared; pthread_mutexattr_settype; + pthread_setcancelstate; pthread_setcanceltype; pthread_sigmask; } @@ -146,6 +147,7 @@ libc { __pthread_attr_setstacksize; __pthread_attr_setstackaddr; __pthread_attr_setstack; + __pthread_setcancelstate; __pthread_cond_broadcast; __pthread_cond_destroy; __pthread_cond_init; @@ -232,7 +234,6 @@ libpthread { pthread_rwlockattr_destroy; pthread_rwlockattr_getpshared; pthread_rwlockattr_init; pthread_rwlockattr_setpshared; - pthread_setcancelstate; pthread_setconcurrency; pthread_setschedprio; pthread_setspecific; diff --git a/htl/forward.c b/htl/forward.c index 9455df7316..0a7a69644d 100644 --- a/htl/forward.c +++ b/htl/forward.c @@ -58,9 +58,5 @@ FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS)) strong_alias (__pthread_exit, pthread_exit); -FORWARD (__pthread_setcancelstate, (int state, int *oldstate), - (state, oldstate), 0) -strong_alias (__pthread_setcancelstate, pthread_setcancelstate); - FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **, (void), (), return &__pthread_cleanup_stack); diff --git a/htl/pt-initialize.c b/htl/pt-initialize.c index eba9e12d73..53b9c76e8f 100644 --- a/htl/pt-initialize.c +++ b/htl/pt-initialize.c @@ -28,7 +28,6 @@ #if IS_IN (libpthread) static const struct pthread_functions pthread_functions = { .ptr___pthread_exit = __pthread_exit, - .ptr___pthread_setcancelstate = __pthread_setcancelstate, .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack, .ptr_pthread_once = __pthread_once, .ptr_pthread_rwlock_rdlock = __pthread_rwlock_rdlock, diff --git a/htl/pt-setcancelstate.c b/htl/pt-setcancelstate.c index 57894de718..6e09c260ea 100644 --- a/htl/pt-setcancelstate.c +++ b/htl/pt-setcancelstate.c @@ -17,7 +17,7 @@ . */ #include - +#include #include int @@ -42,5 +42,9 @@ __pthread_setcancelstate (int state, int *oldstate) return 0; } +libc_hidden_def (__pthread_setcancelstate) +versioned_symbol (libc, __pthread_setcancelstate, pthread_setcancelstate, GLIBC_2_21); -weak_alias (__pthread_setcancelstate, pthread_setcancelstate); +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libc, __pthread_setcancelstate, pthread_setcancelstate, GLIBC_2_12); +#endif diff --git a/sysdeps/htl/libc-lockP.h b/sysdeps/htl/libc-lockP.h index f39c8bba87..6804c0d636 100644 --- a/sysdeps/htl/libc-lockP.h +++ b/sysdeps/htl/libc-lockP.h @@ -75,7 +75,6 @@ extern int __pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__mutex_attr); - extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); libc_hidden_proto (__pthread_mutex_destroy) @@ -113,6 +112,8 @@ extern int __pthread_atfork (void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)); +extern int __pthread_setcancelstate (int state, int *oldstate); +libc_hidden_proto (__pthread_setcancelstate) /* Make the pthread functions weak so that we can elide them from single-threaded processes. */ #if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread) @@ -130,7 +131,6 @@ weak_extern (__pthread_getspecific) weak_extern (__pthread_once) weak_extern (__pthread_initialize) weak_extern (__pthread_atfork) -weak_extern (__pthread_setcancelstate) # else # pragma weak __pthread_rwlock_destroy # pragma weak __pthread_rwlock_rdlock @@ -144,7 +144,6 @@ weak_extern (__pthread_setcancelstate) # pragma weak __pthread_once # pragma weak __pthread_initialize # pragma weak __pthread_atfork -# pragma weak __pthread_setcancelstate # endif #endif diff --git a/sysdeps/htl/pthread-functions.h b/sysdeps/htl/pthread-functions.h index 9788085b83..56b5b2383e 100644 --- a/sysdeps/htl/pthread-functions.h +++ b/sysdeps/htl/pthread-functions.h @@ -22,7 +22,6 @@ #include void __pthread_exit (void *) __attribute__ ((__noreturn__)); -int __pthread_setcancelstate (int, int *); struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void); int __pthread_once (pthread_once_t *, void (*) (void)); int __pthread_rwlock_rdlock (pthread_rwlock_t *); @@ -42,7 +41,6 @@ int _cthreads_ftrylockfile (FILE *); struct pthread_functions { void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__)); - int (*ptr___pthread_setcancelstate) (int, int *); struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void); int (*ptr_pthread_once) (pthread_once_t *, void (*) (void)); int (*ptr_pthread_rwlock_rdlock) (pthread_rwlock_t *); diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 889a63200d..1a1b9ff39a 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -146,8 +146,6 @@ int __pthread_setspecific (pthread_key_t key, const void *value); int __pthread_key_delete (pthread_key_t key); int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)); -int __pthread_setcancelstate (int state, int *oldstate); - int __pthread_getattr_np (pthread_t, pthread_attr_t *); int __pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr); diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index c26eddba3d..30c01aaf23 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -82,6 +82,7 @@ GLIBC_2.12 pthread_mutexattr_setprotocol F GLIBC_2.12 pthread_mutexattr_setpshared F GLIBC_2.12 pthread_mutexattr_settype F GLIBC_2.12 pthread_self F +GLIBC_2.12 pthread_setcancelstate F GLIBC_2.12 pthread_setcanceltype F GLIBC_2.12 pthread_setschedparam F GLIBC_2.12 pthread_sigmask F diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index 30b598ffd9..0cefd91495 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -56,7 +56,6 @@ GLIBC_2.12 pthread_rwlockattr_destroy F GLIBC_2.12 pthread_rwlockattr_getpshared F GLIBC_2.12 pthread_rwlockattr_init F GLIBC_2.12 pthread_rwlockattr_setpshared F -GLIBC_2.12 pthread_setcancelstate F GLIBC_2.12 pthread_setconcurrency F GLIBC_2.12 pthread_setschedprio F GLIBC_2.12 pthread_setspecific F diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist index 800b7935fb..0812c7c735 100644 --- a/sysdeps/mach/hurd/x86_64/libpthread.abilist +++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist @@ -78,7 +78,6 @@ GLIBC_2.38 pthread_rwlockattr_destroy F GLIBC_2.38 pthread_rwlockattr_getpshared F GLIBC_2.38 pthread_rwlockattr_init F GLIBC_2.38 pthread_rwlockattr_setpshared F -GLIBC_2.38 pthread_setcancelstate F GLIBC_2.38 pthread_setconcurrency F GLIBC_2.38 pthread_setschedprio F GLIBC_2.38 pthread_setspecific F diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c index 9f242599d5..e5eacb5fed 100644 --- a/sysdeps/pthread/sem_open.c +++ b/sysdeps/pthread/sem_open.c @@ -26,6 +26,7 @@ #include #include + #if !PTHREAD_IN_LIBC /* The private names are not exported from libc. */ # define __link link @@ -57,11 +58,7 @@ __sem_open (const char *name, int oflag, ...) } /* Disable asynchronous cancellation. */ -#ifdef __libc_ptf_call - int state; - __libc_ptf_call (__pthread_setcancelstate, - (PTHREAD_CANCEL_DISABLE, &state), 0); -#endif + int state = __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); /* If the semaphore object has to exist simply open it. */ if ((oflag & O_CREAT) == 0 || (oflag & O_EXCL) == 0) @@ -214,9 +211,7 @@ __sem_open (const char *name, int oflag, ...) } out: -#ifdef __libc_ptf_call - __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0); -#endif + __pthread_setcancelstate (state, NULL); return result; }