not-cancel.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Uncancelable versions of cancelable interfaces. Linux/NPTL version.
  2. Copyright (C) 2003-2019 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, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef NOT_CANCEL_H
  17. # define NOT_CANCEL_H
  18. #include <fcntl.h>
  19. #include <sysdep.h>
  20. #include <errno.h>
  21. #include <unistd.h>
  22. #include <sys/syscall.h>
  23. #include <sys/wait.h>
  24. #include <time.h>
  25. /* Non cancellable open syscall. */
  26. __typeof (open) __open_nocancel;
  27. /* Non cancellable open syscall (LFS version). */
  28. __typeof (open64) __open64_nocancel;
  29. /* Non cancellable openat syscall. */
  30. __typeof (openat) __openat_nocancel;
  31. /* Non cacellable openat syscall (LFS version). */
  32. __typeof (openat64) __openat64_nocancel;
  33. /* Non cancellable read syscall. */
  34. __typeof (__read) __read_nocancel;
  35. /* Uncancelable write. */
  36. __typeof (__write) __write_nocancel;
  37. /* Uncancelable close. */
  38. __typeof (__close) __close_nocancel;
  39. /* Non cancellable close syscall that does not also set errno in case of
  40. failure. */
  41. static inline void
  42. __close_nocancel_nostatus (int fd)
  43. {
  44. __close_nocancel (fd);
  45. }
  46. /* Non cancellable writev syscall that does not also set errno in case of
  47. failure. */
  48. static inline void
  49. __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
  50. {
  51. INTERNAL_SYSCALL_DECL (err);
  52. INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);
  53. }
  54. /* Uncancelable waitpid. */
  55. __typeof (waitpid) __waitpid_nocancel;
  56. /* Uncancelable pause. */
  57. __typeof (pause) __pause_nocancel;
  58. /* Uncancelable nanosleep. */
  59. __typeof (__nanosleep) __nanosleep_nocancel;
  60. /* Uncancelable fcntl. */
  61. __typeof (__fcntl) __fcntl64_nocancel;
  62. #if IS_IN (libc) || IS_IN (rtld)
  63. hidden_proto (__open_nocancel)
  64. hidden_proto (__open64_nocancel)
  65. hidden_proto (__openat_nocancel)
  66. hidden_proto (__openat64_nocancel)
  67. hidden_proto (__read_nocancel)
  68. hidden_proto (__write_nocancel)
  69. hidden_proto (__close_nocancel)
  70. hidden_proto (__waitpid_nocancel)
  71. hidden_proto (__pause_nocancel)
  72. hidden_proto (__nanosleep_nocancel)
  73. hidden_proto (__fcntl64_nocancel)
  74. #endif
  75. #endif /* NOT_CANCEL_H */