blob: 921126ec0467c2121187c24c5e7099f34f26da7d [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#ifndef __LINUX_COMPILER_H
2#error "Please don't include <linux/compiler-gcc13.h> directly, include <linux/compiler.h> instead."
3#endif
4
5#define __used __attribute__((__used__))
6#define __must_check __attribute__((warn_unused_result))
7#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
8
9/* Mark functions as cold. gcc will assume any path leading to a call
10 to them will be unlikely. This means a lot of manual unlikely()s
11 are unnecessary now for any paths leading to the usual suspects
12 like BUG(), printk(), panic() etc. [but let's keep them for now for
13 older compilers]
14
15 gcc also has a __attribute__((__hot__)) to move hot functions into
16 a special section, but I don't see any sense in this right now in
17 the kernel context */
18#define __cold __attribute__((__cold__))
19
20#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
21
22#ifndef __CHECKER__
23# define __compiletime_warning(message) __attribute__((warning(message)))
24# define __compiletime_error(message) __attribute__((error(message)))
25#endif /* __CHECKER__ */
26
27/*
28 * Mark a position in code as unreachable. This can be used to
29 * suppress control flow warnings after asm blocks that transfer
30 * control elsewhere.
31 */
32#define unreachable() __builtin_unreachable()
33
34/* Mark a function definition as prohibited from being cloned. */
35#define __noclone __attribute__((__noclone__))
36
37/*
38 * Tell the optimizer that something else uses this function or variable.
39 */
40#define __visible __attribute__((externally_visible))
41
42/*
43 * GCC 'asm goto' miscompiles certain code sequences:
44 *
45 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
46 *
47 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
48 *
49 * (asm goto is automatically volatile - the naming reflects this.)
50 */
51#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
52
53#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
54#define __HAVE_BUILTIN_BSWAP32__
55#define __HAVE_BUILTIN_BSWAP64__
56#define __HAVE_BUILTIN_BSWAP16__
57#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
58
59#define KASAN_ABI_VERSION 4