sanitizer_errno.h revision 321369
1//===-- sanitizer_errno.h ---------------------------------------*- 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// This file is shared between sanitizers run-time libraries.
11//
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
15// includes though.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef SANITIZER_ERRNO_H
20#define SANITIZER_ERRNO_H
21
22#include "sanitizer_errno_codes.h"
23#include "sanitizer_platform.h"
24
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
31#endif
32
33extern "C" int *__errno_location();
34
35#define errno (*__errno_location())
36
37#endif  // SANITIZER_ERRNO_H
38