sanitizer_syscall_generic.inc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // Generic implementations of internal_syscall* and internal_iserror.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // NetBSD uses libc calls directly
  13. #if !SANITIZER_NETBSD
  14. #if SANITIZER_FREEBSD || SANITIZER_APPLE || SANITIZER_SOLARIS
  15. # define SYSCALL(name) SYS_ ## name
  16. #else
  17. # define SYSCALL(name) __NR_ ## name
  18. #endif
  19. #if (defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_APPLE)) || \
  20. (defined(__aarch64__) && SANITIZER_FREEBSD)
  21. # define internal_syscall __syscall
  22. # else
  23. # define internal_syscall syscall
  24. #endif
  25. #endif
  26. bool internal_iserror(uptr retval, int *rverrno) {
  27. if (retval == (uptr)-1) {
  28. if (rverrno)
  29. *rverrno = errno;
  30. return true;
  31. } else {
  32. return false;
  33. }
  34. }