not-cancel.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Uncancelable versions of cancelable interfaces. Linux/NPTL version.
  2. Copyright (C) 2003 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. libc_hidden_proto(__open_nocancel)
  25. libc_hidden_proto(__close_nocancel)
  26. libc_hidden_proto(__read_nocancel)
  27. libc_hidden_proto(__write_nocancel)
  28. libc_hidden_proto(__waitpid_nocancel)
  29. #else
  30. #define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
  31. #define __close_nocancel(fd) __close (fd)
  32. #define __read_nocancel(fd, buf, len) __read (fd, buf, len)
  33. #define __write_nocancel(fd, buf, len) __write (fd, buf, len)
  34. #define __waitpid_nocancel(pid, stat_loc, options) \
  35. __waitpid (pid, stat_loc, options)
  36. #endif
  37. /* Uncancelable open. */
  38. #define open_not_cancel(name, flags, mode) \
  39. __open_nocancel (name, flags, mode)
  40. #define open_not_cancel_2(name, flags) \
  41. __open_nocancel (name, flags)
  42. /* Uncancelable close. */
  43. #define close_not_cancel(fd) \
  44. __close_nocancel (fd)
  45. #define close_not_cancel_no_status(fd) \
  46. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  47. INTERNAL_SYSCALL (close, err, 1, (fd)); })
  48. /* Uncancelable read. */
  49. #define read_not_cancel(fd, buf, n) \
  50. __read_nocancel (fd, buf, n)
  51. /* Uncancelable write. */
  52. #define write_not_cancel(fd, buf, n) \
  53. __write_nocancel (fd, buf, n)
  54. /* Uncancelable writev. */
  55. #define writev_not_cancel_no_status(fd, iov, n) \
  56. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  57. INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
  58. /* Uncancelable fcntl. */
  59. #define fcntl_not_cancel(fd, cmd, val) \
  60. __fcntl_nocancel (fd, cmd, val)
  61. /* Uncancelable waitpid. */
  62. #ifdef __NR_waitpid
  63. # define waitpid_not_cancel(pid, stat_loc, options) \
  64. __waitpid_nocancel (pid, stat_loc, options)
  65. #else
  66. # define waitpid_not_cancel(pid, stat_loc, options) \
  67. INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
  68. #endif