not-cancel.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Uncancelable versions of cancelable interfaces. Linux/NPTL 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. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include <sysdep.h>
  18. #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
  19. extern int __open_nocancel (const char *, int, ...) attribute_hidden;
  20. extern int __close_nocancel (int) attribute_hidden;
  21. extern int __read_nocancel (int, void *, size_t) attribute_hidden;
  22. extern int __write_nocancel (int, const void *, size_t) attribute_hidden;
  23. extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
  24. extern int __openat_nocancel (int fd, const char *fname, int oflag,
  25. mode_t mode) attribute_hidden;
  26. extern int __openat64_nocancel (int fd, const char *fname, int oflag,
  27. mode_t mode) attribute_hidden;
  28. #else
  29. # define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
  30. # define __close_nocancel(fd) __close (fd)
  31. # define __read_nocancel(fd, buf, len) __read (fd, buf, len)
  32. # define __write_nocancel(fd, buf, len) __write (fd, buf, len)
  33. # define __waitpid_nocancel(pid, stat_loc, options) \
  34. __waitpid (pid, stat_loc, options)
  35. # define __openat_nocancel(fd, fname, oflag, mode) \
  36. openat (fd, fname, oflag, mode)
  37. # define __openat64_nocancel(fd, fname, oflag, mode) \
  38. openat64 (fd, fname, oflag, mode)
  39. #endif
  40. /* Uncancelable open. */
  41. #define open_not_cancel(name, flags, mode) \
  42. __open_nocancel (name, flags, mode)
  43. #define open_not_cancel_2(name, flags) \
  44. __open_nocancel (name, flags)
  45. /* Uncancelable openat. */
  46. #define openat_not_cancel(fd, fname, oflag, mode) \
  47. __openat_nocancel (fd, fname, oflag, mode)
  48. #define openat_not_cancel_3(fd, fname, oflag) \
  49. __openat_nocancel (fd, fname, oflag, 0)
  50. #define openat64_not_cancel(fd, fname, oflag, mode) \
  51. __openat64_nocancel (fd, fname, oflag, mode)
  52. #define openat64_not_cancel_3(fd, fname, oflag) \
  53. __openat64_nocancel (fd, fname, oflag, 0)
  54. /* Uncancelable close. */
  55. #define close_not_cancel(fd) \
  56. __close_nocancel (fd)
  57. #define close_not_cancel_no_status(fd) \
  58. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  59. INTERNAL_SYSCALL (close, err, 1, (fd)); })
  60. /* Uncancelable read. */
  61. #define read_not_cancel(fd, buf, n) \
  62. __read_nocancel (fd, buf, n)
  63. /* Uncancelable write. */
  64. #define write_not_cancel(fd, buf, n) \
  65. __write_nocancel (fd, buf, n)
  66. /* Uncancelable writev. */
  67. #define writev_not_cancel_no_status(fd, iov, n) \
  68. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  69. INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
  70. /* Uncancelable fcntl. */
  71. #define fcntl_not_cancel(fd, cmd, val) \
  72. __fcntl_nocancel (fd, cmd, val)
  73. /* Uncancelable waitpid. */
  74. #ifdef __NR_waitpid
  75. # define waitpid_not_cancel(pid, stat_loc, options) \
  76. __waitpid_nocancel (pid, stat_loc, options)
  77. #else
  78. # define waitpid_not_cancel(pid, stat_loc, options) \
  79. INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
  80. #endif
  81. /* Uncancelable pause. */
  82. #define pause_not_cancel() \
  83. __pause_nocancel ()
  84. /* Uncancelable nanosleep. */
  85. #define nanosleep_not_cancel(requested_time, remaining) \
  86. __nanosleep_nocancel (requested_time, remaining)
  87. /* Uncancelable sigsuspend. */
  88. #define sigsuspend_not_cancel(set) \
  89. __sigsuspend_nocancel (set)