File Index
Files and directories
Sign in
FILE

compiler_types.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/compiler_types.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __LINUX_COMPILER_TYPES_H
  3#define __LINUX_COMPILER_TYPES_H
  4
  5/*
  6 * __has_builtin is supported on gcc >= 10, clang >= 3 and icc >= 21.
  7 * In the meantime, to support gcc < 10, we implement __has_builtin
  8 * by hand.
  9 */
 10#ifndef __has_builtin
 11#define __has_builtin(x) (0)
 12#endif
 13
 14/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
 15#define ___PASTE(a, b) a##b
 16#define __PASTE(a, b) ___PASTE(a, b)
 17
 18#ifndef __ASSEMBLY__
 19
 20/*
 21 * C23 introduces "auto" as a standard way to define type-inferred
 22 * variables, but "auto" has been a (useless) keyword even since K&R C,
 23 * so it has always been "namespace reserved."
 24 *
 25 * Until at some future time we require C23 support, we need the gcc
 26 * extension __auto_type, but there is no reason to put that elsewhere
 27 * in the source code.
 28 */
 29#if __STDC_VERSION__ < 202311L
 30# define auto __auto_type
 31#endif
 32
 33/*
 34 * Skipped when running bindgen due to a libclang issue;
 35 * see https://github.com/rust-lang/rust-bindgen/issues/2244.
 36 */
 37#if defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
 38	__has_attribute(btf_type_tag) && !defined(__BINDGEN__)
 39# define BTF_TYPE_TAG(value) __attribute__((btf_type_tag(#value)))
 40#else
 41# define BTF_TYPE_TAG(value) /* nothing */
 42#endif
 43
 44/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
 45#ifdef __CHECKER__
 46/* address spaces */
 47# define __kernel	__attribute__((address_space(0)))
 48# define __user		__attribute__((noderef, address_space(__user)))
 49# define __iomem	__attribute__((noderef, address_space(__iomem)))
 50# define __percpu	__attribute__((noderef, address_space(__percpu)))
 51# define __rcu		__attribute__((noderef, address_space(__rcu)))
 52static inline void __chk_user_ptr(const volatile void __user *ptr) { }
 53static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
 54/* context/locking */
 55# define __must_hold(x)	__attribute__((context(x,1,1)))
 56# define __acquires(x)	__attribute__((context(x,0,1)))
 57# define __cond_acquires(x) __attribute__((context(x,0,-1)))
 58# define __releases(x)	__attribute__((context(x,1,0)))
 59# define __acquire(x)	__context__(x,1)
 60# define __release(x)	__context__(x,-1)
 61# define __cond_lock(x,c)	((c) ? ({ __acquire(x); 1; }) : 0)
 62/* other */
 63# define __force	__attribute__((force))
 64# define __nocast	__attribute__((nocast))
 65# define __safe		__attribute__((safe))
 66# define __private	__attribute__((noderef))
 67# define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member))
 68#else /* __CHECKER__ */
 69/* address spaces */
 70# define __kernel
 71# ifdef STRUCTLEAK_PLUGIN
 72#  define __user	__attribute__((user))
 73# else
 74#  define __user	BTF_TYPE_TAG(user)
 75# endif
 76# define __iomem
 77# define __percpu	__percpu_qual BTF_TYPE_TAG(percpu)
 78# define __rcu		BTF_TYPE_TAG(rcu)
 79
 80# define __chk_user_ptr(x)	(void)0
 81# define __chk_io_ptr(x)	(void)0
 82/* context/locking */
 83# define __must_hold(x)
 84# define __acquires(x)
 85# define __cond_acquires(x)
 86# define __releases(x)
 87# define __acquire(x)	(void)0
 88# define __release(x)	(void)0
 89# define __cond_lock(x,c) (c)
 90/* other */
 91# define __force
 92# define __nocast
 93# define __safe
 94# define __private
 95# define ACCESS_PRIVATE(p, member) ((p)->member)
 96# define __builtin_warning(x, y...) (1)
 97#endif /* __CHECKER__ */
 98
 99#ifdef __KERNEL__
