blob: 15cf05f06087afcf95473e4c245c2e609de41527 [file] [log] [blame]
Peter Collingbourne6f4be192013-05-08 14:43:49 +00001//===-- sanitizer_syscall_generic.inc ---------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Generic implementations of internal_syscall and internal_iserror.
11//
12//===----------------------------------------------------------------------===//
13
Ismail Pazarbasi87f4c902015-02-22 22:01:09 +000014#if SANITIZER_FREEBSD || SANITIZER_MAC
Alexey Samsonov78a6d202014-03-07 10:03:54 +000015# define SYSCALL(name) SYS_ ## name
16#else
17# define SYSCALL(name) __NR_ ## name
18#endif
19
Ismail Pazarbasi87f4c902015-02-22 22:01:09 +000020#if (SANITIZER_FREEBSD || SANITIZER_MAC) && defined(__x86_64__)
Alexey Samsonov78a6d202014-03-07 10:03:54 +000021# define internal_syscall __syscall
22# else
23# define internal_syscall syscall
24#endif
Peter Collingbourne6f4be192013-05-08 14:43:49 +000025
26bool internal_iserror(uptr retval, int *rverrno) {
27 if (retval == (uptr)-1) {
28 if (rverrno)
29 *rverrno = errno;
30 return true;
31 } else {
32 return false;
33 }
34}