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(a, b) \
125 __attribute__((section("." Z_STRINGIFY(a) \
127 "." Z_STRINGIFY(b))))
129#define __in_section_unique(seg) ___in_section_unique(seg, __COUNTER__)
131#define __in_section_unique_named(seg, name) ___in_section_unique(seg, name)
139#if !defined(CONFIG_XIP)
141#elif defined(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT)
145#define __ramfunc __attribute__((noinline, section(".ramfunc")))
150#define __fallthrough [[fallthrough]]
154#define __packed __attribute__((__packed__))
158#define __aligned(x) __attribute__((__aligned__(x)))
162#define __noinline __attribute__((noinline))
165#if defined(__cplusplus)
166#define __alignof(x) alignof(x)
168#define __alignof(x) _Alignof(x)
171#define __may_alias __attribute__((__may_alias__))
183#define __printf_like(f, a)
186#define __used __attribute__((__used__))
187#define __unused __attribute__((__unused__))
188#define __maybe_unused __attribute__((__unused__))
191#define __deprecated __attribute__((deprecated))
194#ifndef __deprecated_version
195#define __deprecated_version(version) \
196 __attribute__((deprecated("planned removal in v" #version)))
199#define FUNC_NO_STACK_PROTECTOR _Pragma("no_stack_protect")
201#ifndef __attribute_const__
202#if __VER__ > 0x09000000
203#define __attribute_const__ __attribute__((const))
205#define __attribute_const__
215#define __PRAGMA(...) _Pragma(#__VA_ARGS__)
216#define ARG_UNUSED(x) (void)(x)
218#define likely(x) (__builtin_expect((bool)!!(x), true) != 0L)
219#define unlikely(x) (__builtin_expect((bool)!!(x), false) != 0L)
220#define POPCOUNT(x) __builtin_popcount(x)
222#ifndef __no_optimization
223#define __no_optimization __PRAGMA(optimize = none)
226#ifndef __attribute_nonnull
227 #define __attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
232#define __weak __attribute__((__weak__))
236#include <intrinsics.h>
251#define __WARN(s) __PRAGMA(message = #s)
252#define __WARN1(s) __PRAGMA(message = #s)
255#if !(defined(CONFIG_DEPRECATION_TEST) || !defined(CONFIG_WARN_DEPRECATED))
256#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
258#define __DEPRECATED_MACRO
265#if defined(_ASMLANGUAGE)
267#if defined(CONFIG_ASSEMBLER_ISA_THUMB2)
268#define FUNC_CODE() .code 32
271#define _ASM_FILE_PROLOGUE .text; .syntax unified; .thumb
275#define _ASM_FILE_PROLOGUE .text; .code 32
291#define SECTION_VAR(sect, sym)
292#define SECTION_FUNC(sect, sym)
293#define SECTION_SUBSEC_FUNC(sect, subsec, sym)
304#define GEN_OFFSET_EXTERN(name) extern const char name[]
306#define GEN_ABS_SYM_BEGIN(name) \
307 EXTERN_C void name(void); \
311#define GEN_ABS_SYM_END }
318#define GEN_ABSOLUTE_SYM(name, value) \
319 __PRAGMA(public_equ = #name, (unsigned int)value)
325#define GEN_ABSOLUTE_SYM_KCONFIG(name, value) \
326 __PRAGMA(public_equ = #name, (unsigned int)value)
328#define compiler_barrier() do { \
329 __asm volatile("" ::: "memory"); \
338#define Z_POW2_CEIL(x) \
339 ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) - 1))))
347#define Z_IS_POW2(x) (((x) != 0) && (((x) & ((x)-1)) == 0))
354#define INT8_C(x) __INT8_C(x)
358#define __UINT8_C(x) x ## U
362#define UINT8_C(x) __UINT8_C(x)
366#define __INT16_C(x) x
370#define INT16_C(x) __INT16_C(x)
374#define __UINT16_C(x) x ## U
378#define UINT16_C(x) __UINT16_C(x)
382#define __INT32_C(x) x
386#define INT32_C(x) __INT32_C(x)
390#define __UINT32_C(x) x ## U
394#define UINT32_C(x) __UINT32_C(x)
398#define __INT64_C(x) x ## LL
402#define INT64_C(x) __INT64_C(x)
406#define __UINT64_C(x) x ## ULL
410#define UINT64_C(x) __UINT64_C(x)
416#define _GLUE_B(x, y) x##y
417#define _GLUE(x, y) _GLUE_B(x, y)
420#define INTMAX_C(x) _GLUE(x, __INTMAX_C_SUFFIX__)
424#define UINTMAX_C(x) _GLUE(x, __UINTMAX_C_SUFFIX__)