1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_COMPILER_TYPES_H
3 #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
6 /* Compiler specific definitions for Clang compiler */
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
11 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
13 /* all clang versions usable with the kernel support KASAN ABI version 5 */
14 #define KASAN_ABI_VERSION 5
16 #if __has_feature(address_sanitizer) || __has_feature(hwaddress_sanitizer)
17 /* Emulate GCC's __SANITIZE_ADDRESS__ flag */
18 #define __SANITIZE_ADDRESS__
19 #define __no_sanitize_address \
20 __attribute__((no_sanitize("address", "hwaddress")))
22 #define __no_sanitize_address
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")))
31 #define __no_sanitize_thread
34 #if __has_feature(undefined_behavior_sanitizer)
35 /* GCC does not have __SANITIZE_UNDEFINED__ */
36 #define __no_sanitize_undefined \
37 __attribute__((no_sanitize("undefined")))
39 #define __no_sanitize_undefined
43 * Not all versions of clang implement the type-generic versions
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.
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
55 #if __has_feature(shadow_call_stack)
56 # define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))