]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc
Libsanitizer: merge from trunk with merge.sh.
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_syscall_generic.inc
CommitLineData
ef1b3fda
KS
1//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
2//
b667dd70
ML
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-exception
ef1b3fda
KS
6//
7//===----------------------------------------------------------------------===//
8//
5d3805fc 9// Generic implementations of internal_syscall* and internal_iserror.
ef1b3fda
KS
10//
11//===----------------------------------------------------------------------===//
12
eac97531
ML
13// NetBSD uses libc calls directly
14#if !SANITIZER_NETBSD
15
16#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_SOLARIS
dee5ea7a
KS
17# define SYSCALL(name) SYS_ ## name
18#else
19# define SYSCALL(name) __NR_ ## name
20#endif
21
eac97531 22#if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
dee5ea7a
KS
23# define internal_syscall __syscall
24# else
25# define internal_syscall syscall
26#endif
ef1b3fda 27
eac97531
ML
28#endif
29
ef1b3fda
KS
30bool internal_iserror(uptr retval, int *rverrno) {
31 if (retval == (uptr)-1) {
32 if (rverrno)
33 *rverrno = errno;
34 return true;
35 } else {
36 return false;
37 }
38}