sanitizer_syscall_generic.inc 850 B

123456789101112131415161718192021222324252627282930313233
  1. //===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // Generic implementations of internal_syscall and internal_iserror.
  9. //
  10. //===----------------------------------------------------------------------===//
  11. #if SANITIZER_FREEBSD
  12. # define SYSCALL(name) SYS_ ## name
  13. #else
  14. # define SYSCALL(name) __NR_ ## name
  15. #endif
  16. #if SANITIZER_FREEBSD && defined(__x86_64__)
  17. # define internal_syscall __syscall
  18. # else
  19. # define internal_syscall syscall
  20. #endif
  21. bool internal_iserror(uptr retval, int *rverrno) {
  22. if (retval == (uptr)-1) {
  23. if (rverrno)
  24. *rverrno = errno;
  25. return true;
  26. } else {
  27. return false;
  28. }
  29. }