Zephyr API Documentation 4.2.00-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gcc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2014,2017 Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_
8#define ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_
9
10#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_H_
11#error Please do not include toolchain-specific headers directly, use <zephyr/toolchain.h> instead
12#endif
13
21#define TOOLCHAIN_GCC_VERSION \
22 ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
23
24/* GCC supports #pragma diagnostics since 4.6.0 */
25#if !defined(TOOLCHAIN_HAS_PRAGMA_DIAG) && (TOOLCHAIN_GCC_VERSION >= 40600)
26#define TOOLCHAIN_HAS_PRAGMA_DIAG 1
27#endif
28
29#if !defined(TOOLCHAIN_HAS_C_GENERIC) && (TOOLCHAIN_GCC_VERSION >= 40900)
30#define TOOLCHAIN_HAS_C_GENERIC 1
31#endif
32
33#if !defined(TOOLCHAIN_HAS_C_AUTO_TYPE) && (TOOLCHAIN_GCC_VERSION >= 40900)
34#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
35#endif
36
37#define TOOLCHAIN_HAS_ZLA 1
38
39/*
40 * Older versions of GCC do not define __BYTE_ORDER__, so it must be manually
41 * detected and defined using arch-specific definitions.
42 */
43
44#ifndef _LINKER
45
46#ifndef __ORDER_BIG_ENDIAN__
47#define __ORDER_BIG_ENDIAN__ (1)
48#endif
49
50#ifndef __ORDER_LITTLE_ENDIAN__
51#define __ORDER_LITTLE_ENDIAN__ (2)
52#endif
53
54#ifndef __BYTE_ORDER__
55#if defined(__BIG_ENDIAN__) || defined(__ARMEB__) || \
56 defined(__THUMBEB__) || defined(__AARCH64EB__) || \
57 defined(__MIPSEB__) || defined(__TC32EB__)
58
59#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
60
61#elif defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || \
62 defined(__THUMBEL__) || defined(__AARCH64EL__) || \
63 defined(__MIPSEL__) || defined(__TC32EL__)
64
65#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
66
67#else
68#error "__BYTE_ORDER__ is not defined and cannot be automatically resolved"
69#endif
70#endif
71
72
73#undef BUILD_ASSERT /* clear out common version */
74/* C++11 has static_assert built in */
75#if defined(__cplusplus) && (__cplusplus >= 201103L)
76#define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG)
77
78/*
79 * GCC 4.6 and higher have the C11 _Static_assert built in and its
80 * output is easier to understand than the common BUILD_ASSERT macros.
81 * Don't use this in C++98 mode though (which we can hit, as
82 * static_assert() is not available)
83 */
84#elif !defined(__cplusplus) && \
85 (((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))) || \
86 (__STDC_VERSION__) >= 201100)
87#define BUILD_ASSERT(EXPR, MSG...) _Static_assert((EXPR), "" MSG)
88#else
89#define BUILD_ASSERT(EXPR, MSG...)
90#endif
91
92#ifdef __cplusplus
93#define ZRESTRICT __restrict
94#else
95#define ZRESTRICT restrict
96#endif
97
99#include <stdbool.h>
100
101#define ALIAS_OF(of) __attribute__((alias(#of)))
102
103#define FUNC_ALIAS(real_func, new_alias, return_type) \
104 return_type new_alias() ALIAS_OF(real_func)
105
106#if TOOLCHAIN_GCC_VERSION < 40500
107#define __builtin_unreachable() __builtin_trap()
108#endif
109
110#if defined(CONFIG_ARCH_POSIX) && !defined(_ASMLANGUAGE)
112
113/*let's not segfault if this were to happen for some reason*/
114#define CODE_UNREACHABLE \
115{\
116 posix_print_error_and_exit("CODE_UNREACHABLE reached from %s:%d\n",\
117 __FILE__, __LINE__);\
118 __builtin_unreachable(); \
119}
120#else
121#define CODE_UNREACHABLE __builtin_unreachable()
122#endif
123#define FUNC_NORETURN __attribute__((__noreturn__))
124
125/* The GNU assembler for Cortex-M3 uses # for immediate values, not
126 * comments, so the @nobits# trick does not work.
127 */
128#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
129#define _NODATA_SECTION(segment) __attribute__((section(#segment)))
130#else
131#define _NODATA_SECTION(segment) \
132 __attribute__((section(#segment ",\"wa\",@nobits#")))
133#endif
134
135/* Unaligned access */
136#define UNALIGNED_GET(g) \
137__extension__ ({ \
138 struct __attribute__((__packed__)) { \
139 __typeof__(*(g)) __v; \
140 } *__g = (__typeof__(__g)) (g); \
141 __g->__v; \
142})
143
144
145#if (__GNUC__ >= 7) && (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
146
147/* Version of UNALIGNED_PUT() which issues a compiler_barrier() after
148 * the store. It is required to workaround an apparent optimization
149 * bug in GCC for ARM Cortex-M3 and higher targets, when multiple
150 * byte, half-word and word stores (strb, strh, str instructions),
151 * which support unaligned access, can be coalesced into store double
152 * (strd) instruction, which doesn't support unaligned access (the
153 * compilers in question do this optimization ignoring __packed__
154 * attribute).
155 */
156#define UNALIGNED_PUT(v, p) \
157do { \
158 struct __attribute__((__packed__)) { \
159 __typeof__(*p) __v; \
160 } *__p = (__typeof__(__p)) (p); \
161 __p->__v = (v); \
162 compiler_barrier(); \
163} while (false)
164
165#else
166
167#define UNALIGNED_PUT(v, p) \
168do { \
169 struct __attribute__((__packed__)) { \
170 __typeof__(*p) __v; \
171 } *__p = (__typeof__(__p)) (p); \
172 __p->__v = (v); \
173} while (false)
174
175#endif
176
177/* Double indirection to ensure section names are expanded before
178 * stringification
179 */
180#define __GENERIC_SECTION(segment) __attribute__((section(STRINGIFY(segment))))
181#define Z_GENERIC_SECTION(segment) __GENERIC_SECTION(segment)
182
183#define __GENERIC_DOT_SECTION(segment) \
184 __attribute__((section("." STRINGIFY(segment))))
185#define Z_GENERIC_DOT_SECTION(segment) __GENERIC_DOT_SECTION(segment)
186
187#define ___in_section(a, b, c) \
188 __attribute__((section("." Z_STRINGIFY(a) \
189 "." Z_STRINGIFY(b) \
190 "." Z_STRINGIFY(c))))
191#define __in_section(a, b, c) ___in_section(a, b, c)
192
193#ifndef __in_section_unique
194#define __in_section_unique(seg) ___in_section(seg, __FILE__, __COUNTER__)
195#endif
196
197#ifndef __in_section_unique_named
198#define __in_section_unique_named(seg, name) \
199 ___in_section(seg, __FILE__, name)
200#endif
201
202/* When using XIP, using '__ramfunc' places a function into RAM instead
203 * of FLASH. Make sure '__ramfunc' is defined only when
204 * CONFIG_ARCH_HAS_RAMFUNC_SUPPORT is defined, so that the compiler can
205 * report an error if '__ramfunc' is used but the architecture does not
206 * support it.
207 */
208#if !defined(CONFIG_XIP)
209#define __ramfunc
210#elif defined(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT)
211#if defined(CONFIG_ARM)
212#if defined(__clang__)
213/* No long_call attribute for Clang.
214 * Rely on linker to place required veneers.
215 * https://github.com/llvm/llvm-project/issues/39969
216 */
217#define __ramfunc __attribute__((noinline)) __attribute__((section(".ramfunc")))
218#else
219/* GCC version */
220#define __ramfunc __attribute__((noinline)) \
221 __attribute__((long_call, section(".ramfunc")))
222#endif
223#else
224#define __ramfunc __attribute__((noinline)) \
225 __attribute__((section(".ramfunc")))
226#endif
227#endif /* !CONFIG_XIP */
228
229#ifndef __fallthrough
230#if __GNUC__ >= 7
231#define __fallthrough __attribute__((fallthrough))
232#else
233#define __fallthrough
234#endif /* __GNUC__ >= 7 */
235#endif
236
237#ifndef __packed
238#define __packed __attribute__((__packed__))
239#endif
240
241#ifndef __aligned
242#define __aligned(x) __attribute__((__aligned__(x)))
243#endif
244
245#ifndef __noinline
246#define __noinline __attribute__((noinline))
247#endif
248
249#define __may_alias __attribute__((__may_alias__))
250
251#ifndef __printf_like
252#ifdef CONFIG_ENFORCE_ZEPHYR_STDINT
253#define __printf_like(f, a) __attribute__((format (printf, f, a)))
254#else
255/*
256 * The Zephyr stdint convention enforces int32_t = int, int64_t = long long,
257 * and intptr_t = long so that short string format length modifiers can be
258 * used universally across ILP32 and LP64 architectures. Without that it
259 * is possible for ILP32 toolchains to have int32_t = long and intptr_t = int
260 * clashing with the Zephyr convention and generating pointless warnings
261 * as they're still the same size. Inhibit the format argument type
262 * validation in that case and let the other configs do it.
263 */
264#define __printf_like(f, a)
265#endif
266#endif
267
268#define __used __attribute__((__used__))
269#define __unused __attribute__((__unused__))
270#define __maybe_unused __attribute__((__unused__))
271
272#ifndef __deprecated
273#define __deprecated __attribute__((deprecated))
274/* When adding this, remember to follow the instructions in
275 * https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html#deprecated
276 */
277#endif
278
279#ifndef __attribute_const__
280#define __attribute_const__ __attribute__((__const__))
281#endif
282
283#ifndef __must_check
284#define __must_check __attribute__((warn_unused_result))
285#endif
286
287#define ARG_UNUSED(x) (void)(x)
288
289#define likely(x) (__builtin_expect((bool)!!(x), true) != 0L)
290#define unlikely(x) (__builtin_expect((bool)!!(x), false) != 0L)
291#define POPCOUNT(x) __builtin_popcount(x)
292
293#ifndef __no_optimization
294#define __no_optimization __attribute__((optimize("-O0")))
295#endif
296
297#ifndef __weak
298#define __weak __attribute__((__weak__))
299#endif
300
301#ifndef __attribute_nonnull
302#define __attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
303#endif
304
305/* Builtins with availability that depend on the compiler version. */
306#if __GNUC__ >= 5
307#define HAS_BUILTIN___builtin_add_overflow 1
308#define HAS_BUILTIN___builtin_sub_overflow 1
309#define HAS_BUILTIN___builtin_mul_overflow 1
310#define HAS_BUILTIN___builtin_div_overflow 1
311#endif
312#if __GNUC__ >= 4
313#define HAS_BUILTIN___builtin_clz 1
314#define HAS_BUILTIN___builtin_clzl 1
315#define HAS_BUILTIN___builtin_clzll 1
316#define HAS_BUILTIN___builtin_ctz 1
317#define HAS_BUILTIN___builtin_ctzl 1
318#define HAS_BUILTIN___builtin_ctzll 1
319#endif
320
321/*
322 * Be *very* careful with these. You cannot filter out __DEPRECATED_MACRO with
323 * -wno-deprecated, which has implications for -Werror.
324 */
325
326/*
327 * Expands to nothing and generates a warning. Used like
328 *
329 * #define FOO __WARN("Please use BAR instead") ...
330 *
331 * The warning points to the location where the macro is expanded.
332 */
333#define __WARN(msg) __WARN1(GCC warning msg)
334#define __WARN1(s) _Pragma(#s)
335
336/* Generic message */
337#ifndef CONFIG_DEPRECATION_TEST
338#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
339/* When adding this, remember to follow the instructions in
340 * https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html#deprecated
341 */
342#else
343#define __DEPRECATED_MACRO
344#endif
345
346/* These macros allow having ARM asm functions callable from thumb */
347
348#if defined(_ASMLANGUAGE)
349
350#if defined(CONFIG_ARM)
351
352#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
353
354#define FUNC_CODE() .thumb;
355#define FUNC_INSTR(a)
356
357#else
358
359#define FUNC_CODE() .code 32;
360#define FUNC_INSTR(a)
361
362#endif /* CONFIG_ASSEMBLER_ISA_THUMB2 */
363
364#else
365
366#define FUNC_CODE()
367#define FUNC_INSTR(a)
368
369#endif /* CONFIG_ARM */
370
371#endif /* _ASMLANGUAGE */
372
373/*
374 * These macros are used to declare assembly language symbols that need
375 * to be typed properly(func or data) to be visible to the OMF tool.
376 * So that the build tool could mark them as an entry point to be linked
377 * correctly. This is an elfism. Use #if 0 for a.out.
378 */
379
380#if defined(_ASMLANGUAGE)
381
382#if defined(CONFIG_ARM) || defined(CONFIG_RISCV) \
383 || defined(CONFIG_XTENSA) || defined(CONFIG_ARM64) \
384 || defined(CONFIG_MIPS) || defined(CONFIG_RX)
385#define GTEXT(sym) .global sym; .type sym, %function
386#define GDATA(sym) .global sym; .type sym, %object
387#define WTEXT(sym) .weak sym; .type sym, %function
388#define WDATA(sym) .weak sym; .type sym, %object
389#elif defined(CONFIG_ARC)
390/*
391 * Need to use assembly macros because ';' is interpreted as the start of
392 * a single line comment in the ARC assembler.
393 */
394
395.macro glbl_text symbol
396 .globl \symbol
397 .type \symbol, %function
398.endm
399
400.macro glbl_data symbol
401 .globl \symbol
402 .type \symbol, %object
403.endm
404
405.macro weak_data symbol
406 .weak \symbol
407 .type \symbol, %object
408.endm
409
410#define GTEXT(sym) glbl_text sym
411#define GDATA(sym) glbl_data sym
412#define WDATA(sym) weak_data sym
413
414#else /* !CONFIG_ARM && !CONFIG_ARC */
415#define GTEXT(sym) .globl sym; .type sym, @function
416#define GDATA(sym) .globl sym; .type sym, @object
417#endif
418
419/*
420 * These macros specify the section in which a given function or variable
421 * resides.
422 *
423 * - SECTION_FUNC allows only one function to reside in a sub-section
424 * - SECTION_SUBSEC_FUNC allows multiple functions to reside in a sub-section
425 * This ensures that garbage collection only discards the section
426 * if all functions in the sub-section are not referenced.
427 */
428
429#if defined(CONFIG_ARC)
430/*
431 * Need to use assembly macros because ';' is interpreted as the start of
432 * a single line comment in the ARC assembler.
433 *
434 * Also, '\‍()' is needed in the .section directive of these macros for
435 * correct substitution of the 'section' variable.
436 */
437
438.macro section_var section, symbol
439 .section .\section\‍().\symbol
440 \symbol :
441.endm
442
443.macro section_func section, symbol
444 .section .\section\().\symbol, "ax"
445 FUNC_CODE()
446 PERFOPT_ALIGN
447 \symbol :
448 FUNC_INSTR(\symbol)
449.endm
450
451.macro section_subsec_func section, subsection, symbol
452 .section .\section\().\subsection, "ax"
453 PERFOPT_ALIGN
454 \symbol :
455.endm
456
457#define SECTION_VAR(sect, sym) section_var sect, sym
458#define SECTION_FUNC(sect, sym) section_func sect, sym
459#define SECTION_SUBSEC_FUNC(sect, subsec, sym) \
460 section_subsec_func sect, subsec, sym
461#else /* !CONFIG_ARC */
462
463#define SECTION_VAR(sect, sym) .section .sect.sym; sym:
464#define SECTION_FUNC(sect, sym) \
465 .section .sect.sym, "ax"; \
466 FUNC_CODE() \
467 PERFOPT_ALIGN; sym : \
468 FUNC_INSTR(sym)
469#define SECTION_SUBSEC_FUNC(sect, subsec, sym) \
470 .section .sect.subsec, "ax"; PERFOPT_ALIGN; sym :
471
472#endif /* CONFIG_ARC */
473
474#endif /* _ASMLANGUAGE */
475
476#if defined(_ASMLANGUAGE)
477#if defined(CONFIG_ARM)
478#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
479/* '.syntax unified' is a gcc-ism used in thumb-2 asm files */
480#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
481#else
482#define _ASM_FILE_PROLOGUE .text; .code 32
483#endif /* CONFIG_ASSEMBLER_ISA_THUMB2 */
484#elif defined(CONFIG_ARM64)
485#define _ASM_FILE_PROLOGUE .text
486#endif /* CONFIG_ARM64 || CONFIG_ARM */
487#endif /* _ASMLANGUAGE */
488
489/*
490 * These macros generate absolute symbols for GCC
491 */
492
493/* create an extern reference to the absolute symbol */
494
495#define GEN_OFFSET_EXTERN(name) extern const char name[]
496
497#define GEN_ABS_SYM_BEGIN(name) \
498 EXTERN_C void name(void); \
499 void name(void) \
500 {
501
502#define GEN_ABS_SYM_END }
503
504/*
505 * Note that GEN_ABSOLUTE_SYM(), depending on the architecture
506 * and toolchain, may restrict the range of values permitted
507 * for assignment to the named symbol.
508 *
509 * For example, on x86, "value" is interpreted as signed
510 * 32-bit integer. Passing in an unsigned 32-bit integer
511 * with MSB set would result in a negative integer.
512 * Moreover, GCC would error out if an integer larger
513 * than 2^32-1 is passed as "value".
514 */
515
516/*
517 * GEN_ABSOLUTE_SYM_KCONFIG() is outputted by the build system
518 * to generate named symbol/value pairs for kconfigs.
519 */
520
521#if defined(CONFIG_ARM)
522
523/*
524 * GNU/ARM backend does not have a proper operand modifier which does not
525 * produces prefix # followed by value, such as %0 for PowerPC, Intel, and
526 * MIPS. The workaround performed here is using %B0 which converts
527 * the value to ~(value). Thus "n"(~(value)) is set in operand constraint
528 * to output (value) in the ARM specific GEN_OFFSET macro.
529 */
530
531#define GEN_ABSOLUTE_SYM(name, value) \
532 __asm__(".globl\t" #name "\n\t.equ\t" #name \
533 ",%B0" \
534 "\n\t.type\t" #name ",%%object" : : "n"(~(value)))
535
536#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
537 __asm__(".globl\t" #name \
538 "\n\t.equ\t" #name "," #value \
539 "\n\t.type\t" #name ",%object")
540
541#elif defined(CONFIG_X86)
542
543#define GEN_ABSOLUTE_SYM(name, value) \
544 __asm__(".globl\t" #name "\n\t.equ\t" #name \
545 ",%c0" \
546 "\n\t.type\t" #name ",@object" : : "n"(value))
547
548#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
549 __asm__(".globl\t" #name \
550 "\n\t.equ\t" #name "," #value \
551 "\n\t.type\t" #name ",@object")
552
553#elif defined(CONFIG_ARC) || defined(CONFIG_ARM64)
554
555#define GEN_ABSOLUTE_SYM(name, value) \
556 __asm__(".globl\t" #name "\n\t.equ\t" #name \
557 ",%c0" \
558 "\n\t.type\t" #name ",@object" : : "n"(value))
559
560#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
561 __asm__(".globl\t" #name \
562 "\n\t.equ\t" #name "," #value \
563 "\n\t.type\t" #name ",@object")
564
565#elif defined(CONFIG_RISCV) || defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)
566
567/* No special prefixes necessary for constants in this arch AFAICT */
568#define GEN_ABSOLUTE_SYM(name, value) \
569 __asm__(".globl\t" #name "\n\t.equ\t" #name \
570 ",%0" \
571 "\n\t.type\t" #name ",%%object" : : "n"(value))
572
573#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
574 __asm__(".globl\t" #name \
575 "\n\t.equ\t" #name "," #value \
576 "\n\t.type\t" #name ",%object")
577
578#elif defined(CONFIG_ARCH_POSIX)
579#define GEN_ABSOLUTE_SYM(name, value) \
580 __asm__(".globl\t" #name "\n\t.equ\t" #name \
581 ",%c0" \
582 "\n\t.type\t" #name ",@object" : : "n"(value))
583
584#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
585 __asm__(".globl\t" #name \
586 "\n\t.equ\t" #name "," #value \
587 "\n\t.type\t" #name ",@object")
588
589#elif defined(CONFIG_SPARC)
590#define GEN_ABSOLUTE_SYM(name, value) \
591 __asm__(".global\t" #name "\n\t.equ\t" #name \
592 ",%0" \
593 "\n\t.type\t" #name ",#object" : : "n"(value))
594
595#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
596 __asm__(".globl\t" #name \
597 "\n\t.equ\t" #name "," #value \
598 "\n\t.type\t" #name ",#object")
599
600#elif defined(CONFIG_RX)
601#define GEN_ABSOLUTE_SYM(name, value) \
602 __asm__(".global\t" #name "\n\t.equ\t" #name \
603 ",%c0" \
604 "\n\t.type\t" #name ",%%object" : : "n"(value))
605
606#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
607 __asm__(".global\t" #name \
608 "\n\t.equ\t" #name "," #value \
609 "\n\t.type\t" #name ",#object")
610
611#else
612#error processor architecture not supported
613#endif
614
615#define compiler_barrier() do { \
616 __asm__ __volatile__ ("" ::: "memory"); \
617} while (false)
618
628#define Z_MAX(a, b) ({ \
629 /* random suffix to avoid naming conflict */ \
630 __typeof__(a) _value_a_ = (a); \
631 __typeof__(b) _value_b_ = (b); \
632 (_value_a_ > _value_b_) ? _value_a_ : _value_b_; \
633 })
634
640#define Z_MIN(a, b) ({ \
641 /* random suffix to avoid naming conflict */ \
642 __typeof__(a) _value_a_ = (a); \
643 __typeof__(b) _value_b_ = (b); \
644 (_value_a_ < _value_b_) ? _value_a_ : _value_b_; \
645 })
646
652#define Z_CLAMP(val, low, high) ({ \
653 /* random suffix to avoid naming conflict */ \
654 __typeof__(val) _value_val_ = (val); \
655 __typeof__(low) _value_low_ = (low); \
656 __typeof__(high) _value_high_ = (high); \
657 (_value_val_ < _value_low_) ? _value_low_ : \
658 (_value_val_ > _value_high_) ? _value_high_ : \
659 _value_val_; \
660 })
661
668#define Z_POW2_CEIL(x) \
669 ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) - 1))))
670
677#define Z_IS_POW2(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
678
679#if defined(CONFIG_ASAN) && defined(__clang__)
680#define __noasan __attribute__((no_sanitize("address")))
681#else
682#define __noasan
683#endif
684
685#if defined(CONFIG_UBSAN)
686#define __noubsan __attribute__((no_sanitize("undefined")))
687#else
688#define __noubsan
689#endif
690
696#if (TOOLCHAIN_GCC_VERSION >= 110000) || \
697 (defined(TOOLCHAIN_CLANG_VERSION) && (TOOLCHAIN_CLANG_VERSION >= 70000))
698#define FUNC_NO_STACK_PROTECTOR __attribute__((no_stack_protector))
699#else
700#define FUNC_NO_STACK_PROTECTOR
701#endif
702
703#endif /* !_LINKER */
704
705#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER "-Waddress-of-packed-member"
706#define TOOLCHAIN_WARNING_ARRAY_BOUNDS "-Warray-bounds"
707#define TOOLCHAIN_WARNING_ATTRIBUTES "-Wattributes"
708#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR "-Wdelete-non-virtual-dtor"
709#define TOOLCHAIN_WARNING_EXTRA "-Wextra"
710#define TOOLCHAIN_WARNING_NONNULL "-Wnonnull"
711#define TOOLCHAIN_WARNING_SHADOW "-Wshadow"
712#define TOOLCHAIN_WARNING_UNUSED_LABEL "-Wunused-label"
713#define TOOLCHAIN_WARNING_UNUSED_VARIABLE "-Wunused-variable"
714
715/* GCC-specific warnings that aren't in clang. */
716#if defined(__GNUC__) && !defined(__clang__)
717#define TOOLCHAIN_WARNING_POINTER_ARITH "-Wpointer-arith"
718#define TOOLCHAIN_WARNING_STRINGOP_OVERREAD "-Wstringop-overread"
719#endif
720
721#define _TOOLCHAIN_DISABLE_WARNING(compiler, warning) \
722 TOOLCHAIN_PRAGMA(compiler diagnostic push) \
723 TOOLCHAIN_PRAGMA(compiler diagnostic ignored warning)
724
725#define _TOOLCHAIN_ENABLE_WARNING(compiler, warning) TOOLCHAIN_PRAGMA(compiler diagnostic pop)
726
727#define TOOLCHAIN_DISABLE_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(GCC, warning)
728#define TOOLCHAIN_ENABLE_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(GCC, warning)
729
730#if defined(__GNUC__) && !defined(__clang__)
731#define TOOLCHAIN_DISABLE_GCC_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(GCC, warning)
732#define TOOLCHAIN_ENABLE_GCC_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(GCC, warning)
733#endif
734
735#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_ */
Common toolchain abstraction.