1 //===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // Generic implementations of internal_syscall* and internal_iserror.
10 //===----------------------------------------------------------------------===//
12 #if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
13 # define SYSCALL(name) SYS_ ## name
15 # define SYSCALL(name) __NR_ ## name
19 // We use 3 kinds of internal_syscall's for different types of retval in order
20 // to address differences in calling conventions (e.g. registers to place the
22 // - internal_syscall for 32-bit length (int, pid_t)
23 // - internal_syscall64 for 64-bit length (off_t)
24 // - internal_syscall_ptr for pointer and (s)size_t
25 # define internal_syscall syscall
26 # define internal_syscall64 __syscall
27 // Handle syscall renames manually
28 # define SYS_stat SYS___stat50
29 # define SYS_lstat SYS___lstat50
30 # define SYS_fstat SYS___fstat50
31 # define SYS_gettimeofday SYS___gettimeofday50
32 # define SYS_wait4 SYS___wait450
33 # define SYS_getdents SYS___getdents30
34 # define SYS_sigaltstack SYS___sigaltstack14
35 # define SYS_sigprocmask SYS___sigprocmask14
36 # define SYS_nanosleep SYS___nanosleep50
37 # if SANITIZER_WORDSIZE == 64
38 # define internal_syscall_ptr __syscall
40 # define internal_syscall_ptr syscall
42 #elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
43 # define internal_syscall __syscall
45 # define internal_syscall syscall
48 bool internal_iserror(uptr retval, int *rverrno) {
49 if (retval == (uptr)-1) {