drm/amd/display: do not compare integers of different widths
[linux-2.6-microblaze.git] / include / linux / compiler-clang.h
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."
4 #endif
5
6 /* Compiler specific definitions for Clang compiler */
7
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__)
12
13 /* all clang versions usable with the kernel support KASAN ABI version 5 */
14 #define KASAN_ABI_VERSION 5
15
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")))
21 #else
22 #define __no_sanitize_address
23 #endif
24
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
34 #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
35 #define __HAVE_BUILTIN_BSWAP32__
36 #define __HAVE_BUILTIN_BSWAP64__
37 #define __HAVE_BUILTIN_BSWAP16__
38 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
39
40 #if __has_feature(undefined_behavior_sanitizer)
41 /* GCC does not have __SANITIZE_UNDEFINED__ */
42 #define __no_sanitize_undefined \
43                 __attribute__((no_sanitize("undefined")))
44 #else
45 #define __no_sanitize_undefined
46 #endif
47
48 /*
49  * Not all versions of clang implement the type-generic versions
50  * of the builtin overflow checkers. Fortunately, clang implements
51  * __has_builtin allowing us to avoid awkward version
52  * checks. Unfortunately, we don't know which version of gcc clang
53  * pretends to be, so the macro may or may not be defined.
54  */
55 #if __has_builtin(__builtin_mul_overflow) && \
56     __has_builtin(__builtin_add_overflow) && \
57     __has_builtin(__builtin_sub_overflow)
58 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
59 #endif
60
61 #if __has_feature(shadow_call_stack)
62 # define __noscs        __attribute__((__no_sanitize__("shadow-call-stack")))
63 #endif
64
65 #define __nocfi         __attribute__((__no_sanitize__("cfi")))
66 #define __cficanonical  __attribute__((__cfi_canonical_jump_table__))