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
28 # define __errno_location __errno
29 #elif SANITIZER_WINDOWS
30 # define __errno_location _errno
33 extern "C" int *__errno_location();
35 #define errno (*__errno_location())
37 #endif // SANITIZER_ERRNO_H