1 //===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // Generic implementations of internal_syscall* and internal_iserror. 11 // 12 //===----------------------------------------------------------------------===// 13 14 // NetBSD uses libc calls directly 15 #if !SANITIZER_NETBSD 16 17 #if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_SOLARIS 18 # define SYSCALL(name) SYS_ ## name 19 #else 20 # define SYSCALL(name) __NR_ ## name 21 #endif 22 23 #if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC) 24 # define internal_syscall __syscall 25 # else 26 # define internal_syscall syscall 27 #endif 28 29 #endif 30 31 bool internal_iserror(uptr retval, int *rverrno) { 32 if (retval == (uptr)-1) { 33 if (rverrno) 34 *rverrno = errno; 35 return true; 36 } else { 37 return false; 38 } 39 } 40