1 //===-- sanitizer_errno.h ---------------------------------------*- 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 // This file is shared between sanitizers run-time libraries.
12 // Defines errno to avoid including errno.h and its dependencies into sensitive
13 // files (e.g. interceptors are not supposed to include any system headers).
14 // It's ok to use errno.h directly when your file already depend on other system
17 //===----------------------------------------------------------------------===//
19 #ifndef SANITIZER_ERRNO_H
20 #define SANITIZER_ERRNO_H
22 #include "sanitizer_errno_codes.h"
23 #include "sanitizer_platform.h"
25 #if SANITIZER_FREEBSD || SANITIZER_MAC
26 # define __errno_location __error
27 #elif SANITIZER_ANDROID || SANITIZER_NETBSD || SANITIZER_OPENBSD || \
29 # define __errno_location __errno
30 #elif SANITIZER_SOLARIS
31 # define __errno_location ___errno
32 #elif SANITIZER_WINDOWS
33 # define __errno_location _errno
36 extern "C" int *__errno_location();
38 #define errno (*__errno_location())
40 #endif // SANITIZER_ERRNO_H