sanitizer_internal_defs.h revision 15503b0a4331c7f27f9cebc25e25c2e494f61cb9
1//===-- sanitizer_internal_defs.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 AddressSanitizer and ThreadSanitizer. 11// It contains macro used in run-time libraries code. 12//===----------------------------------------------------------------------===// 13#ifndef SANITIZER_DEFS_H 14#define SANITIZER_DEFS_H 15 16#include "sanitizer_interface_defs.h" 17using namespace __sanitizer; // NOLINT 18// ----------- ATTENTION ------------- 19// This header should NOT include any other headers to avoid portability issues. 20 21// Common defs. 22#define INLINE static inline 23#define INTERFACE_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE 24#define WEAK SANITIZER_WEAK_ATTRIBUTE 25 26// Platform-specific defs. 27#if defined(_WIN32) 28typedef unsigned long DWORD; // NOLINT 29// FIXME(timurrrr): do we need this on Windows? 30# define ALIAS(x) 31# define ALIGNED(x) __declspec(align(x)) 32# define FORMAT(f, a) 33# define NOINLINE __declspec(noinline) 34# define NORETURN __declspec(noreturn) 35# define THREADLOCAL __declspec(thread) 36#else // _WIN32 37# define ALIAS(x) __attribute__((alias(x))) 38# define ALIGNED(x) __attribute__((aligned(x))) 39# define FORMAT(f, a) __attribute__((format(printf, f, a))) 40# define NOINLINE __attribute__((noinline)) 41# define NORETURN __attribute__((noreturn)) 42# define THREADLOCAL __thread 43#endif // _WIN32 44 45// We have no equivalent of these on Windows. 46#ifndef _WIN32 47# define ALWAYS_INLINE __attribute__((always_inline)) 48# define LIKELY(x) __builtin_expect(!!(x), 1) 49# define UNLIKELY(x) __builtin_expect(!!(x), 0) 50# define USED __attribute__((used)) 51#endif 52 53// If __WORDSIZE was undefined by the platform, define it in terms of the 54// compiler built-ins __LP64__ and _WIN64. 55#ifndef __WORDSIZE 56# if __LP64__ || defined(_WIN64) 57# define __WORDSIZE 64 58# else 59# define __WORDSIZE 32 60# endif 61#endif // __WORDSIZE 62 63// Raw check. 64#define RAW_CHECK_MSG(expr, msg) do { \ 65 if (!(expr)) { \ 66 RawWrite(msg); \ 67 Die(); \ 68 } \ 69} while (0) 70 71#define RAW_CHECK(expr) RAW_CHECK_MSG(expr, #expr) 72 73#endif // SANITIZER_DEFS_H 74