]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
1 //===-- sanitizer_platform.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Common platform macros.
11 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_PLATFORM_H
14 #define SANITIZER_PLATFORM_H
16 #if !defined(__linux__) && !defined(__FreeBSD__) && \
17 !defined(__APPLE__) && !defined(_WIN32)
18 # error "This operating system is not supported"
21 #if defined(__linux__)
22 # define SANITIZER_LINUX 1
24 # define SANITIZER_LINUX 0
27 #if defined(__FreeBSD__)
28 # define SANITIZER_FREEBSD 1
30 # define SANITIZER_FREEBSD 0
33 #if defined(__APPLE__)
34 # define SANITIZER_MAC 1
35 # include <TargetConditionals.h>
37 # define SANITIZER_IOS 1
39 # define SANITIZER_IOS 0
42 # define SANITIZER_MAC 0
43 # define SANITIZER_IOS 0
47 # define SANITIZER_WINDOWS 1
49 # define SANITIZER_WINDOWS 0
52 #if defined(__ANDROID__) || defined(ANDROID)
53 # define SANITIZER_ANDROID 1
55 # define SANITIZER_ANDROID 0
58 #define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC)
60 #if __LP64__ || defined(_WIN64)
61 # define SANITIZER_WORDSIZE 64
63 # define SANITIZER_WORDSIZE 32
66 #if SANITIZER_WORDSIZE == 64
67 # define FIRST_32_SECOND_64(a, b) (b)
69 # define FIRST_32_SECOND_64(a, b) (a)
72 // By default we allow to use SizeClassAllocator64 on 64-bit platform.
73 // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
74 // does not work well and we need to fallback to SizeClassAllocator32.
75 // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
76 // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
77 #ifndef SANITIZER_CAN_USE_ALLOCATOR64
78 # if defined(__aarch64__)
79 # define SANITIZER_CAN_USE_ALLOCATOR64 0
81 # define SANITIZER_CAN_USE_ALLOCATOR64 (SANITIZER_WORDSIZE == 64)
85 // The range of addresses which can be returned my mmap.
86 // FIXME: this value should be different on different platforms,
87 // e.g. on AArch64 it is most likely (1ULL << 39). Larger values will still work
88 // but will consume more memory for TwoLevelByteMap.
89 #if defined(__aarch64__)
90 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
92 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
95 // The AArch64 linux port uses the canonical syscall set as mandated by
96 // the upstream linux community for all new ports. Other ports may still
97 // use legacy syscalls.
98 #ifndef SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
99 # if defined(__aarch64__) && SANITIZER_LINUX
100 # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 1
102 # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 0
106 #endif // SANITIZER_PLATFORM_H