2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / not-cancel.h
blob80d33be29c701702a3182337d9e19b8883ac5e80
1 /* Uncancelable versions of cancelable interfaces. Linux version.
2 Copyright (C) 2003, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <sys/types.h>
22 #include <sysdep.h>
24 /* Uncancelable open. */
25 #define open_not_cancel(name, flags, mode) \
26 INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
27 #define open_not_cancel_2(name, flags) \
28 INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
30 /* Uncancelable openat. */
31 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
32 extern int __openat_nocancel (int fd, const char *fname, int oflag,
33 mode_t mode) attribute_hidden;
34 extern int __openat64_nocancel (int fd, const char *fname, int oflag,
35 mode_t mode) attribute_hidden;
36 #else
37 # define __openat_nocancel(fd, fname, oflag, mode) \
38 openat (fd, fname, oflag, mode)
39 # define __openat64_nocancel(fd, fname, oflag, mode) \
40 openat64 (fd, fname, oflag, mode)
41 #endif
43 #define openat_not_cancel(fd, fname, oflag, mode) \
44 __openat_nocancel (fd, fname, oflag, mode)
45 #define openat_not_cancel_3(fd, fname, oflag) \
46 __openat_nocancel (fd, fname, oflag, 0)
47 #define openat64_not_cancel(fd, fname, oflag, mode) \
48 __openat64_nocancel (fd, fname, oflag, mode)
49 #define openat64_not_cancel_3(fd, fname, oflag) \
50 __openat64_nocancel (fd, fname, oflag, 0)
52 /* Uncancelable close. */
53 #define close_not_cancel(fd) \
54 INLINE_SYSCALL (close, 1, fd)
55 #define close_not_cancel_no_status(fd) \
56 (void) ({ INTERNAL_SYSCALL_DECL (err); \
57 INTERNAL_SYSCALL (close, err, 1, (fd)); })
59 /* Uncancelable read. */
60 #define read_not_cancel(fd, buf, n) \
61 INLINE_SYSCALL (read, 3, (fd), (buf), (n))
63 /* Uncancelable write. */
64 #define write_not_cancel(fd, buf, n) \
65 INLINE_SYSCALL (write, 3, (fd), (buf), (n))
67 /* Uncancelable writev. */
68 #define writev_not_cancel_no_status(fd, iov, n) \
69 (void) ({ INTERNAL_SYSCALL_DECL (err); \
70 INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
72 /* Uncancelable fcntl. */
73 #define fcntl_not_cancel(fd, cmd, val) \
74 __fcntl_nocancel (fd, cmd, val)
76 /* Uncancelable waitpid. */
77 #ifdef __NR_waitpid
78 # define waitpid_not_cancel(pid, stat_loc, options) \
79 INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
80 #else
81 # define waitpid_not_cancel(pid, stat_loc, options) \
82 INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
83 #endif
85 /* Uncancelable pause. */
86 #ifdef __NR_pause
87 # define pause_not_cancel() \
88 INLINE_SYSCALL (pause, 0)
89 #else
90 # define pause_not_cancel() \
91 __pause_nocancel ()
92 #endif
94 /* Uncancelable nanosleep. */
95 #ifdef __NR_nanosleep
96 # define nanosleep_not_cancel(requested_time, remaining) \
97 INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
98 #else
99 # define nanosleep_not_cancel(requested_time, remaining) \
100 __nanosleep_nocancel (requested_time, remaining)
101 #endif
103 /* Uncancelable sigsuspend. */
104 #define sigsuspend_not_cancel(set) \
105 __sigsuspend_nocancel (set)