123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- #ifndef ZEPHYR_INCLUDE_TOOLCHAIN_COMMON_H_
- #define ZEPHYR_INCLUDE_TOOLCHAIN_COMMON_H_
- #ifdef __cplusplus
- #define EXTERN_C extern "C"
- #else
- #define EXTERN_C extern
- #endif
- #ifdef __cplusplus
- #define TASK_ENTRY_CPP extern "C"
- #endif
- #ifdef _ASMLANGUAGE
- #define REQUIRES(sym) .set sym ## _Requires, sym
- #else
- #define REQUIRES(sym) __asm__ (".set " # sym "_Requires, " # sym "\n\t");
- #endif
- #ifdef _ASMLANGUAGE
- #define SECTION .section
- #endif
- #ifdef _ASMLANGUAGE
- #if defined(CONFIG_X86)
- #ifdef PERF_OPT
- #define PERFOPT_ALIGN .balign 16
- #else
- #define PERFOPT_ALIGN .balign 1
- #endif
- #elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
- #define PERFOPT_ALIGN .balign 4
- #elif defined(CONFIG_ARC)
-
- #define PERFOPT_ALIGN .align 4
- #elif defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
- defined(CONFIG_XTENSA)
- #define PERFOPT_ALIGN .balign 4
- #elif defined(CONFIG_ARCH_POSIX)
- #elif defined(CONFIG_SPARC)
- #define PERFOPT_ALIGN .align 4
- #else
- #error Architecture unsupported
- #endif
- #define GC_SECTION(sym) SECTION .text.##sym, "ax"
- #endif
- #if !defined(_ASMLANGUAGE)
- #ifdef CONFIG_COVERAGE
-
- #define ALWAYS_INLINE inline
- #else
- #define ALWAYS_INLINE inline __attribute__((always_inline))
- #endif
- #endif
- #define Z_STRINGIFY(x) #x
- #define STRINGIFY(s) Z_STRINGIFY(s)
- #define _DO_CONCAT(x, y) x ## y
- #define _CONCAT(x, y) _DO_CONCAT(x, y)
- #ifndef ZTEST_UNITTEST
- #define __syscall static inline
- #else
- #define __syscall
- #endif
- #define __subsystem
- #define __net_socket
- #ifndef BUILD_ASSERT
- #define BUILD_ASSERT(EXPR, MSG...) \
- enum _CONCAT(__build_assert_enum, __COUNTER__) { \
- _CONCAT(__build_assert, __COUNTER__) = 1 / !!(EXPR) \
- }
- #endif
- #define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
- #define STRUCT_SECTION_ITERABLE(struct_type, name) \
- Z_DECL_ALIGN(struct struct_type) name \
- __in_section(_##struct_type, static, name) __used
- #define Z_STRUCT_SECTION_ITERABLE(struct_type, name) \
- __DEPRECATED_MACRO \
- STRUCT_SECTION_ITERABLE(struct_type, name)
- #define STRUCT_SECTION_ITERABLE_ALTERNATE(out_type, struct_type, name) \
- Z_DECL_ALIGN(struct struct_type) name \
- __in_section(_##out_type, static, name) __used
- #define Z_STRUCT_SECTION_ITERABLE_ALTERNATE(out_type, struct_type, name) \
- __DEPRECATED_MACRO \
- STRUCT_SECTION_ITERABLE_ALTERNATE(out_type, struct_type, name)
- #define STRUCT_SECTION_FOREACH(struct_type, iterator) \
- extern struct struct_type _CONCAT(_##struct_type, _list_start)[]; \
- extern struct struct_type _CONCAT(_##struct_type, _list_end)[]; \
- for (struct struct_type *iterator = \
- _CONCAT(_##struct_type, _list_start); \
- ({ __ASSERT(iterator <= _CONCAT(_##struct_type, _list_end), \
- "unexpected list end location")
- iterator < _CONCAT(_##struct_type, _list_end); }); \
- iterator++)
- #define Z_STRUCT_SECTION_FOREACH(struct_type, iterator) \
- __DEPRECATED_MACRO \
- STRUCT_SECTION_FOREACH(struct_type, iterator)
-
- #define LOG2CEIL(x) \
- ((((x) <= 4) ? 2 : (((x) <= 8) ? 3 : (((x) <= 16) ? \
- 4 : (((x) <= 32) ? 5 : (((x) <= 64) ? 6 : (((x) <= 128) ? \
- 7 : (((x) <= 256) ? 8 : (((x) <= 512) ? 9 : (((x) <= 1024) ? \
- 10 : (((x) <= 2048) ? 11 : (((x) <= 4096) ? 12 : (((x) <= 8192) ? \
- 13 : (((x) <= 16384) ? 14 : (((x) <= 32768) ? 15:(((x) <= 65536) ? \
- 16 : (((x) <= 131072) ? 17 : (((x) <= 262144) ? 18:(((x) <= 524288) ? \
- 19 : (((x) <= 1048576) ? 20 : (((x) <= 2097152) ? \
- 21 : (((x) <= 4194304) ? 22 : (((x) <= 8388608) ? \
- 23 : (((x) <= 16777216) ? 24 : (((x) <= 33554432) ? \
- 25 : (((x) <= 67108864) ? 26 : (((x) <= 134217728) ? \
- 27 : (((x) <= 268435456) ? 28 : (((x) <= 536870912) ? \
- 29 : (((x) <= 1073741824) ? 30 : (((x) <= 2147483648) ? \
- 31 : 32)))))))))))))))))))))))))))))))
- #endif
|