not-cancel.h 4.4 KB

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