Home | History | Annotate | Line # | Download | only in sanitizer_common
      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 || SANITIZER_NETBSD || SANITIZER_OPENBSD || \
     28   SANITIZER_RTEMS
     29 #  define __errno_location __errno
     30 #elif SANITIZER_SOLARIS
     31 #  define __errno_location ___errno
     32 #elif SANITIZER_WINDOWS
     33 #  define __errno_location _errno
     34 #endif
     35 
     36 extern "C" int *__errno_location();
     37 
     38 #define errno (*__errno_location())
     39 
     40 #endif  // SANITIZER_ERRNO_H
     41