100
101/* Attributes */
102#include <linux/compiler_attributes.h>
103
104#if CONFIG_FUNCTION_ALIGNMENT > 0
105#define __function_aligned		__aligned(CONFIG_FUNCTION_ALIGNMENT)
106#else
107#define __function_aligned
108#endif
109
110/*
111 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-cold-function-attribute
112 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-cold-label-attribute
113 *
114 * When -falign-functions=N is in use, we must avoid the cold attribute as
115 * GCC drops the alignment for cold functions. Worse, GCC can implicitly mark
116 * callees of cold functions as cold themselves, so it's not sufficient to add
117 * __function_aligned here as that will not ensure that callees are correctly
118 * aligned.
119 *
120 * See:
121 *
122 *   https://lore.kernel.org/lkml/Y77%2FqVgvaJidFpYt@FVFF77S0Q05N
123 *   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345#c9
124 */
125#if defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) || (CONFIG_FUNCTION_ALIGNMENT == 0)
126#define __cold				__attribute__((__cold__))
127#else
128#define __cold
129#endif
130
131/*
132 * On x86-64 and arm64 targets, __preserve_most changes the calling convention
133 * of a function to make the code in the caller as unintrusive as possible. This
134 * convention behaves identically to the C calling convention on how arguments
135 * and return values are passed, but uses a different set of caller- and callee-
136 * saved registers.
137 *
138 * The purpose is to alleviates the burden of saving and recovering a large
139 * register set before and after the call in the caller.  This is beneficial for
140 * rarely taken slow paths, such as error-reporting functions that may be called
141 * from hot paths.
142 *
143 * Note: This may conflict with instrumentation inserted on function entry which
144 * does not use __preserve_most or equivalent convention (if in assembly). Since
145 * function tracing assumes the normal C calling convention, where the attribute
146 * is supported, __preserve_most implies notrace.  It is recommended to restrict
147 * use of the attribute to functions that should or already disable tracing.
148 *
149 * Optional: not supported by gcc.
150 *
151 * clang: https://clang.llvm.org/docs/AttributeReference.html#preserve-most
152 */
153#if __has_attribute(__preserve_most__) && (defined(CONFIG_X86_64) || defined(CONFIG_ARM64))
154# define __preserve_most notrace __attribute__((__preserve_most__))
155#else
156# define __preserve_most
157#endif
158
159/*
160 * Annotating a function/variable with __retain tells the compiler to place
161 * the object in its own section and set the flag SHF_GNU_RETAIN. This flag
162 * instructs the linker to retain the object during garbage-cleanup or LTO
163 * phases.
164 *
165 * Note that the __used macro is also used to prevent functions or data
166 * being optimized out, but operates at the compiler/IR-level and may still
167 * allow unintended removal of objects during linking.
168 *
169 * Optional: only supported since gcc >= 11, clang >= 13
170 *
171 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-retain-function-attribute
172 * clang: https://clang.llvm.org/docs/AttributeReference.html#retain
173 */
174#if __has_attribute(__retain__) && \
175	(defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || \
176	 defined(CONFIG_LTO_CLANG))
177# define __retain			__attribute__((__retain__))
178#else
179# define __retain
180#endif
181
182/* Compiler specific macros. */
183#ifdef __clang__
184#include <linux/compiler-clang.h>
185#elif defined(__GNUC__)
186/* The above compilers also define __GNUC__, so order is important here. */
187#include <linux/compiler-gcc.h>
188#else
189#error "Unknown compiler"
190#endif
191
192/*
193 * Some architectures need to provide custom definitions of macros provided
194 * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
195 * conditionally rather than using an asm-generic wrapper in order to avoid
196 * build failures if any C compilation, which will include this file via an
197 * -include argument in c_flags, occurs prior to the asm-generic wrappers being
198 * generated.
199 */
200#ifdef CONFIG_HAVE_ARCH_COMPILER_H
201#include <asm/compiler.h>
202#endif
203
204struct ftrace_branch_data {
205	const char *func;
206	const char *file;
207	unsigned line;
208	union {
209		struct {
210			unsigned long correct;
211			unsigned long incorrect;
212		};
213		struct {
214			unsigned long miss;
215			unsigned long hit;
216		};
217		unsigned long miss_hit[2];
218	};
219};
220
221struct ftrace_likely_data {
222	struct ftrace_branch_data	data;
223	unsigned long			constant;
224};
225
226#if defined(CC_USING_HOTPATCH)
227#define notrace			__attribute__((hotpatch(0, 0)))
228#elif defined(CC_USING_PATCHABLE_FUNCTION_ENTRY)
229#define notrace			__attribute__((patchable_function_entry(0, 0)))
230#else
231#define notrace			__attribute__((__no_instrument_function__))
232#endif
233
234/*
235 * it doesn't make sense on ARM (currently the only user of __naked)
236 * to trace naked functions because then mcount is called without
237 * stack and frame pointer being set up and there is no chance to
238 * restore the lr register to the value before mcount was called.
239 */
240#define __naked			__attribute__((__naked__)) notrace
241
242/*
243 * Prefer gnu_inline, so that extern inline functions do not emit an
244 * externally visible function. This makes extern inline behave as per gnu89
245 * semantics rather than c99. This prevents multiple symbol definition errors
246 * of extern inline functions at link time.
247 * A lot of inline functions can cause havoc with function tracing.
248 */
249#define inline inline __gnu_inline __inline_maybe_unused notrace
250
251/*
252 * gcc provides both __inline__ and __inline as alternate spellings of
253 * the inline keyword, though the latter is undocumented. New kernel
254 * code should only use the inline spelling, but some existing code
255 * uses __inline__. Since we #define inline above, to ensure
256 * __inline__ has the same semantics, we need this #define.
257 *
258 * However, the spelling __inline is strictly reserved for referring
259 * to the bare keyword.
260 */
261#define __inline__ inline
262
263/*
264 * GCC does not warn about unused static inline functions for -Wunused-function.
265 * Suppress the warning in clang as well by using __maybe_unused, but enable it
266 * for W=2 build. This will allow clang to find unused functions.
267 */
268#ifdef KBUILD_EXTRA_WARN2
269#define __inline_maybe_unused
270#else
271#define __inline_maybe_unused __maybe_unused
272#endif
273
274/*
275 * Rather then using noinline to prevent stack consumption, use
276 * noinline_for_stack instead.  For documentation reasons.
277 */
278#define noinline_for_stack noinline
279
280/*
281 * Use noinline_for_tracing for functions that should not be inlined.
282 * For tracing reasons.
283 */
284#define noinline_for_tracing noinline
285
286/*
287 * Sanitizer helper attributes: Because using __always_inline and
288 * __no_sanitize_* conflict, provide helper attributes that will either expand
289 * to __no_sanitize_* in compilation units where instrumentation is enabled
290 * (__SANITIZE_*__), or __always_inline in compilation units without
291 * instrumentation (__SANITIZE_*__ undefined).
292 */
293#ifdef __SANITIZE_ADDRESS__
294/*
295 * We can't declare function 'inline' because __no_sanitize_address conflicts
296 * with inlining. Attempt to inline it may cause a build failure.
297 *     https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
298 * '__maybe_unused' allows us to avoid defined-but-not-used warnings.
299 */
300# define __no_kasan_or_inline __no_sanitize_address notrace __maybe_unused
301# define __no_sanitize_or_inline __no_kasan_or_inline
302#else
303# define __no_kasan_or_inline __always_inline
304#endif
305
306#ifdef CONFIG_KCSAN
307/*
308 * Type qualifier to mark variables where all data-racy accesses should be
309 * ignored by KCSAN. Note, the implementation simply marks these variables as
310 * volatile, since KCSAN will treat such accesses as "marked".
311 *
312 * Defined here because defining __data_racy as volatile for KCSAN objects only
313 * causes problems in BPF Type Format (BTF) generation since struct members
314 * of core kernel data structs will be volatile in some objects and not in
315 * others.  Instead define it globally for KCSAN kernels.
316 */
317# define __data_racy volatile
318#else
319# define __data_racy
320#endif
321
322#ifdef __SANITIZE_THREAD__
323/*
324 * Clang still emits instrumentation for __tsan_func_{entry,exit}() and builtin
325 * atomics even with __no_sanitize_thread (to avoid false positives in userspace
326 * ThreadSanitizer). The kernel's requirements are stricter and we really do not
327 * want any instrumentation with __no_kcsan.
328 *
329 * Therefore we add __disable_sanitizer_instrumentation where available to
330 * disable all instrumentation. See Kconfig.kcsan where this is mandatory.
331 */
332# define __no_kcsan __no_sanitize_thread __disable_sanitizer_instrumentation
333# define __no_sanitize_or_inline __no_kcsan notrace __maybe_unused
334#else
335# define __no_kcsan
336#endif
337
338#ifdef __SANITIZE_MEMORY__
339/*
340 * Similarly to KASAN and KCSAN, KMSAN loses function attributes of inlined
341 * functions, therefore disabling KMSAN checks also requires disabling inlining.
342 *
343 * __no_sanitize_or_inline effectively prevents KMSAN from reporting errors
344 * within the function and marks all its outputs as initialized.
345 */
346# define __no_sanitize_or_inline __no_kmsan_checks notrace __maybe_unused
347#endif
348
349#ifndef __no_sanitize_or_inline
350#define __no_sanitize_or_inline __always_inline
351#endif
352
353/*
354 * The assume attribute is used to indicate that a certain condition is
355 * assumed to be true. If this condition is violated at runtime, the behavior
356 * is undefined. Compilers may or may not use this indication to generate
357 * optimized code.
358 *
359 * Note that the clang documentation states that optimizers may react
360 * differently to this attribute, and this may even have a negative
361 * performance impact. Therefore this attribute should be used with care.
362 *
363 * Optional: only supported since gcc >= 13
364 * Optional: only supported since clang >= 19
365 *
366 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#index-assume-statement-attribute
367 * clang: https://clang.llvm.org/docs/AttributeReference.html#id13
368 *
369 */
370#ifdef CONFIG_CC_HAS_ASSUME
371# define __assume(expr)			__attribute__((__assume__(expr)))
372#else
373# define __assume(expr)
374#endif
375
376/*
377 * Optional: only supported since gcc >= 15
378 * Optional: only supported since clang >= 18
379 *
380 *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
381 * clang: https://github.com/llvm/llvm-project/pull/76348
382 *
383 * __bdos on clang < 19.1.2 can erroneously return 0:
384 * https://github.com/llvm/llvm-project/pull/110497
385 *
386 * __bdos on clang < 19.1.3 can be off by 4:
387 * https://github.com/llvm/llvm-project/pull/112636
388 */
389#ifdef CONFIG_CC_HAS_COUNTED_BY
390# define __counted_by(member)		__attribute__((__counted_by__(member)))
391#else
392# define __counted_by(member)
393#endif
394
395/*
396 * Optional: only supported since gcc >= 15
397 * Optional: not supported by Clang
398 *
399 * gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178
400 */
401#ifdef CONFIG_CC_HAS_MULTIDIMENSIONAL_NONSTRING
402# define __nonstring_array		__attribute__((__nonstring__))
403#else
404# define __nonstring_array
405#endif
406
407/*
408 * Apply __counted_by() when the Endianness matches to increase test coverage.
409 */
410#ifdef __LITTLE_ENDIAN
411#define __counted_by_le(member)	__counted_by(member)
412#define __counted_by_be(member)
413#else
414#define __counted_by_le(member)
415#define __counted_by_be(member)	__counted_by(member)
416#endif
417
418/*
419 * This designates the minimum number of elements a passed array parameter must
420 * have. For example:
421 *
422 *     void some_function(u8 param[at_least 7]);
423 *
424 * If a caller passes an array with fewer than 7 elements, the compiler will
425 * emit a warning.
426 */
427#ifndef __CHECKER__
428#define at_least static
429#else
430#define at_least
431#endif
432
433/* Do not trap wrapping arithmetic within an annotated function. */
434#ifdef CONFIG_UBSAN_INTEGER_WRAP
435# define __signed_wrap __attribute__((no_sanitize("signed-integer-overflow")))
436#else
437# define __signed_wrap
438#endif
439
440/* Section for code which can't be instrumented at all */
441#define __noinstr_section(section)					\
442	noinline notrace __attribute((__section__(section)))		\
443	__no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage \
444	__no_sanitize_memory __signed_wrap
445
446#define noinstr __noinstr_section(".noinstr.text")
447
448/*
449 * The __cpuidle section is used twofold:
450 *
451 *  1) the original use -- identifying if a CPU is 'stuck' in idle state based
452 *     on it's instruction pointer. See cpu_in_idle().
453 *
454 *  2) supressing instrumentation around where cpuidle disables RCU; where the
455 *     function isn't strictly required for #1, this is interchangeable with
456 *     noinstr.
457 */
458#define __cpuidle __noinstr_section(".cpuidle.text")
459
460#endif /* __KERNEL__ */
461
462#endif /* __ASSEMBLY__ */
463
464/*
465 * The below symbols may be defined for one or more, but not ALL, of the above
466 * compilers. We don't consider that to be an error, so set them to nothing.
467 * For example, some of them are for compiler specific plugins.
468 */
469#ifndef __latent_entropy
470# define __latent_entropy
471#endif
472
473#if defined(RANDSTRUCT) && !defined(__CHECKER__)
474# define __randomize_layout __designated_init __attribute__((randomize_layout))
475# define __no_randomize_layout __attribute__((no_randomize_layout))
476/* This anon struct can add padding, so only enable it under randstruct. */
477# define randomized_struct_fields_start	struct {
478# define randomized_struct_fields_end	} __randomize_layout;
479#else
480# define __randomize_layout __designated_init
481# define __no_randomize_layout
482# define randomized_struct_fields_start
483# define randomized_struct_fields_end
484#endif
485
486#ifndef __no_kstack_erase
487# define __no_kstack_erase
488#endif
489
490#ifndef __noscs
491# define __noscs
492#endif
493
494#if defined(CONFIG_CFI)
495# define __nocfi		__attribute__((__no_sanitize__("kcfi")))
496#else
497# define __nocfi
498#endif
499
500#if defined(CONFIG_ARCH_USES_CFI_GENERIC_LLVM_PASS)
501# define __nocfi_generic	__nocfi
502#else
503# define __nocfi_generic
504#endif
505
506/*
507 * Any place that could be marked with the "alloc_size" attribute is also
508 * a place to be marked with the "malloc" attribute, except those that may
509 * be performing a _reallocation_, as that may alias the existing pointer.
510 * For these, use __realloc_size().
511 */
512#ifdef __alloc_size__
513# define __alloc_size(x, ...)	__alloc_size__(x, ## __VA_ARGS__) __malloc
514# define __realloc_size(x, ...)	__alloc_size__(x, ## __VA_ARGS__)
515#else
516# define __alloc_size(x, ...)	__malloc
517# define __realloc_size(x, ...)
518#endif
519
520/*
521 * When the size of an allocated object is needed, use the best available
522 * mechanism to find it. (For cases where sizeof() cannot be used.)
523 *
524 * Optional: only supported since gcc >= 12
525 *
526 *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
527 * clang: https://clang.llvm.org/docs/LanguageExtensions.html#evaluating-object-size
528 */
529#if __has_builtin(__builtin_dynamic_object_size)
530#define __struct_size(p)	__builtin_dynamic_object_size(p, 0)
531#define __member_size(p)	__builtin_dynamic_object_size(p, 1)
532#else
533#define __struct_size(p)	__builtin_object_size(p, 0)
534#define __member_size(p)	__builtin_object_size(p, 1)
535#endif
536
537/*
538 * Determine if an attribute has been applied to a variable.
539 * Using __annotated needs to check for __annotated being available,
540 * or negative tests may fail when annotation cannot be checked. For
541 * example, see the definition of __is_cstr().
542 */
543#if __has_builtin(__builtin_has_attribute)
544#define __annotated(var, attr)	__builtin_has_attribute(var, attr)
545#endif
546
547/*
548 * Some versions of gcc do not mark 'asm goto' volatile:
549 *
550 *  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103979
551 *
552 * We do it here by hand, because it doesn't hurt.
553 */
554#ifndef asm_goto_output
555#define asm_goto_output(x...) asm volatile goto(x)
556#endif
557
558/*
559 * Clang has trouble with constraints with multiple
560 * alternative behaviors ("g" , "rm" and "=rm").
561 */
562#ifndef ASM_INPUT_G
563  #define ASM_INPUT_G "g"
564  #define ASM_INPUT_RM "rm"
565  #define ASM_OUTPUT_RM "=rm"
566#endif
567
568#ifdef CONFIG_CC_HAS_ASM_INLINE
569#define asm_inline asm __inline
570#else
571#define asm_inline asm
572#endif
573
574/* Are two types/vars the same type (ignoring qualifiers)? */
575#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
576
577/*
578 * __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving
579 *			       non-scalar types unchanged.
580 */
581/*
582 * Prefer C11 _Generic for better compile-times and simpler code. Note: 'char'
583 * is not type-compatible with 'signed char', and we define a separate case.
584 */
585#define __scalar_type_to_expr_cases(type)				\
586		unsigned type:	(unsigned type)0,			\
587		signed type:	(signed type)0
588
589#define __unqual_scalar_typeof(x) typeof(				\
590		_Generic((x),						\
591			 char:	(char)0,				\
592			 __scalar_type_to_expr_cases(char),		\
593			 __scalar_type_to_expr_cases(short),		\
594			 __scalar_type_to_expr_cases(int),		\
595			 __scalar_type_to_expr_cases(long),		\
596			 __scalar_type_to_expr_cases(long long),	\
597			 default: (x)))
598
599/* Is this type a native word size -- useful for atomic operations */
600#define __native_word(t) \
601	(sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
602	 sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
603
604#ifdef __OPTIMIZE__
605/*
606 * #ifdef __OPTIMIZE__ is only a good approximation; for instance "make
607 * CFLAGS_foo.o=-Og" defines __OPTIMIZE__, does not elide the conditional code
608 * and can break compilation with wrong error message(s). Combine with
609 * -U__OPTIMIZE__ when needed.
610 */
611# define __compiletime_assert(condition, msg, prefix, suffix)		\
612	do {								\
613		/*							\
614		 * __noreturn is needed to give the compiler enough	\
615		 * information to avoid certain possibly-uninitialized	\
616		 * warnings (regardless of the build failing).		\
617		 */							\
618		__noreturn extern void prefix ## suffix(void)		\
619			__compiletime_error(msg);			\
620		if (!(condition))					\
621			prefix ## suffix();				\
622	} while (0)
623#else
624# define __compiletime_assert(condition, msg, prefix, suffix) ((void)(condition))
625#endif
626
627#define _compiletime_assert(condition, msg, prefix, suffix) \
628	__compiletime_assert(condition, msg, prefix, suffix)
629
630/**
631 * compiletime_assert - break build and emit msg if condition is false
632 * @condition: a compile-time constant condition to check
633 * @msg:       a message to emit if condition is false
634 *
635 * In tradition of POSIX assert, this macro will break the build if the
636 * supplied condition is *false*, emitting the supplied error message if the
637 * compiler has support to do so.
638 */
639#define compiletime_assert(condition, msg) \
640	_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
641
642#define compiletime_assert_atomic_type(t)				\
643	compiletime_assert(__native_word(t),				\
644		"Need native word sized stores/loads for atomicity.")
645
646/* Helpers for emitting diagnostics in pragmas. */
647#ifndef __diag
648#define __diag(string)
649#endif
650
651#ifndef __diag_GCC
652#define __diag_GCC(version, severity, string)
653#endif
654
655#define __diag_push()	__diag(push)
656#define __diag_pop()	__diag(pop)
657
658#define __diag_ignore(compiler, version, option, comment) \
659	__diag_ ## compiler(version, ignore, option)
660#define __diag_warn(compiler, version, option, comment) \
661	__diag_ ## compiler(version, warn, option)
662#define __diag_error(compiler, version, option, comment) \
663	__diag_ ## compiler(version, error, option)
664
665#ifndef __diag_ignore_all
666#define __diag_ignore_all(option, comment)
667#endif
668
669#endif /* __LINUX_COMPILER_TYPES_H */
~/ Read-only file preview.