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