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#if SANITIZER_FREEBSD
15# define SYSCALL(name) SYS_ ## name
16#else
17# define SYSCALL(name) __NR_ ## name
18#endif
19
20#if SANITIZER_FREEBSD && defined(__x86_64__)
21# define internal_syscall __syscall
22# else
23# define internal_syscall syscall
24#endif
25
26bool internal_iserror(uptr retval, int *rverrno) {
27  if (retval == (uptr)-1) {
28    if (rverrno)
29      *rverrno = errno;
30    return true;
31  } else {
32    return false;
33  }
34}
35