40 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8//9// Generic implementations of internal_syscall* and internal_iserror.10//11//===----------------------------------------------------------------------===//12 13// NetBSD uses libc calls directly14#if !SANITIZER_NETBSD15 16#if SANITIZER_FREEBSD || SANITIZER_APPLE || SANITIZER_SOLARIS17# define SYSCALL(name) SYS_ ## name18#else19# define SYSCALL(name) __NR_ ## name20#endif21 22#if (defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_APPLE)) || \23 (defined(__aarch64__) && SANITIZER_FREEBSD)24# define internal_syscall __syscall25# else26# define internal_syscall syscall27#endif28 29#endif30 31bool 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