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#define FUNC_NO_STACK_PROTECTOR _Pragma("no_stack_protect")
192#ifndef __attribute_const__
193#if __VER__ > 0x09000000
194#define __attribute_const__ __attribute__((const))
196#define __attribute_const__
206#define __PRAGMA(...) _Pragma(#__VA_ARGS__)
207#define ARG_UNUSED(x) (void)(x)
209#define likely(x) (__builtin_expect((bool)!!(x), true) != 0L)
210#define unlikely(x) (__builtin_expect((bool)!!(x), false) != 0L)
211#define POPCOUNT(x) __builtin_popcount(x)
213#ifndef __no_optimization
214#define __no_optimization __PRAGMA(optimize = none)
217#ifndef __attribute_nonnull
218 #define __attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
223#define __weak __attribute__((__weak__))
227#include <intrinsics.h>
242#define __WARN(s) __PRAGMA(message = #s)
243#define __WARN1(s) __PRAGMA(message = #s)
246#ifndef CONFIG_DEPRECATION_TEST
247#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
249#define __DEPRECATED_MACRO
256#if defined(_ASMLANGUAGE)
258#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
259#define FUNC_CODE() .code 32
262#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
266#define _ASM_FILE_PROLOGUE .text; .code 32
282#define SECTION_VAR(sect, sym)
283#define SECTION_FUNC(sect, sym)
284#define SECTION_SUBSEC_FUNC(sect, subsec, sym)
295#define GEN_OFFSET_EXTERN(name) extern const char name[]
297#define GEN_ABS_SYM_BEGIN(name) \
298 EXTERN_C void name(void); \
302#define GEN_ABS_SYM_END }
309#define GEN_ABSOLUTE_SYM(name, value) \
310 __PRAGMA(public_equ = #name, (unsigned int)value)
316#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
317 __PRAGMA(public_equ = #name, (unsigned int)value)
319#define compiler_barrier() do { \
320 __asm volatile("" ::: "memory"); \
332#define Z_MAX(a, b) ({ \
334 __typeof__(a) _value_a_ = (a); \
335 __typeof__(b) _value_b_ = (b); \
336 _value_a_ > _value_b_ ? _value_a_ : _value_b_; \
344#define Z_MIN(a, b) ({ \
346 __typeof__(a) _value_a_ = (a); \
347 __typeof__(b) _value_b_ = (b); \
348 _value_a_ < _value_b_ ? _value_a_ : _value_b_; \
356#define Z_CLAMP(val, low, high) ({ \
358 __typeof__(val) _value_val_ = (val); \
359 __typeof__(low) _value_low_ = (low); \
360 __typeof__(high) _value_high_ = (high); \
361 (_value_val_ < _value_low_) ? _value_low_ : \
362 (_value_val_ > _value_high_) ? _value_high_ : \
372#define Z_POW2_CEIL(x) \
373 ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) - 1))))
381#define Z_IS_POW2(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
388#define INT8_C(x) __INT8_C(x)
392#define __UINT8_C(x) x ## U
396#define UINT8_C(x) __UINT8_C(x)
400#define __INT16_C(x) x
404#define INT16_C(x) __INT16_C(x)
408#define __UINT16_C(x) x ## U
412#define UINT16_C(x) __UINT16_C(x)
416#define __INT32_C(x) x
420#define INT32_C(x) __INT32_C(x)
424#define __UINT32_C(x) x ## U
428#define UINT32_C(x) __UINT32_C(x)
432#define __INT64_C(x) x ## LL
436#define INT64_C(x) __INT64_C(x)
440#define __UINT64_C(x) x ## ULL
444#define UINT64_C(x) __UINT64_C(x)
450#define _GLUE_B(x, y) x##y
451#define _GLUE(x, y) _GLUE_B(x, y)
454#define INTMAX_C(x) _GLUE(x, __INTMAX_C_SUFFIX__)
458#define UINTMAX_C(x) _GLUE(x, __UINTMAX_C_SUFFIX__)