diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/not-cancel.h')
-rw-r--r-- | sysdeps/unix/sysv/linux/not-cancel.h | 122 |
1 files changed, 54 insertions, 68 deletions
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index d23136d2ad..09de92dee9 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -1,5 +1,5 @@ /* Uncancelable versions of cancelable interfaces. Linux/NPTL version. - Copyright (C) 2003-2016 Free Software Foundation, Inc. + Copyright (C) 2003-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. @@ -20,90 +20,76 @@ #ifndef NOT_CANCEL_H # define NOT_CANCEL_H +#include <fcntl.h> #include <sysdep.h> #include <errno.h> #include <unistd.h> #include <sys/syscall.h> +#include <sys/wait.h> +#include <time.h> -/* Uncancelable open. */ -#ifdef __NR_open -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (open, 3, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (open, 2, name, flags) -#else -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (openat, 4, AT_FDCWD, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (openat, 3, AT_FDCWD, name, flags) -#endif +/* Non cancellable open syscall. */ +__typeof (open) __open_nocancel; -/* Uncancelable read. */ -#define __read_nocancel(fd, buf, len) \ - INLINE_SYSCALL (read, 3, fd, buf, len) +/* Non cancellable open syscall (LFS version). */ +__typeof (open64) __open64_nocancel; -/* Uncancelable write. */ -#define __write_nocancel(fd, buf, len) \ - INLINE_SYSCALL (write, 3, fd, buf, len) - -/* Uncancelable openat. */ -#define openat_not_cancel(fd, fname, oflag, mode) \ - INLINE_SYSCALL (openat, 4, fd, fname, oflag, mode) -#define openat_not_cancel_3(fd, fname, oflag) \ - INLINE_SYSCALL (openat, 3, fd, fname, oflag) -#define openat64_not_cancel(fd, fname, oflag, mode) \ - INLINE_SYSCALL (openat, 4, fd, fname, oflag | O_LARGEFILE, mode) -#define openat64_not_cancel_3(fd, fname, oflag) \ - INLINE_SYSCALL (openat, 3, fd, fname, oflag | O_LARGEFILE) +/* Non cancellable openat syscall. */ +__typeof (openat) __openat_nocancel; -/* Uncancelable close. */ -#define __close_nocancel(fd) \ - INLINE_SYSCALL (close, 1, fd) -#define close_not_cancel(fd) \ - __close_nocancel (fd) -#define close_not_cancel_no_status(fd) \ - (void) ({ INTERNAL_SYSCALL_DECL (err); \ - INTERNAL_SYSCALL (close, err, 1, (fd)); }) - -/* Uncancelable read. */ -#define read_not_cancel(fd, buf, n) \ - __read_nocancel (fd, buf, n) +/* Non cacellable openat syscall (LFS version). */ +__typeof (openat64) __openat64_nocancel; -/* Uncancelable write. */ -#define write_not_cancel(fd, buf, n) \ - __write_nocancel (fd, buf, n) +/* Non cancellable read syscall. */ +__typeof (__read) __read_nocancel; -/* Uncancelable writev. */ -#define writev_not_cancel_no_status(fd, iov, n) \ - (void) ({ INTERNAL_SYSCALL_DECL (err); \ - INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); }) +/* Uncancelable write. */ +__typeof (__write) __write_nocancel; -/* Uncancelable fcntl. */ -#define fcntl_not_cancel(fd, cmd, val) \ - __fcntl_nocancel (fd, cmd, val) +/* Uncancelable close. */ +__typeof (__close) __close_nocancel; + +/* Non cancellable close syscall that does not also set errno in case of + failure. */ +static inline void +__close_nocancel_nostatus (int fd) +{ + __close_nocancel (fd); +} + +/* Non cancellable writev syscall that does not also set errno in case of + failure. */ +static inline void +__writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt) +{ + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt); +} /* Uncancelable waitpid. */ -#define __waitpid_nocancel(pid, stat_loc, options) \ - INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) -#define waitpid_not_cancel(pid, stat_loc, options) \ - __waitpid_nocancel(pid, stat_loc, options) +__typeof (waitpid) __waitpid_nocancel; /* Uncancelable pause. */ -#define pause_not_cancel() \ - ({ sigset_t set; \ - int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \ - _NSIG / 8); \ - if (__rc == 0) \ - __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \ - __rc; \ - }) +__typeof (pause) __pause_nocancel; /* Uncancelable nanosleep. */ -#define nanosleep_not_cancel(requested_time, remaining) \ - INLINE_SYSCALL (nanosleep, 2, requested_time, remaining) +__typeof (__nanosleep) __nanosleep_nocancel; -/* Uncancelable sigsuspend. */ -#define sigsuspend_not_cancel(set) \ - INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8) +/* Uncancelable fcntl. */ +__typeof (__fcntl) __fcntl64_nocancel; + +#if IS_IN (libc) || IS_IN (rtld) +hidden_proto (__open_nocancel) +hidden_proto (__open64_nocancel) +hidden_proto (__openat_nocancel) +hidden_proto (__openat64_nocancel) +hidden_proto (__read_nocancel) +hidden_proto (__write_nocancel) +hidden_proto (__close_nocancel) +hidden_proto (__waitpid_nocancel) +hidden_proto (__pause_nocancel) +hidden_proto (__nanosleep_nocancel) +hidden_proto (__fcntl64_nocancel) +#endif #endif /* NOT_CANCEL_H */ |