sanitizer_syscall_generic.inc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_MAC || 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_MAC)
  20. # define internal_syscall __syscall
  21. # else
  22. # define internal_syscall syscall
  23. #endif
  24. #endif
  25. bool internal_iserror(uptr retval, int *rverrno) {
  26. if (retval == (uptr)-1) {
  27. if (rverrno)
  28. *rverrno = errno;
  29. return true;
  30. } else {
  31. return false;
  32. }
  33. }