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 || \
15 SANITIZER_OPENBSD || SANITIZER_SOLARIS
16 # define SYSCALL(name) SYS_ ## name
18 # define SYSCALL(name) __NR_ ## name
22 // We use 3 kinds of internal_syscall's for different types of retval in order
23 // to address differences in calling conventions (e.g. registers to place the
25 // - internal_syscall for 32-bit length (int, pid_t)
26 // - internal_syscall64 for 64-bit length (off_t)
27 // - internal_syscall_ptr for pointer and (s)size_t
28 # define internal_syscall syscall
29 # define internal_syscall64 __syscall
30 // Handle syscall renames manually
31 # define SYS_stat SYS___stat50
32 # define SYS_lstat SYS___lstat50
33 # define SYS_fstat SYS___fstat50
34 # define SYS_gettimeofday SYS___gettimeofday50
35 # define SYS_wait4 SYS___wait450
36 # define SYS_getdents SYS___getdents30
37 # define SYS_sigaltstack SYS___sigaltstack14
38 # define SYS_sigprocmask SYS___sigprocmask14
39 # define SYS_nanosleep SYS___nanosleep50
40 # define SYS_clock_gettime SYS___clock_gettime50
41 # if SANITIZER_WORDSIZE == 64
42 # define internal_syscall_ptr __syscall
44 # define internal_syscall_ptr syscall
46 #elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
47 # define internal_syscall __syscall
48 # define internal_syscall64 __syscall
49 # define internal_syscall_ptr __syscall
51 # define internal_syscall syscall
52 # define internal_syscall64 syscall
53 # define internal_syscall_ptr syscall
56 bool internal_iserror(uptr retval, int *rverrno) {
57 if (retval == (uptr)-1) {