]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
d1515582 | 2 | #ifndef __LINUX_COMPILER_TYPES_H |
565cbdc2 MC |
3 | #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead." |
4 | #endif | |
5 | ||
3e2ffd65 MT |
6 | /* Compiler specific definitions for Clang compiler */ |
7 | ||
b41c29b0 AB |
8 | /* same as gcc, this was present in clang-2.6 so we can assume it works |
9 | * with any version that can compile the kernel | |
10 | */ | |
11 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | |
4ca59b14 | 12 | |
53a98ed7 PL |
13 | /* all clang versions usable with the kernel support KASAN ABI version 5 */ |
14 | #define KASAN_ABI_VERSION 5 | |
15 | ||
2bd926b4 | 16 | #if __has_feature(address_sanitizer) || __has_feature(hwaddress_sanitizer) |
5cbaefe9 | 17 | /* Emulate GCC's __SANITIZE_ADDRESS__ flag */ |
53a98ed7 | 18 | #define __SANITIZE_ADDRESS__ |
2bd926b4 AK |
19 | #define __no_sanitize_address \ |
20 | __attribute__((no_sanitize("address", "hwaddress"))) | |
21 | #else | |
22 | #define __no_sanitize_address | |
53a98ed7 | 23 | #endif |
87358710 | 24 | |
dfd402a4 ME |
25 | #if __has_feature(thread_sanitizer) |
26 | /* emulate gcc's __SANITIZE_THREAD__ flag */ | |
27 | #define __SANITIZE_THREAD__ | |
28 | #define __no_sanitize_thread \ | |
29 | __attribute__((no_sanitize("thread"))) | |
30 | #else | |
31 | #define __no_sanitize_thread | |
32 | #endif | |
33 | ||
5144f8a8 ME |
34 | #if __has_feature(undefined_behavior_sanitizer) |
35 | /* GCC does not have __SANITIZE_UNDEFINED__ */ | |
36 | #define __no_sanitize_undefined \ | |
37 | __attribute__((no_sanitize("undefined"))) | |
38 | #else | |
39 | #define __no_sanitize_undefined | |
40 | #endif | |
41 | ||
f0907827 | 42 | /* |
c5f748e2 | 43 | * Not all versions of clang implement the type-generic versions |
f0907827 RV |
44 | * of the builtin overflow checkers. Fortunately, clang implements |
45 | * __has_builtin allowing us to avoid awkward version | |
46 | * checks. Unfortunately, we don't know which version of gcc clang | |
47 | * pretends to be, so the macro may or may not be defined. | |
48 | */ | |
f0907827 RV |
49 | #if __has_builtin(__builtin_mul_overflow) && \ |
50 | __has_builtin(__builtin_add_overflow) && \ | |
51 | __has_builtin(__builtin_sub_overflow) | |
52 | #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 | |
53 | #endif | |
815f0ddb | 54 | |
d08b9f0c ST |
55 | #if __has_feature(shadow_call_stack) |
56 | # define __noscs __attribute__((__no_sanitize__("shadow-call-stack"))) | |
57 | #endif |