xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/sanitizer_common/sanitizer_errno.h (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 //===-- sanitizer_errno.h ---------------------------------------*- 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 // This file is shared between sanitizers run-time libraries.
9 //
10 // Defines errno to avoid including errno.h and its dependencies into sensitive
11 // files (e.g. interceptors are not supposed to include any system headers).
12 // It's ok to use errno.h directly when your file already depend on other system
13 // includes though.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef SANITIZER_ERRNO_H
18 #define SANITIZER_ERRNO_H
19 
20 #include "sanitizer_errno_codes.h"
21 #include "sanitizer_platform.h"
22 
23 #if SANITIZER_FREEBSD || SANITIZER_MAC
24 #  define __errno_location __error
25 #elif SANITIZER_ANDROID || SANITIZER_NETBSD || SANITIZER_OPENBSD || \
26   SANITIZER_RTEMS
27 #  define __errno_location __errno
28 #elif SANITIZER_SOLARIS
29 #  define __errno_location ___errno
30 #elif SANITIZER_WINDOWS
31 #  define __errno_location _errno
32 #endif
33 
34 extern "C" int *__errno_location();
35 
36 #define errno (*__errno_location())
37 
38 #endif  // SANITIZER_ERRNO_H
39