not-cancel.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Uncancelable versions of cancelable interfaces. Linux 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 <sys/syscall.h>
  18. #undef INLINE_SYSCALL
  19. #define INLINE_SYSCALL(func, numargs, args...) syscall(__NR_ ## func, args)
  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. /* Uncancelable close. */
  26. #define close_not_cancel(fd) \
  27. INLINE_SYSCALL (close, 1, fd)
  28. #define close_not_cancel_no_status(fd) \
  29. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  30. INTERNAL_SYSCALL (close, err, 1, (fd)); })
  31. /* Uncancelable read. */
  32. #define read_not_cancel(fd, buf, n) \
  33. INLINE_SYSCALL (read, 3, (fd), (buf), (n))
  34. /* Uncancelable write. */
  35. #define write_not_cancel(fd, buf, n) \
  36. INLINE_SYSCALL (write, 3, (fd), (buf), (n))
  37. /* Uncancelable writev. */
  38. #define writev_not_cancel_no_status(fd, iov, n) \
  39. (void) ({ INTERNAL_SYSCALL_DECL (err); \
  40. INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
  41. /* Uncancelable fcntl. */
  42. #define fcntl_not_cancel(fd, cmd, val) \
  43. __fcntl_nocancel (fd, cmd, val)
  44. /* Uncancelable waitpid. */
  45. #ifdef __NR_waitpid
  46. # define waitpid_not_cancel(pid, stat_loc, options) \
  47. INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
  48. #else
  49. # define waitpid_not_cancel(pid, stat_loc, options) \
  50. INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
  51. #endif