7#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_IAR_ICCARM_H_
8#define ZEPHYR_INCLUDE_TOOLCHAIN_IAR_ICCARM_H_
20#define TOOLCHAIN_HAS_C_GENERIC 1
22#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
33#ifndef __ORDER_BIG_ENDIAN__
34#define __ORDER_BIG_ENDIAN__ (1)
37#ifndef __ORDER_LITTLE_ENDIAN__
38#define __ORDER_LITTLE_ENDIAN__ (2)
41#ifndef __ORDER_PDP_ENDIAN__
42#define __ORDER_PDP_ENDIAN__ (3)
47#if __LITTLE_ENDIAN__ == 1
48#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
50#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
56#if defined(__cplusplus) && (__cplusplus >= 201103L)
57#define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG)
58#elif defined(__ICCARM__)
59#define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
63#ifdef __STDC_NO_ATOMICS__
64#ifndef __ATOMIC_SEQ_CST
65#define __MEMORY_ORDER_SEQ_CST__ 5
68#ifndef __ATOMIC_SEQ_CST
69#define __ATOMIC_SEQ_CST __MEMORY_ORDER_SEQ_CST__
75#define ZRESTRICT __restrict
87#ifndef CONFIG_COVERAGE
89#define ALWAYS_INLINE \
90 _Pragma("diag_suppress=Go004") inline __attribute__((always_inline))
93#define ALIAS_OF(of) __attribute__((alias(#of)))
95#define FUNC_ALIAS(real_func, new_alias, return_type) \
96 return_type new_alias() ALIAS_OF(real_func)
98#define CODE_UNREACHABLE __builtin_unreachable()
99#define FUNC_NORETURN __attribute__((__noreturn__))
101#define _NODATA_SECTION(segment) __attribute__((section(#segment)))
104#define UNALIGNED_GET(p) \
106 struct __attribute__((__packed__)) { \
107 __typeof__(*(p)) __v; \
108 } *__p = (__typeof__(__p)) (p); \
112#define UNALIGNED_PUT(v, p) \
114 struct __attribute__((__packed__)) { \
115 __typeof__(*p) __v; \
116 } *__p = (__typeof__(__p)) (p); \
124#define __GENERIC_SECTION(segment) __attribute__((section(STRINGIFY(segment))))
125#define Z_GENERIC_SECTION(segment) __GENERIC_SECTION(segment)
127#define __GENERIC_DOT_SECTION(segment) \
128 __attribute__((section("." STRINGIFY(segment))))
129#define Z_GENERIC_DOT_SECTION(segment) __GENERIC_DOT_SECTION(segment)
131#define ___in_section(a, b, c) \
132 __attribute__((section("." Z_STRINGIFY(a) \
134 "." Z_STRINGIFY(c))))
135#define __in_section(a, b, c) ___in_section(a, b, c)
137#define ___in_section_unique(a, b) \
138 __attribute__((section("." Z_STRINGIFY(a) \
140 "." Z_STRINGIFY(b))))
142#define __in_section_unique(seg) ___in_section_unique(seg, __COUNTER__)
144#define __in_section_unique_named(seg, name) ___in_section_unique(seg, name)
152#if !defined(CONFIG_XIP)
154#elif defined(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT)
158#define __ramfunc __attribute__((noinline, section(".ramfunc")))
163#define __fallthrough [[fallthrough]]
167#define __packed __attribute__((__packed__))
171#define __aligned(x) __attribute__((__aligned__(x)))
175#define __noinline __attribute__((noinline))
178#if defined(__cplusplus)
179#define __alignof(x) alignof(x)
181#define __alignof(x) _Alignof(x)
184#define __may_alias __attribute__((__may_alias__))
196#define __printf_like(f, a)
199#define __used __attribute__((__used__))
200#define __unused __attribute__((__unused__))
201#define __maybe_unused __attribute__((__unused__))
204#define __deprecated __attribute__((deprecated))
207#ifndef __deprecated_version
208#define __deprecated_version(version) \
209 __attribute__((deprecated("planned removal in v" #version)))
212#define FUNC_NO_STACK_PROTECTOR _Pragma("no_stack_protect")
214#ifndef __attribute_const__
215#if __VER__ > 0x09000000
216#define __attribute_const__ __attribute__((const))
218#define __attribute_const__
228#define __PRAGMA(...) _Pragma(#__VA_ARGS__)
235#define TOOLCHAIN_PRAGMA_UNROLL(n) __PRAGMA(unroll = n)
237#define ARG_UNUSED(x) (void)(x)
239#define likely(x) (__builtin_expect((bool)!!(x), true) != 0L)
240#define unlikely(x) (__builtin_expect((bool)!!(x), false) != 0L)
241#define POPCOUNT(x) __builtin_popcount(x)
243#ifndef __no_optimization
244#define __no_optimization __PRAGMA(optimize = none)
247#ifndef __attribute_nonnull
248 #define __attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
253#define __weak __attribute__((__weak__))
257#include <intrinsics.h>
272#define __WARN(s) __PRAGMA(message = #s)
273#define __WARN1(s) __PRAGMA(message = #s)
276#if defined(CONFIG_WARN_DEPRECATED)
277#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
279#define __DEPRECATED_MACRO
286#if defined(_ASMLANGUAGE)
288#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
289#define FUNC_CODE() .code 32
292#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
296#define _ASM_FILE_PROLOGUE .text; .code 32
312#define SECTION_VAR(sect, sym)
313#define SECTION_FUNC(sect, sym)
314#define SECTION_SUBSEC_FUNC(sect, subsec, sym)
325#define GEN_OFFSET_EXTERN(name) extern const char name[]
327#define GEN_ABS_SYM_BEGIN(name) \
328 EXTERN_C void name(void); \
332#define GEN_ABS_SYM_END }
339#define GEN_ABSOLUTE_SYM(name, value) \
340 __PRAGMA(public_equ = #name, (unsigned int)value)
346#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
347 __PRAGMA(public_equ = #name, (unsigned int)value)
349#define compiler_barrier() do { \
350 __asm volatile("" ::: "memory"); \
359#define Z_POW2_CEIL(x) \
360 ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) - 1))))
368#define Z_IS_POW2(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
375#define INT8_C(x) __INT8_C(x)
379#define __UINT8_C(x) x ## U
383#define UINT8_C(x) __UINT8_C(x)
387#define __INT16_C(x) x
391#define INT16_C(x) __INT16_C(x)
395#define __UINT16_C(x) x ## U
399#define UINT16_C(x) __UINT16_C(x)
403#define __INT32_C(x) x
407#define INT32_C(x) __INT32_C(x)
411#define __UINT32_C(x) x ## U
415#define UINT32_C(x) __UINT32_C(x)
419#define __INT64_C(x) x ## LL
423#define INT64_C(x) __INT64_C(x)
427#define __UINT64_C(x) x ## ULL
431#define UINT64_C(x) __UINT64_C(x)
437#define _GLUE_B(x, y) x##y
438#define _GLUE(x, y) _GLUE_B(x, y)
441#define INTMAX_C(x) _GLUE(x, __INTMAX_C_SUFFIX__)
445#define UINTMAX_C(x) _GLUE(x, __UINTMAX_C_SUFFIX__)