Back to index

glibc  2.9
not-cancel.h
Go to the documentation of this file.
00001 /* Uncancelable versions of cancelable interfaces.  Linux version.
00002    Copyright (C) 2003, 2006 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <sys/types.h>
00022 #include <sysdep.h>
00023 
00024 /* Uncancelable open.  */
00025 #define open_not_cancel(name, flags, mode) \
00026    INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
00027 #define open_not_cancel_2(name, flags) \
00028    INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
00029 
00030 /* Uncancelable openat.  */
00031 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
00032 extern int __openat_nocancel (int fd, const char *fname, int oflag,
00033                            mode_t mode) attribute_hidden;
00034 extern int __openat64_nocancel (int fd, const char *fname, int oflag,
00035                             mode_t mode) attribute_hidden;
00036 #else
00037 # define __openat_nocancel(fd, fname, oflag, mode) \
00038   openat (fd, fname, oflag, mode)
00039 # define __openat64_nocancel(fd, fname, oflag, mode) \
00040   openat64 (fd, fname, oflag, mode)
00041 #endif
00042 
00043 #define openat_not_cancel(fd, fname, oflag, mode) \
00044   __openat_nocancel (fd, fname, oflag, mode)
00045 #define openat_not_cancel_3(fd, fname, oflag) \
00046   __openat_nocancel (fd, fname, oflag, 0)
00047 #define openat64_not_cancel(fd, fname, oflag, mode) \
00048   __openat64_nocancel (fd, fname, oflag, mode)
00049 #define openat64_not_cancel_3(fd, fname, oflag) \
00050   __openat64_nocancel (fd, fname, oflag, 0)
00051 
00052 /* Uncancelable close.  */
00053 #define close_not_cancel(fd) \
00054   INLINE_SYSCALL (close, 1, fd)
00055 #define close_not_cancel_no_status(fd) \
00056   (void) ({ INTERNAL_SYSCALL_DECL (err);                             \
00057            INTERNAL_SYSCALL (close, err, 1, (fd)); })
00058 
00059 /* Uncancelable read.  */
00060 #define read_not_cancel(fd, buf, n) \
00061   INLINE_SYSCALL (read, 3, (fd), (buf), (n))
00062 
00063 /* Uncancelable write.  */
00064 #define write_not_cancel(fd, buf, n) \
00065   INLINE_SYSCALL (write, 3, (fd), (buf), (n))
00066 
00067 /* Uncancelable writev.  */
00068 #define writev_not_cancel_no_status(fd, iov, n) \
00069   (void) ({ INTERNAL_SYSCALL_DECL (err);                             \
00070            INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
00071 
00072 /* Uncancelable fcntl.  */
00073 #define fcntl_not_cancel(fd, cmd, val) \
00074   __fcntl_nocancel (fd, cmd, val)
00075 
00076 /* Uncancelable waitpid.  */
00077 #ifdef __NR_waitpid
00078 # define waitpid_not_cancel(pid, stat_loc, options) \
00079   INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
00080 #else
00081 # define waitpid_not_cancel(pid, stat_loc, options) \
00082   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
00083 #endif
00084 
00085 /* Uncancelable pause.  */
00086 #ifdef __NR_pause
00087 # define pause_not_cancel() \
00088   INLINE_SYSCALL (pause, 0)
00089 #else
00090 # define pause_not_cancel() \
00091   __pause_nocancel ()
00092 #endif
00093 
00094 /* Uncancelable nanosleep.  */
00095 #ifdef __NR_nanosleep
00096 # define nanosleep_not_cancel(requested_time, remaining) \
00097   INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
00098 #else
00099 # define nanosleep_not_cancel(requested_time, remaining) \
00100   __nanosleep_nocancel (requested_time, remaining)
00101 #endif
00102 
00103 /* Uncancelable sigsuspend.  */
00104 #define sigsuspend_not_cancel(set) \
00105   __sigsuspend_nocancel (set)