2013-05-08 22:43:49 +08:00
|
|
|
//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-05-08 22:43:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2017-08-05 06:23:52 +08:00
|
|
|
// Generic implementations of internal_syscall* and internal_iserror.
|
2013-05-08 22:43:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-10-09 02:04:46 +08:00
|
|
|
// NetBSD uses libc calls directly
|
|
|
|
#if !SANITIZER_NETBSD
|
|
|
|
|
|
|
|
#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_SOLARIS
|
2014-03-07 18:03:54 +08:00
|
|
|
# define SYSCALL(name) SYS_ ## name
|
|
|
|
#else
|
|
|
|
# define SYSCALL(name) __NR_ ## name
|
|
|
|
#endif
|
|
|
|
|
2018-10-09 02:04:46 +08:00
|
|
|
#if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
|
2014-03-07 18:03:54 +08:00
|
|
|
# define internal_syscall __syscall
|
|
|
|
# else
|
|
|
|
# define internal_syscall syscall
|
2018-10-09 02:04:46 +08:00
|
|
|
#endif
|
|
|
|
|
2014-03-07 18:03:54 +08:00
|
|
|
#endif
|
2013-05-08 22:43:49 +08:00
|
|
|
|
|
|
|
bool internal_iserror(uptr retval, int *rverrno) {
|
|
|
|
if (retval == (uptr)-1) {
|
|
|
|
if (rverrno)
|
|
|
|
*rverrno = errno;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|