7#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_ICCARM_H_
8#define ZEPHYR_INCLUDE_TOOLCHAIN_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
80#define ALIAS_OF(of) __attribute__((alias(#of)))
82#define FUNC_ALIAS(real_func, new_alias, return_type) \
83 return_type new_alias() ALIAS_OF(real_func)
85#define CODE_UNREACHABLE __builtin_unreachable()
86#define FUNC_NORETURN __attribute__((__noreturn__))
88#define _NODATA_SECTION(segment) __attribute__((section(#segment)))
91#define UNALIGNED_GET(p) \
93 struct __attribute__((__packed__)) { \
94 __typeof__(*(p)) __v; \
95 } *__p = (__typeof__(__p)) (p); \
99#define UNALIGNED_PUT(v, p) \
101 struct __attribute__((__packed__)) { \
102 __typeof__(*p) __v; \
103 } *__p = (__typeof__(__p)) (p); \
111#define __GENERIC_SECTION(segment) __attribute__((section(STRINGIFY(segment))))
112#define Z_GENERIC_SECTION(segment) __GENERIC_SECTION(segment)
114#define __GENERIC_DOT_SECTION(segment) \
115 __attribute__((section("." STRINGIFY(segment))))
116#define Z_GENERIC_DOT_SECTION(segment) __GENERIC_DOT_SECTION(segment)
118#define ___in_section(a, b, c) \
119 __attribute__((section("." Z_STRINGIFY(a) \
121 "." Z_STRINGIFY(c))))
122#define __in_section(a, b, c) ___in_section(a, b, c)
124#define __in_section_unique(seg) ___in_section(seg, __FILE__, __COUNTER__)
126#define __in_section_unique_named(seg, name) \
127 ___in_section(seg, __FILE__, name)
135#if !defined(CONFIG_XIP)
137#elif defined(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT)
141#define __ramfunc __attribute__((noinline, section(".ramfunc")))
146#define __fallthrough [[fallthrough]]
150#define __packed __attribute__((__packed__))
154#define __aligned(x) __attribute__((__aligned__(x)))
158#define __noinline __attribute__((noinline))
161#if defined(__cplusplus)
162#define __alignof(x) alignof(x)
164#define __alignof(x) _Alignof(x)
167#define __may_alias __attribute__((__may_alias__))
179#define __printf_like(f, a)
182#define __used __attribute__((__used__))
183#define __unused __attribute__((__unused__))
184#define __maybe_unused __attribute__((__unused__))
187#define __deprecated __attribute__((deprecated))
190#ifndef __deprecated_version
191#define __deprecated_version(version) \
192 __attribute__((deprecated("planned removal in v" #version)))
195#define FUNC_NO_STACK_PROTECTOR _Pragma("no_stack_protect")
197#ifndef __attribute_const__
198#if __VER__ > 0x09000000
199#define __attribute_const__ __attribute__((const))
201#define __attribute_const__
211#define __PRAGMA(...) _Pragma(#__VA_ARGS__)
212#define ARG_UNUSED(x) (void)(x)
214#define likely(x) (__builtin_expect((bool)!!(x), true) != 0L)
215#define unlikely(x) (__builtin_expect((bool)!!(x), false) != 0L)
216#define POPCOUNT(x) __builtin_popcount(x)
218#ifndef __no_optimization
219#define __no_optimization __PRAGMA(optimize = none)
222#ifndef __attribute_nonnull
223 #define __attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
228#define __weak __attribute__((__weak__))
232#include <intrinsics.h>
247#define __WARN(s) __PRAGMA(message = #s)
248#define __WARN1(s) __PRAGMA(message = #s)
251#ifndef CONFIG_DEPRECATION_TEST
252#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
254#define __DEPRECATED_MACRO
261#if defined(_ASMLANGUAGE)
263#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
264#define FUNC_CODE() .code 32
267#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
271#define _ASM_FILE_PROLOGUE .text; .code 32
287#define SECTION_VAR(sect, sym)
288#define SECTION_FUNC(sect, sym)
289#define SECTION_SUBSEC_FUNC(sect, subsec, sym)
300#define GEN_OFFSET_EXTERN(name) extern const char name[]
302#define GEN_ABS_SYM_BEGIN(name) \
303 EXTERN_C void name(void); \
307#define GEN_ABS_SYM_END }
314#define GEN_ABSOLUTE_SYM(name, value) \
315 __PRAGMA(public_equ = #name, (unsigned int)value)
321#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
322 __PRAGMA(public_equ = #name, (unsigned int)value)
324#define compiler_barrier() do { \
325 __asm volatile("" ::: "memory"); \
334#define Z_POW2_CEIL(x) \
335 ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) - 1))))
343#define Z_IS_POW2(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
350#define INT8_C(x) __INT8_C(x)
354#define __UINT8_C(x) x ## U
358#define UINT8_C(x) __UINT8_C(x)
362#define __INT16_C(x) x
366#define INT16_C(x) __INT16_C(x)
370#define __UINT16_C(x) x ## U
374#define UINT16_C(x) __UINT16_C(x)
378#define __INT32_C(x) x
382#define INT32_C(x) __INT32_C(x)
386#define __UINT32_C(x) x ## U
390#define UINT32_C(x) __UINT32_C(x)
394#define __INT64_C(x) x ## LL
398#define INT64_C(x) __INT64_C(x)
402#define __UINT64_C(x) x ## ULL
406#define UINT64_C(x) __UINT64_C(x)
412#define _GLUE_B(x, y) x##y
413#define _GLUE(x, y) _GLUE_B(x, y)
416#define INTMAX_C(x) _GLUE(x, __INTMAX_C_SUFFIX__)
420#define UINTMAX_C(x) _GLUE(x, __UINTMAX_C_SUFFIX__)