sanitizer_internal_defs.h revision 0a4c906dbc8f150657ddd4f19a7192b779f1d605
19aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany//===-- sanitizer_defs.h ----------------------------------------*- C++ -*-===// 29aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// 39aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// The LLVM Compiler Infrastructure 49aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// 59aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// This file is distributed under the University of Illinois Open Source 69aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// License. See LICENSE.TXT for details. 79aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// 89aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany//===----------------------------------------------------------------------===// 99aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// 109aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// This file is shared between AddressSanitizer and ThreadSanitizer. 110a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// It contains macro used in run-time libraries code. 129aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany//===----------------------------------------------------------------------===// 139aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany#ifndef SANITIZER_DEFS_H 149aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany#define SANITIZER_DEFS_H 159aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany 160a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#include "sanitizer_interface_defs.h" 170a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonovusing namespace __sanitizer; // NOLINT 189aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// ----------- ATTENTION ------------- 199aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany// This header should NOT include any other headers to avoid portability issues. 209aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany 210a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// Common defs. 220a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#define INLINE static inline 230a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#define INTERFACE_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE 240a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#define WEAK SANITIZER_WEAK_ATTRIBUTE 250a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov 260a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// Platform-specific defs. 279aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany#if defined(_WIN32) 280a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonovtypedef unsigned long DWORD; // NOLINT 290a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// FIXME(timurrrr): do we need this on Windows? 300a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define ALIAS(x) 310a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define ALIGNED(x) __declspec(align(x)) 320a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define NOINLINE __declspec(noinline) 330a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define NORETURN __declspec(noreturn) 340a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define THREADLOCAL __declspec(thread) 350a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#else // _WIN32 360a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define ALIAS(x) __attribute__((alias(x))) 370a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define ALIGNED(x) __attribute__((aligned(x))) 380a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define NOINLINE __attribute__((noinline)) 390a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define NORETURN __attribute__((noreturn)) 400a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define THREADLOCAL __thread 410a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#endif // _WIN32 420a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov 430a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// We have no equivalent of these on Windows. 440a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#ifndef _WIN32 450a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define ALWAYS_INLINE __attribute__((always_inline)) 460a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define LIKELY(x) __builtin_expect(!!(x), 1) 470a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define UNLIKELY(x) __builtin_expect(!!(x), 0) 480a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define FORMAT(f, a) __attribute__((format(printf, f, a))) 490a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define USED __attribute__((used)) 509aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany#endif 519aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany 520a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// If __WORDSIZE was undefined by the platform, define it in terms of the 530a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov// compiler built-ins __LP64__ and _WIN64. 540a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#ifndef __WORDSIZE 550a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# if __LP64__ || defined(_WIN64) 560a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define __WORDSIZE 64 570a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# else 580a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# define __WORDSIZE 32 590a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov# endif 600a4c906dbc8f150657ddd4f19a7192b779f1d605Alexey Samsonov#endif // __WORDSIZE 619aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany 629aead37421a6e4bf43265e5195c6ac31fc519982Kostya Serebryany#endif // SANITIZER_DEFS_H 63