~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/compiler-clang.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 /*
  9  * Clang prior to 17 is being silly and considers many __cleanup() variables
 10  * as unused (because they are, their sole purpose is to go out of scope).
 11  *
 12  * https://github.com/llvm/llvm-project/commit/877210faa447f4cc7db87812f8ed80e398fedd61
 13  */
 14 #undef __cleanup
 15 #define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))
 16 
 17 /* all clang versions usable with the kernel support KASAN ABI version 5 */
 18 #define KASAN_ABI_VERSION 5
 19 
 20 /*
 21  * Note: Checking __has_feature(*_sanitizer) is only true if the feature is
 22  * enabled. Therefore it is not required to additionally check defined(CONFIG_*)
 23  * to avoid adding redundant attributes in other configurations.
 24  */
 25 
 26 #if __has_feature(address_sanitizer) || __has_feature(hwaddress_sanitizer)
 27 /* Emulate GCC's __SANITIZE_ADDRESS__ flag */
 28 #define __SANITIZE_ADDRESS__
 29 #define __no_sanitize_address \
 30                 __attribute__((no_sanitize("address", "hwaddress")))
 31 #else
 32 #define __no_sanitize_address
 33 #endif
 34 
 35 #if __has_feature(thread_sanitizer)
 36 /* emulate gcc's __SANITIZE_THREAD__ flag */
 37 #define __SANITIZE_THREAD__
 38 #define __no_sanitize_thread \
 39                 __attribute__((no_sanitize("thread")))
 40 #else
 41 #define __no_sanitize_thread
 42 #endif
 43 
 44 #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP)
 45 #define __HAVE_BUILTIN_BSWAP32__
 46 #define __HAVE_BUILTIN_BSWAP64__
 47 #define __HAVE_BUILTIN_BSWAP16__
 48 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
 49 
 50 #if __has_feature(undefined_behavior_sanitizer)
 51 /* GCC does not have __SANITIZE_UNDEFINED__ */
 52 #define __no_sanitize_undefined \
 53                 __attribute__((no_sanitize("undefined")))
 54 #else
 55 #define __no_sanitize_undefined
 56 #endif
 57 
 58 #if __has_feature(memory_sanitizer)
 59 #define __SANITIZE_MEMORY__
 60 /*
 61  * Unlike other sanitizers, KMSAN still inserts code into functions marked with
 62  * no_sanitize("kernel-memory"). Using disable_sanitizer_instrumentation
 63  * provides the behavior consistent with other __no_sanitize_ attributes,
 64  * guaranteeing that __no_sanitize_memory functions remain uninstrumented.
 65  */
 66 #define __no_sanitize_memory __disable_sanitizer_instrumentation
 67 
 68 /*
 69  * The __no_kmsan_checks attribute ensures that a function does not produce
 70  * false positive reports by:
 71  *  - initializing all local variables and memory stores in this function;
 72  *  - skipping all shadow checks;
 73  *  - passing initialized arguments to this function's callees.
 74  */
 75 #define __no_kmsan_checks __attribute__((no_sanitize("kernel-memory")))
 76 #else
 77 #define __no_sanitize_memory
 78 #define __no_kmsan_checks
 79 #endif
 80 
 81 /*
 82  * Support for __has_feature(coverage_sanitizer) was added in Clang 13 together
 83  * with no_sanitize("coverage"). Prior versions of Clang support coverage
 84  * instrumentation, but cannot be queried for support by the preprocessor.
 85  */
 86 #if __has_feature(coverage_sanitizer)
 87 #define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
 88 #else
 89 #define __no_sanitize_coverage
 90 #endif
 91 
 92 #if __has_feature(shadow_call_stack)
 93 # define __noscs        __attribute__((__no_sanitize__("shadow-call-stack")))
 94 #endif
 95 
 96 #if __has_feature(kcfi)
 97 /* Disable CFI checking inside a function. */
 98 #define __nocfi         __attribute__((__no_sanitize__("kcfi")))
 99 #endif
100 
101 /*
102  * Turn individual warnings and errors on and off locally, depending
103  * on version.
104  */
105 #define __diag_clang(version, severity, s) \
106         __diag_clang_ ## version(__diag_clang_ ## severity s)
107 
108 /* Severity used in pragma directives */
109 #define __diag_clang_ignore     ignored
110 #define __diag_clang_warn       warning
111 #define __diag_clang_error      error
112 
113 #define __diag_str1(s)          #s
114 #define __diag_str(s)           __diag_str1(s)
115 #define __diag(s)               _Pragma(__diag_str(clang diagnostic s))
116 
117 #define __diag_clang_13(s)      __diag(s)
118 
119 #define __diag_ignore_all(option, comment) \
120         __diag_clang(13, ignore, option)
121 
122 /*
123  * clang has horrible behavior with "g" or "rm" constraints for asm
124  * inputs, turning them into something worse than "m". Avoid using
125  * constraints with multiple possible uses (but "ir" seems to be ok):
126  *
127  *      https://github.com/llvm/llvm-project/issues/20571
128  */
129 #define ASM_INPUT_G "ir"
130 #define ASM_INPUT_RM "r"
131 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php