]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / nptl / sysdeps / unix / sysv / linux / not-cancel.h
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.
5
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.
10
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.
15
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/>.  */
19
20 #include <sys/types.h>
21 #include <sysdep.h>
22
23 /* Uncancelable open.  */
24 #if defined __NR_openat && !defined __NR_open
25 #define open_not_cancel(name, flags, mode) \
26         INLINE_SYSCALL (openat, 4, AT_FDCWD, (const char *) (name), \
27                 (flags), (mode))
28 #define open_not_cancel_2(name, flags) \
29         INLINE_SYSCALL (openat, 3, AT_FDCWD, (const char *) (name), \
30                 (flags))
31 #else
32 #define open_not_cancel(name, flags, mode) \
33    INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
34 #define open_not_cancel_2(name, flags) \
35    INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
36 #endif
37
38 /* Uncancelable openat.  */
39 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
40 extern int __openat_nocancel (int fd, const char *fname, int oflag,
41                               mode_t mode) attribute_hidden;
42 extern int __openat64_nocancel (int fd, const char *fname, int oflag,
43                                 mode_t mode) attribute_hidden;
44 #else
45 # define __openat_nocancel(fd, fname, oflag, mode) \
46   openat (fd, fname, oflag, mode)
47 # define __openat64_nocancel(fd, fname, oflag, mode) \
48   openat64 (fd, fname, oflag, mode)
49 #endif
50
51 #define openat_not_cancel(fd, fname, oflag, mode) \
52   __openat_nocancel (fd, fname, oflag, mode)
53 #define openat_not_cancel_3(fd, fname, oflag) \
54   __openat_nocancel (fd, fname, oflag, 0)
55 #define openat64_not_cancel(fd, fname, oflag, mode) \
56   __openat64_nocancel (fd, fname, oflag, mode)
57 #define openat64_not_cancel_3(fd, fname, oflag) \
58   __openat64_nocancel (fd, fname, oflag, 0)
59
60 /* Uncancelable close.  */
61 #define close_not_cancel(fd) \
62   INLINE_SYSCALL (close, 1, fd)
63 #define close_not_cancel_no_status(fd) \
64   (void) ({ INTERNAL_SYSCALL_DECL (err);                                      \
65             INTERNAL_SYSCALL (close, err, 1, (fd)); })
66
67 /* Uncancelable read.  */
68 #define read_not_cancel(fd, buf, n) \
69   INLINE_SYSCALL (read, 3, (fd), (buf), (n))
70
71 /* Uncancelable write.  */
72 #define write_not_cancel(fd, buf, n) \
73   INLINE_SYSCALL (write, 3, (fd), (buf), (n))
74
75 /* Uncancelable writev.  */
76 #define writev_not_cancel_no_status(fd, iov, n) \
77   (void) ({ INTERNAL_SYSCALL_DECL (err);                                      \
78             INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
79
80 /* Uncancelable fcntl.  */
81 #define fcntl_not_cancel(fd, cmd, val) \
82   __fcntl_nocancel (fd, cmd, val)
83
84 /* Uncancelable waitpid.  */
85 #ifdef __NR_waitpid
86 # define waitpid_not_cancel(pid, stat_loc, options) \
87   INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
88 #else
89 # define waitpid_not_cancel(pid, stat_loc, options) \
90   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
91 #endif
92
93 /* Uncancelable pause.  */
94 #ifdef __NR_pause
95 # define pause_not_cancel() \
96   INLINE_SYSCALL (pause, 0)
97 #else
98 # define pause_not_cancel() \
99   __pause_nocancel ()
100 #endif
101
102 /* Uncancelable nanosleep.  */
103 #ifdef __NR_nanosleep
104 # define nanosleep_not_cancel(requested_time, remaining) \
105   INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
106 #else
107 # define nanosleep_not_cancel(requested_time, remaining) \
108   __nanosleep_nocancel (requested_time, remaining)
109 #endif
110
111 /* Uncancelable sigsuspend.  */
112 #define sigsuspend_not_cancel(set) \
113   __sigsuspend_nocancel (set)