Back to index

glibc  2.9
not-cancel.h
Go to the documentation of this file.
00001 /* Uncancelable versions of cancelable interfaces.  Linux/NPTL 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 <sysdep.h>
00022 
00023 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
00024 extern int __open_nocancel (const char *, int, ...) attribute_hidden;
00025 extern int __close_nocancel (int) attribute_hidden;
00026 extern int __read_nocancel (int, void *, size_t) attribute_hidden;
00027 extern int __write_nocancel (int, const void *, size_t) attribute_hidden;
00028 extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
00029 extern int __openat_nocancel (int fd, const char *fname, int oflag,
00030                             mode_t mode) attribute_hidden;
00031 extern int __openat64_nocancel (int fd, const char *fname, int oflag,
00032                               mode_t mode) attribute_hidden;
00033 #else
00034 # define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
00035 # define __close_nocancel(fd) __close (fd)
00036 # define __read_nocancel(fd, buf, len) __read (fd, buf, len)
00037 # define __write_nocancel(fd, buf, len) __write (fd, buf, len)
00038 # define __waitpid_nocancel(pid, stat_loc, options) \
00039   __waitpid (pid, stat_loc, options)
00040 # define __openat_nocancel(fd, fname, oflag, mode) \
00041   openat (fd, fname, oflag, mode)
00042 # define __openat64_nocancel(fd, fname, oflag, mode) \
00043   openat64 (fd, fname, oflag, mode)
00044 #endif
00045 
00046 /* Uncancelable open.  */
00047 #define open_not_cancel(name, flags, mode) \
00048    __open_nocancel (name, flags, mode)
00049 #define open_not_cancel_2(name, flags) \
00050    __open_nocancel (name, flags)
00051 
00052 /* Uncancelable openat.  */
00053 #define openat_not_cancel(fd, fname, oflag, mode) \
00054   __openat_nocancel (fd, fname, oflag, mode)
00055 #define openat_not_cancel_3(fd, fname, oflag) \
00056   __openat_nocancel (fd, fname, oflag, 0)
00057 #define openat64_not_cancel(fd, fname, oflag, mode) \
00058   __openat64_nocancel (fd, fname, oflag, mode)
00059 #define openat64_not_cancel_3(fd, fname, oflag) \
00060   __openat64_nocancel (fd, fname, oflag, 0)
00061 
00062 /* Uncancelable close.  */
00063 #define close_not_cancel(fd) \
00064   __close_nocancel (fd)
00065 #define close_not_cancel_no_status(fd) \
00066   (void) ({ INTERNAL_SYSCALL_DECL (err);                             \
00067            INTERNAL_SYSCALL (close, err, 1, (fd)); })
00068 
00069 /* Uncancelable read.  */
00070 #define read_not_cancel(fd, buf, n) \
00071   __read_nocancel (fd, buf, n)
00072 
00073 /* Uncancelable write.  */
00074 #define write_not_cancel(fd, buf, n) \
00075   __write_nocancel (fd, buf, n)
00076 
00077 /* Uncancelable writev.  */
00078 #define writev_not_cancel_no_status(fd, iov, n) \
00079   (void) ({ INTERNAL_SYSCALL_DECL (err);                             \
00080            INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
00081 
00082 /* Uncancelable fcntl.  */
00083 #define fcntl_not_cancel(fd, cmd, val) \
00084   __fcntl_nocancel (fd, cmd, val)
00085 
00086 /* Uncancelable waitpid.  */
00087 #ifdef __NR_waitpid
00088 # define waitpid_not_cancel(pid, stat_loc, options) \
00089   __waitpid_nocancel (pid, stat_loc, options)
00090 #else
00091 # define waitpid_not_cancel(pid, stat_loc, options) \
00092   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
00093 #endif
00094 
00095 /* Uncancelable pause.  */
00096 #define pause_not_cancel() \
00097   __pause_nocancel ()
00098 
00099 /* Uncancelable nanosleep.  */
00100 #define nanosleep_not_cancel(requested_time, remaining) \
00101   __nanosleep_nocancel (requested_time, remaining)
00102 
00103 /* Uncancelable sigsuspend.  */
00104 #define sigsuspend_not_cancel(set) \
00105   __sigsuspend_nocancel (set)