not-errno.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Syscall wrapper that do not set errno. Linux version.
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <fcntl.h>
  17. /* This function is used on maybe_enable_malloc_check (elf/dl-tunables.c)
  18. and to avoid having to build/use multiple versions if stack protection
  19. in enabled it is defined as inline. */
  20. static inline int
  21. __access_noerrno (const char *pathname, int mode)
  22. {
  23. int res;
  24. INTERNAL_SYSCALL_DECL (err);
  25. #ifdef __NR_access
  26. res = INTERNAL_SYSCALL_CALL (access, err, pathname, mode);
  27. #else
  28. res = INTERNAL_SYSCALL_CALL (faccessat, err, AT_FDCWD, pathname, mode);
  29. #endif
  30. if (INTERNAL_SYSCALL_ERROR_P (res, err))
  31. return INTERNAL_SYSCALL_ERRNO (res, err);
  32. return 0;
  33. }
  34. static inline int
  35. __kill_noerrno (pid_t pid, int sig)
  36. {
  37. int res;
  38. INTERNAL_SYSCALL_DECL (err);
  39. res = INTERNAL_SYSCALL_CALL (kill, err, pid, sig);
  40. if (INTERNAL_SYSCALL_ERROR_P (res, err))
  41. return INTERNAL_SYSCALL_ERRNO (res, err);
  42. return 0;
  43. }