diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-05-10 17:24:56 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-01-03 18:38:16 -0200 |
commit | ce7eb0e90315eb1939ac29f656d39b3db858c092 (patch) | |
tree | 66f46e348749230c9fb9c95e7d77b01eff8598c9 /sysdeps/unix/sysv/linux/clock_nanosleep.c | |
parent | 0b13e25581afb4ce95373f18249b91c104280a13 (diff) | |
download | glibc-ce7eb0e90315eb1939ac29f656d39b3db858c092.tar.gz glibc-ce7eb0e90315eb1939ac29f656d39b3db858c092.tar.xz glibc-ce7eb0e90315eb1939ac29f656d39b3db858c092.zip |
nptl: Cleanup cancellation macros
This patch wraps all uses of *_{enable,disable}_asynccancel and and *_CANCEL_{ASYNC,RESET} in either already provided macros (lll_futex_timed_wait_cancel) or creates new ones if the functionality is not provided (SYSCALL_CANCEL_NCS, lll_futex_wait_cancel, and lll_futex_timed_wait_cancel). Also for some generic implementations, the direct call of the macros are removed since the underlying symbols are suppose to provide cancellation support. This is a priliminary patch intended to simplify the work required for BZ#12683 fix. It is a refactor change, no semantic changes are expected. Checked on x86_64-linux-gnu and i686-linux-gnu. * nptl/pthread_join_common.c (__pthread_timedjoin_ex): Use lll_wait_tid with timeout. * nptl/sem_wait.c (__old_sem_wait): Use lll_futex_wait_cancel. * sysdeps/nptl/aio_misc.h (AIO_MISC_WAIT): Use futex_reltimed_wait_cancelable for cancelabla mode. * sysdeps/nptl/gai_misc.h (GAI_MISC_WAIT): Likewise. * sysdeps/posix/open64.c (__libc_open64): Do not call cancelation macros. * sysdeps/posix/sigwait.c (__sigwait): Likewise. * sysdeps/posix/waitid.c (__sigwait): Likewise. * sysdeps/unix/sysdep.h (__SYSCALL_CANCEL_CALL, SYSCALL_CANCEL_NCS): New macro. * sysdeps/nptl/lowlevellock.h (lll_wait_tid): Add timeout argument. (lll_timedwait_tid): Remove macro. * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_wait_tid): Likewise. (lll_timedwait_tid): Likewise. * sysdeps/unix/sysv/linux/clock_nanosleep.c (__clock_nanosleep): Use INTERNAL_SYSCALL_CANCEL. * sysdeps/unix/sysv/linux/futex-internal.h (futex_reltimed_wait_cancelable): Use LIBC_CANCEL_{ASYNC,RESET} instead of __pthread_{enable,disable}_asynccancel. * sysdeps/unix/sysv/linux/lowlevellock-futex.h (lll_futex_wait_cancel): New macro.
Diffstat (limited to 'sysdeps/unix/sysv/linux/clock_nanosleep.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/clock_nanosleep.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 0f6dd5d359..0cb6614dc9 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -28,26 +28,16 @@ int __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) { - INTERNAL_SYSCALL_DECL (err); - int r; - if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL; if (clock_id == CLOCK_PROCESS_CPUTIME_ID) clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); - if (SINGLE_THREAD_P) - r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); - else - { - int oldstate = LIBC_CANCEL_ASYNC (); - - r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, - rem); - - LIBC_CANCEL_RESET (oldstate); - } - + /* If the call is interrupted by a signal handler or encounters an error, + it returns a positive value similar to errno. */ + INTERNAL_SYSCALL_DECL (err); + int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags, + req, rem); return (INTERNAL_SYSCALL_ERROR_P (r, err) ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); } |