Fix GNU coding style for G_.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_syscall_generic.inc
blob7c9a2719eea5e019c97f830d5caf7b7bc85f7c84
1 //===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Generic implementations of internal_syscall* and internal_iserror.
9 //
10 //===----------------------------------------------------------------------===//
12 #if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
13 # define SYSCALL(name) SYS_ ## name
14 #else
15 # define SYSCALL(name) __NR_ ## name
16 #endif
18 #if SANITIZER_NETBSD
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
21 // return value in).
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
39 # else
40 #  define internal_syscall_ptr  syscall
41 # endif
42 #elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
43 # define internal_syscall __syscall
44 # else
45 # define internal_syscall syscall
46 #endif
48 bool internal_iserror(uptr retval, int *rverrno) {
49   if (retval == (uptr)-1) {
50     if (rverrno)
51       *rverrno = errno;
52     return true;
53   } else {
54     return false;
55   }