Account for prologue spills in reg_pressure scheduling
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_platform.h
blob14594d5ce553af33d6b7c7ebe3e2ad1d795a1d3d
1 //===-- sanitizer_platform.h ------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Common platform macros.
9 //===----------------------------------------------------------------------===//
11 #ifndef SANITIZER_PLATFORM_H
12 #define SANITIZER_PLATFORM_H
14 #if !defined(__linux__) && !defined(__FreeBSD__) && \
15 !defined(__APPLE__) && !defined(_WIN32)
16 # error "This operating system is not supported"
17 #endif
19 #if defined(__linux__)
20 # define SANITIZER_LINUX 1
21 #else
22 # define SANITIZER_LINUX 0
23 #endif
25 #if defined(__FreeBSD__)
26 # define SANITIZER_FREEBSD 1
27 #else
28 # define SANITIZER_FREEBSD 0
29 #endif
31 #if defined(__APPLE__)
32 # define SANITIZER_MAC 1
33 # include <TargetConditionals.h>
34 # if TARGET_OS_IPHONE
35 # define SANITIZER_IOS 1
36 # else
37 # define SANITIZER_IOS 0
38 # endif
39 #else
40 # define SANITIZER_MAC 0
41 # define SANITIZER_IOS 0
42 #endif
44 #if defined(_WIN32)
45 # define SANITIZER_WINDOWS 1
46 #else
47 # define SANITIZER_WINDOWS 0
48 #endif
50 #if defined(__ANDROID__) || defined(ANDROID)
51 # define SANITIZER_ANDROID 1
52 #else
53 # define SANITIZER_ANDROID 0
54 #endif
56 #define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC)
58 #if __LP64__ || defined(_WIN64)
59 # define SANITIZER_WORDSIZE 64
60 #else
61 # define SANITIZER_WORDSIZE 32
62 #endif
64 #if SANITIZER_WORDSIZE == 64
65 # define FIRST_32_SECOND_64(a, b) (b)
66 #else
67 # define FIRST_32_SECOND_64(a, b) (a)
68 #endif
70 #if defined(__x86_64__) && !defined(_LP64)
71 # define SANITIZER_X32 1
72 #else
73 # define SANITIZER_X32 0
74 #endif
76 // By default we allow to use SizeClassAllocator64 on 64-bit platform.
77 // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
78 // does not work well and we need to fallback to SizeClassAllocator32.
79 // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
80 // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
81 #ifndef SANITIZER_CAN_USE_ALLOCATOR64
82 # if defined(__aarch64__)
83 # define SANITIZER_CAN_USE_ALLOCATOR64 0
84 # else
85 # define SANITIZER_CAN_USE_ALLOCATOR64 (SANITIZER_WORDSIZE == 64)
86 # endif
87 #endif
89 // The range of addresses which can be returned my mmap.
90 // FIXME: this value should be different on different platforms,
91 // e.g. on AArch64 it is most likely (1ULL << 39). Larger values will still work
92 // but will consume more memory for TwoLevelByteMap.
93 #if defined(__aarch64__)
94 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
95 #else
96 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
97 #endif
99 // The AArch64 linux port uses the canonical syscall set as mandated by
100 // the upstream linux community for all new ports. Other ports may still
101 // use legacy syscalls.
102 #ifndef SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
103 # if defined(__aarch64__) && SANITIZER_LINUX
104 # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 1
105 # else
106 # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 0
107 # endif
108 #endif
110 #endif // SANITIZER_PLATFORM_H