mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
nptl: Consolidate async cancel enable/disable implementation in libc
Previously, the source file nptl/cancellation.c was compiled multiple times, for libc, libpthread, librt. This commit switches to a single implementation, with new __pthread_enable_asynccancel@@GLIBC_PRIVATE, __pthread_disable_asynccancel@@GLIBC_PRIVATE exports. The almost-unused CANCEL_ASYNC and CANCEL_RESET macros are replaced by LIBC_CANCEL_ASYNC and LIBC_CANCEL_ASYNC macros. They call the __pthread_* functions unconditionally now. The macros are still needed because shared code uses them; Hurd has different definitions. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@ -89,11 +89,6 @@
|
||||
})
|
||||
|
||||
|
||||
#if IS_IN (libc)
|
||||
# define __pthread_enable_asynccancel __libc_enable_asynccancel
|
||||
# define __pthread_disable_asynccancel __libc_disable_asynccancel
|
||||
#endif
|
||||
|
||||
#define SOCKETCALL_CANCEL(name, args...) \
|
||||
({ \
|
||||
int oldtype = LIBC_CANCEL_ASYNC (); \
|
||||
|
@ -24,44 +24,14 @@
|
||||
#include <tls.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* The two functions are in libc.so and not exported. */
|
||||
extern int __libc_enable_asynccancel (void) attribute_hidden;
|
||||
extern void __libc_disable_asynccancel (int oldtype) attribute_hidden;
|
||||
|
||||
/* The two functions are in librt.so and not exported. */
|
||||
extern int __librt_enable_asynccancel (void) attribute_hidden;
|
||||
extern void __librt_disable_asynccancel (int oldtype) attribute_hidden;
|
||||
|
||||
/* The two functions are in libpthread.so and not exported. */
|
||||
extern int __pthread_enable_asynccancel (void) attribute_hidden;
|
||||
extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden;
|
||||
|
||||
/* Set cancellation mode to asynchronous. */
|
||||
#define CANCEL_ASYNC() \
|
||||
__pthread_enable_asynccancel ()
|
||||
extern int __pthread_enable_asynccancel (void);
|
||||
libc_hidden_proto (__pthread_enable_asynccancel)
|
||||
#define LIBC_CANCEL_ASYNC() __pthread_enable_asynccancel ()
|
||||
|
||||
/* Reset to previous cancellation mode. */
|
||||
#define CANCEL_RESET(oldtype) \
|
||||
__pthread_disable_asynccancel (oldtype)
|
||||
|
||||
#if IS_IN (libc)
|
||||
/* Same as CANCEL_ASYNC, but for use in libc.so. */
|
||||
# define LIBC_CANCEL_ASYNC() \
|
||||
__libc_enable_asynccancel ()
|
||||
/* Same as CANCEL_RESET, but for use in libc.so. */
|
||||
# define LIBC_CANCEL_RESET(oldtype) \
|
||||
__libc_disable_asynccancel (oldtype)
|
||||
#elif IS_IN (libpthread)
|
||||
# define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
|
||||
# define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
|
||||
#elif IS_IN (librt)
|
||||
# define LIBC_CANCEL_ASYNC() \
|
||||
__librt_enable_asynccancel ()
|
||||
# define LIBC_CANCEL_RESET(val) \
|
||||
__librt_disable_asynccancel (val)
|
||||
#else
|
||||
# define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
|
||||
# define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
|
||||
#endif
|
||||
|
||||
extern void __pthread_disable_asynccancel (int oldtype);
|
||||
libc_hidden_proto (__pthread_disable_asynccancel)
|
||||
#define LIBC_CANCEL_RESET(oldtype) __pthread_disable_asynccancel (oldtype)
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user