18#ifndef __USE_ARM_COMPILER_H_PART_1__
19#define __USE_ARM_COMPILER_H_PART_1__
29#if defined(__IS_COMPILER_IAR__) && __IS_COMPILER_IAR__
30# include <intrinsics.h>
33#ifndef __VSF_HEADER_ONLY_SHOW_COMPILER_INFO__
36#include "../__common/__compiler.h"
41#if __IS_COMPILER_ARM_COMPILER_5__ \
42 || __IS_COMPILER_ARM_COMPILER_6__
44# ifndef MAX_CONSTRUCTOR_PRIORITY
45# define MAX_CONSTRUCTOR_PRIORITY 65535
47#elif __IS_COMPILER_GCC__
49# undef MAX_CONSTRUCTOR_PRIORITY
50# define MAX_CONSTRUCTOR_PRIORITY 65534
53#ifndef VSF_UTILITIES_REQ___CMSIS_HEADER_FILE__FROM_USR
54#include "cmsis_compiler.h"
56#include VSF_UTILITIES_REQ___CMSIS_HEADER_FILE__FROM_USR
62#ifndef __USE_ARM_COMPILER_H_PART_2__
63#define __USE_ARM_COMPILER_H_PART_2__
70#if __IS_COMPILER_ARM_COMPILER_5__
73#elif __IS_COMPILER_ARM_COMPILER_6__
74#elif __IS_COMPILER_IAR__
75 #pragma language=extended
77 #define __VSF_STDIO_INTERNAL_FILE_NAME __FILE
78#elif __IS_COMPILER_GCC__
81 #define __COMPILER_HAS_NO_NEXTTOWARDF_IN_MATH__
83#elif __IS_COMPILER_LLVM__
85#elif defined(__TMS470__)
87#elif defined(__TASKING__)
90 #warning Not supported compiler type
97#if __IS_COMPILER_ARM_COMPILER_6__
98# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
107 #define NOP() __asm__ __volatile__ ("nop");
113#if __IS_COMPILER_GCC__
114# undef __VSF_CAL_AT_ADDR
115# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((section(".ARM.__at_" #__ADDR)))
116#elif __IS_COMPILER_IAR__
117# define LOW_LEVEL_INIT_RET_T int
118# define VSF_CAL_NO_INIT __no_init
119# define VSF_CAL_NO_RETURN __attribute__((noreturn))
120# define VSF_CAL_ROOT __root
121# define VSF_CAL_INLINE inline
122# define VSF_CAL_NO_INLINE __attribute__((noinline))
123# define VSF_CAL_ALWAYS_INLINE inline __attribute__((always_inline))
124# define VSF_CAL_WEAK(...) __weak
125# define VSF_CAL_RAMFUNC __ramfunc
126# define __asm__ __asm
127# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
128# define __VSF_CAL_AT_ADDR(__ADDR) @ __ADDR
129# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section (__SEC_STR)))
130# define VSF_CAL_SECTION_DECLARE(__SEC)
131# define VSF_CAL_SECTION_START(__SEC) __section_begin(#__SEC)
132# define VSF_CAL_SECTION_END(__SEC) __section_end(#__SEC)
133# define VSF_CAL_SECTION_SIZE(__SEC) __section_size(#__SEC)
134# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
135 _Pragma(__VSF_STR(weak __ORIGIN=__ALIAS))
136# define VSF_CAL_PACKED __attribute__((packed))
137# define VSF_CAL_UNALIGNED __packed
138# define VSF_CAL_NAKED __naked
139# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
140# define __VSF_CAL_ALIGN_OF(...) __ALIGNOF__(__VA_ARGS__)
142# define __IAR_STARTUP_DATA_INIT __iar_data_init3
144# define __VSF_CAL_ISR(__VEC) void __VEC(void)
146#elif __IS_COMPILER_ARM_COMPILER_5__
147# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit"),zero_init) )
148# define VSF_CAL_NO_RETURN __attribute__((noreturn))
149# define VSF_CAL_ROOT __attribute__((used))
150# define VSF_CAL_INLINE __inline
151# define VSF_CAL_NO_INLINE __attribute__((noinline))
152# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
153# define VSF_CAL_WEAK(...) __attribute__((weak))
154# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
155# define __asm__ __asm
156# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
157# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((at(__ADDR)))
158# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section (__SEC_STR)))
159# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
160 __attribute__((weakref(__VSF_STR(__ALIAS))))
162# define VSF_CAL_PACKED __attribute__((packed))
163# define VSF_CAL_UNALIGNED __packed
164# define VSF_CAL_NAKED does AC5 support this?
165# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
166# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
168# define __VSF_CAL_ISR(__VEC) void __VEC(void)
170#elif __IS_COMPILER_ARM_COMPILER_6__
171# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit")) )
172# define VSF_CAL_NO_RETURN __attribute__((noreturn))
173# define VSF_CAL_ROOT __attribute__((used))
174# define VSF_CAL_INLINE __inline
175# define VSF_CAL_NO_INLINE __attribute__((noinline))
176# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
177# define VSF_CAL_WEAK(...) __attribute__((weak))
178# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
179# define __asm__ __asm
180# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
181# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((section (".ARM.__at_" #__ADDR)))
182# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section (__SEC_STR)))
183# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
184 __attribute__((weakref(__VSF_STR(__ALIAS))))
186# define VSF_CAL_PACKED __attribute__((packed))
187# define VSF_CAL_UNALIGNED __unaligned
188# define VSF_CAL_NAKED __attribute__((naked))
189# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
190# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
192# define __VSF_CAL_ISR(__VEC) void __VEC(void)
200#if __IS_COMPILER_IAR__
201# define ENABLE_GLOBAL_INTERRUPT() __enable_interrupt()
203# define ENABLE_GLOBAL_INTERRUPT() __enable_irq()
207#if __IS_COMPILER_IAR__
208# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
210static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
212 uint32_t wPRIMASK = __get_interrupt_state();
213 __disable_interrupt();
217#elif __IS_COMPILER_ARM_COMPILER_5__
218# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
219#elif __IS_COMPILER_ARM_COMPILER_6__ && !defined(__CMSIS_ARMCC_V6_H)
220# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
221#elif __IS_COMPILER_GCC_
222# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
225# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
227static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
233 : [cpsr]
"=r"(cpsr));
238#if __IS_COMPILER_IAR__
239# define GET_GLOBAL_INTERRUPT_STATE() __get_interrupt_state()
240# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_interrupt_state(__STATE)
242#elif __IS_COMPILER_ARM_COMPILER_5__ || __IS_COMPILER_ARM_COMPILER_6__
243# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
244# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
246#elif __IS_COMPILER_GCC__
247# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
248# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
252# define GET_GLOBAL_INTERRUPT_STATE() ____get_PRIMASK()
259VSF_CAL_ALWAYS_INLINE
static inline uint32_t ____get_PRIMASK(
void)
263 __asm__
volatile (
"MRS %0, primask" :
"=r" (result) );
267# define SET_GLOBAL_INTERRUPT_STATE(__STATE) ____set_PRIMASK(__STATE)
274VSF_CAL_ALWAYS_INLINE
static inline void ____set_PRIMASK(
uint32_t priMask)
276 __asm__
volatile (
"MSR primask, %0" : :
"r" (priMask) :
"memory");
283#if __IS_COMPILER_IAR__
285#ifndef __VECTOR_TABLE
286# define __VECTOR_TABLE __vector_table
288#ifndef __VECTOR_TABLE_ATTRIBUTE
289# define __VECTOR_TABLE_ATTRIBUTE @".intvec"
291#ifndef __PROGRAM_START
292# define __PROGRAM_START __iar_program_start
295# define __INITIAL_SP CSTACK$$Limit
298#elif __IS_COMPILER_ARM_COMPILER_6__ || __IS_COMPILER_ARM_COMPILER_5__
300#ifndef __VECTOR_TABLE
301# define __VECTOR_TABLE __Vectors
303#ifndef __VECTOR_TABLE_ATTRIBUTE
304# define __VECTOR_TABLE_ATTRIBUTE ROOT SECTION("RESET")
306#ifndef __PROGRAM_START
307# define __PROGRAM_START __main
310# define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
315#ifndef __PROGRAM_START
316#define __PROGRAM_START __cmsis_start
321#define __INITIAL_SP __StackTop
325#define __STACK_LIMIT __StackLimit
328#ifndef __VECTOR_TABLE
329#define __VECTOR_TABLE __Vectors
332#ifndef __VECTOR_TABLE_ATTRIBUTE
333#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors")))
#define __volatile__
Definition __compiler.h:56
uint32_t vsf_gint_state_t
Definition arm_compiler.h:254
unsigned uint32_t
Definition stdint.h:9