Chandler Carruth | d865fec | 2012-08-29 02:27:54 +0000 | [diff] [blame] | 1 | //===-- sanitizer/common_interface_defs.h -----------------------*- C++ -*-===// |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 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 basic macro and types. |
| 12 | // NOTE: This file may be included into user code. |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chandler Carruth | d865fec | 2012-08-29 02:27:54 +0000 | [diff] [blame] | 15 | #ifndef SANITIZER_COMMON_INTERFACE_DEFS_H |
| 16 | #define SANITIZER_COMMON_INTERFACE_DEFS_H |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 17 | |
| 18 | // ----------- ATTENTION ------------- |
| 19 | // This header should NOT include any other headers to avoid portability issues. |
| 20 | |
| 21 | #if defined(_WIN32) |
| 22 | // FIXME find out what we need on Windows. __declspec(dllexport) ? |
| 23 | # define SANITIZER_INTERFACE_ATTRIBUTE |
| 24 | # define SANITIZER_WEAK_ATTRIBUTE |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 25 | #elif defined(SANITIZER_GO) |
| 26 | # define SANITIZER_INTERFACE_ATTRIBUTE |
| 27 | # define SANITIZER_WEAK_ATTRIBUTE |
| 28 | #else |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 29 | # define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default"))) |
| 30 | # define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak)) |
Dmitry Vyukov | b78caa6 | 2012-07-05 16:18:28 +0000 | [diff] [blame] | 31 | #endif |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 32 | |
| 33 | // __has_feature |
| 34 | #if !defined(__has_feature) |
| 35 | # define __has_feature(x) 0 |
| 36 | #endif |
| 37 | |
| 38 | // For portability reasons we do not include stddef.h, stdint.h or any other |
| 39 | // system header, but we do need some basic types that are not defined |
| 40 | // in a portable way by the language itself. |
| 41 | namespace __sanitizer { |
| 42 | |
Alexey Samsonov | b46941a | 2012-09-24 11:43:40 +0000 | [diff] [blame^] | 43 | #if defined(_WIN64) |
| 44 | // 64-bit Windows uses LLP64 data model. |
| 45 | typedef unsigned long long uptr; // NOLINT |
| 46 | typedef signed long long sptr; // NOLINT |
| 47 | #else |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 48 | typedef unsigned long uptr; // NOLINT |
| 49 | typedef signed long sptr; // NOLINT |
Alexey Samsonov | b46941a | 2012-09-24 11:43:40 +0000 | [diff] [blame^] | 50 | #endif // defined(_WIN64) |
Alexey Samsonov | 0a4c906 | 2012-06-05 13:50:57 +0000 | [diff] [blame] | 51 | typedef unsigned char u8; |
| 52 | typedef unsigned short u16; // NOLINT |
| 53 | typedef unsigned int u32; |
| 54 | typedef unsigned long long u64; // NOLINT |
| 55 | typedef signed char s8; |
| 56 | typedef signed short s16; // NOLINT |
| 57 | typedef signed int s32; |
| 58 | typedef signed long long s64; // NOLINT |
| 59 | |
| 60 | } // namespace __sanitizer |
| 61 | |
Kostya Serebryany | 81dfbb7 | 2012-09-14 04:35:14 +0000 | [diff] [blame] | 62 | extern "C" { |
| 63 | // Tell the tools to write their reports to "path.<pid>" instead of stderr. |
| 64 | void __sanitizer_set_report_path(const char *path) |
| 65 | SANITIZER_INTERFACE_ATTRIBUTE; |
| 66 | } // extern "C" |
| 67 | |
Chandler Carruth | d865fec | 2012-08-29 02:27:54 +0000 | [diff] [blame] | 68 | #endif // SANITIZER_COMMON_INTERFACE_DEFS_H |