2013-05-08 22:43:49 +08:00
|
|
|
//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Generic implementations of internal_syscall and internal_iserror.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-02-23 06:01:09 +08:00
|
|
|
#if SANITIZER_FREEBSD || SANITIZER_MAC
|
2014-03-07 18:03:54 +08:00
|
|
|
# define SYSCALL(name) SYS_ ## name
|
|
|
|
#else
|
|
|
|
# define SYSCALL(name) __NR_ ## name
|
|
|
|
#endif
|
|
|
|
|
2015-02-23 06:01:09 +08:00
|
|
|
#if (SANITIZER_FREEBSD || SANITIZER_MAC) && defined(__x86_64__)
|
2014-03-07 18:03:54 +08:00
|
|
|
# define internal_syscall __syscall
|
|
|
|
# else
|
|
|
|
# define internal_syscall syscall
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|