123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- #ifndef _COMPILER_ABSTRACTION_H
- #define _COMPILER_ABSTRACTION_H
- #ifndef NRF_STRING_CONCATENATE_IMPL
- #define NRF_STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs
- #endif
- #ifndef NRF_STRING_CONCATENATE
- #define NRF_STRING_CONCATENATE(lhs, rhs) NRF_STRING_CONCATENATE_IMPL(lhs, rhs)
- #endif
- #if __LINT__ == 1
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg)
- #endif
- #endif
- #if defined ( __CC_ARM )
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE __inline
- #endif
- #ifndef __WEAK
- #define __WEAK __weak
- #endif
- #ifndef __ALIGN
- #define __ALIGN(n) __align(n)
- #endif
- #ifndef __PACKED
- #define __PACKED __packed
- #endif
- #ifndef __UNUSED
- #define __UNUSED __attribute__((unused))
- #endif
- #define GET_SP() __current_sp()
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg) \
- ;enum { NRF_STRING_CONCATENATE(static_assert_on_line_, __LINE__) = 1 / (!!(cond)) }
- #endif
-
- #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE __inline
- #endif
- #ifndef __WEAK
- #define __WEAK __attribute__((weak))
- #endif
- #ifndef __ALIGN
- #define __ALIGN(n) __attribute__((aligned(n)))
- #endif
- #ifndef __PACKED
- #define __PACKED __attribute__((packed, aligned(1)))
- #endif
- #ifndef __UNUSED
- #define __UNUSED __attribute__((unused))
- #endif
- #define GET_SP() __current_sp()
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
- #endif
- #elif defined ( __ICCARM__ )
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE inline
- #endif
- #ifndef __WEAK
- #define __WEAK __weak
- #endif
- #ifndef __ALIGN
- #define STRING_PRAGMA(x) _Pragma(#x)
- #define __ALIGN(n) STRING_PRAGMA(data_alignment = n)
- #endif
- #ifndef __PACKED
- #define __PACKED __packed
- #endif
- #ifndef __UNUSED
- #define __UNUSED
- #endif
-
- #define GET_SP() __get_SP()
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
- #endif
- #elif defined ( __GNUC__ ) || defined ( __clang__ )
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE inline
- #endif
- #ifndef __WEAK
- #define __WEAK __attribute__((weak))
- #endif
- #ifndef __ALIGN
- #define __ALIGN(n) __attribute__((aligned(n)))
- #endif
- #ifndef __PACKED
- #define __PACKED __attribute__((packed))
- #endif
- #ifndef __UNUSED
- #define __UNUSED __attribute__((unused))
- #endif
- #define GET_SP() gcc_current_sp()
- static inline unsigned int gcc_current_sp(void)
- {
- unsigned int stack_pointer = 0;
- __asm__ __volatile__ ("mov %0, sp" : "=r"(stack_pointer));
- return stack_pointer;
- }
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
- #endif
- #elif defined ( __TASKING__ )
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE inline
- #endif
- #ifndef __WEAK
- #define __WEAK __attribute__((weak))
- #endif
- #ifndef __ALIGN
- #define __ALIGN(n) __align(n)
- #endif
-
-
- #ifndef __PACKED
- #define __PACKED
- #endif
- #ifndef __UNUSED
- #define __UNUSED __attribute__((unused))
- #endif
- #define GET_SP() __get_MSP()
- #ifndef NRF_STATIC_ASSERT
- #define NRF_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
- #endif
- #endif
- #define NRF_MDK_VERSION_ASSERT_AT_LEAST(major, minor, micro) \
- NRF_STATIC_ASSERT( \
- ( \
- (major < MDK_MAJOR_VERSION) || \
- (major == MDK_MAJOR_VERSION && minor < MDK_MINOR_VERSION) || \
- (major == MDK_MAJOR_VERSION && minor == MDK_MINOR_VERSION && micro < MDK_MICRO_VERSION) \
- ), "MDK version mismatch.")
- #define NRF_MDK_VERSION_ASSERT_EXACT(major, minor, micro) \
- NRF_STATIC_ASSERT( \
- ( \
- (major != MDK_MAJOR_VERSION) || \
- (major != MDK_MAJOR_VERSION) || \
- (major != MDK_MAJOR_VERSION) \
- ), "MDK version mismatch.")
- #endif
|