epoll.h: Add epoll ioctls
[uclibc-ng.git] / libc / sysdeps / linux / common / not-cancel.h
blob426edcc46d45d6465e251e903f090d5a5c65f05c
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, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sys/types.h>
21 #include <sysdep.h>
22 #include <time.h>
24 #ifdef NOT_IN_libc
26 /* Uncancelable open. */
27 #if defined __NR_openat && !defined __NR_open
28 #define open_not_cancel(name, flags, mode) \
29 INLINE_SYSCALL (openat, 4, AT_FDCWD, (const char *) (name), (flags), (mode))
30 #define open_not_cancel_2(name, flags) \
31 INLINE_SYSCALL (openat, 3, AT_FDCWD, (const char *) (name), (flags))
32 #else
33 #define open_not_cancel(name, flags, mode) \
34 INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
35 #define open_not_cancel_2(name, flags) \
36 INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
37 #endif
39 #if 0
40 /* Uncancelable openat. */
41 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
42 extern int __openat_nocancel (int fd, const char *fname, int oflag,
43 mode_t mode) attribute_hidden;
44 extern int __openat64_nocancel (int fd, const char *fname, int oflag,
45 mode_t mode) attribute_hidden;
46 #else
47 # define __openat_nocancel(fd, fname, oflag, mode) \
48 openat (fd, fname, oflag, mode)
49 # define __openat64_nocancel(fd, fname, oflag, mode) \
50 openat64 (fd, fname, oflag, mode)
51 #endif
53 #define openat_not_cancel(fd, fname, oflag, mode) \
54 __openat_nocancel (fd, fname, oflag, mode)
55 #define openat_not_cancel_3(fd, fname, oflag) \
56 __openat_nocancel (fd, fname, oflag, 0)
57 #define openat64_not_cancel(fd, fname, oflag, mode) \
58 __openat64_nocancel (fd, fname, oflag, mode)
59 #define openat64_not_cancel_3(fd, fname, oflag) \
60 __openat64_nocancel (fd, fname, oflag, 0)
61 #endif
63 /* Uncancelable close. */
64 #define close_not_cancel(fd) \
65 INLINE_SYSCALL (close, 1, fd)
66 #define close_not_cancel_no_status(fd) \
67 (void) ({ INTERNAL_SYSCALL_DECL (err); \
68 INTERNAL_SYSCALL (close, err, 1, (fd)); })
70 /* Uncancelable read. */
71 #define read_not_cancel(fd, buf, n) \
72 INLINE_SYSCALL (read, 3, (fd), (buf), (n))
74 #ifdef __UCLIBC_HAS_THREADS__
75 /* Uncancelable write. */
76 #define write_not_cancel(fd, buf, n) \
77 INLINE_SYSCALL (write, 3, (fd), (buf), (n))
78 #endif
80 #if 0
81 /* Uncancelable writev. */
82 #define writev_not_cancel_no_status(fd, iov, n) \
83 (void) ({ INTERNAL_SYSCALL_DECL (err); \
84 INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
86 /* Uncancelable fcntl. */
87 #define fcntl_not_cancel(fd, cmd, val) \
88 __fcntl_nocancel (fd, cmd, val)
89 #endif
91 #ifdef __UCLIBC_HAS_LINUXTHREADS__
92 /* Uncancelable waitpid. */
93 #if 0 /*def __NR_waitpid*/
94 # define waitpid_not_cancel(pid, stat_loc, options) \
95 INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
96 #else
97 # define waitpid_not_cancel(pid, stat_loc, options) \
98 INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
99 #endif
100 #endif
102 /* Uncancelable pause. */
103 #ifdef __NR_pause
104 # define pause_not_cancel() \
105 INLINE_SYSCALL (pause, 0)
106 #else
107 # include <unistd.h>
108 extern __typeof(pause) __pause_nocancel;
109 # define pause_not_cancel() \
110 __pause_nocancel ()
111 #endif
113 /* Uncancelable nanosleep. */
114 #ifdef __NR_nanosleep
115 # define nanosleep_not_cancel(requested_time, remaining) \
116 INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
117 #else
118 extern int __nanosleep_nocancel (const struct timespec *requested_time, struct timespec *remaining);
119 # define nanosleep_not_cancel(requested_time, remaining) \
120 __nanosleep_nocancel (requested_time, remaining)
121 #endif
123 #if 0
124 /* Uncancelable sigsuspend. */
125 #define sigsuspend_not_cancel(set) \
126 __sigsuspend_nocancel (set)
127 #endif
129 #elif !defined NOT_IN_libc
131 #include <cancel.h>
132 #include <fcntl.h>
133 #include <unistd.h>
135 #define open_not_cancel(name, flags, mode) \
136 __NC(open)(name, flags, mode)
137 #define open_not_cancel_2(name, flags) \
138 __NC(open2)(name, flags)
140 #define close_not_cancel(fd) \
141 __NC(close)(fd)
142 #define close_not_cancel_no_status(fd) \
143 __close_nocancel_no_status(fd)
145 #define read_not_cancel(fd, buf, n) \
146 __NC(read)(fd, buf, n)
148 #define write_not_cancel(fd, buf, n) \
149 __NC(write)(fd, buf, n)
151 #define fcntl_not_cancel(fd, cmd, val) \
152 __NC(fcntl)(fd, cmd, val)
154 #endif