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_TRANSPARENT_UNION __attribute__((transparent_union))
139# define __VSF_CAL_ALIGN_OF(...) __ALIGNOF__(__VA_ARGS__)
141# define __IAR_STARTUP_DATA_INIT __iar_data_init3
143# define __VSF_CAL_ISR(__VEC) void __VEC(void)
145#elif __IS_COMPILER_ARM_COMPILER_5__
146# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit"),zero_init) )
147# define VSF_CAL_NO_RETURN __attribute__((noreturn))
148# define VSF_CAL_ROOT __attribute__((used))
149# define VSF_CAL_INLINE __inline
150# define VSF_CAL_NO_INLINE __attribute__((noinline))
151# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
152# define VSF_CAL_WEAK(...) __attribute__((weak))
153# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
154# define __asm__ __asm
155# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
156# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((at(__ADDR)))
157# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section (__SEC_STR)))
158# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
159 __attribute__((weakref(__VSF_STR(__ALIAS))))
161# define VSF_CAL_PACKED __attribute__((packed))
162# define VSF_CAL_UNALIGNED __packed
163# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
164# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
166# define __VSF_CAL_ISR(__VEC) void __VEC(void)
168#elif __IS_COMPILER_ARM_COMPILER_6__
169# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit")) )
170# define VSF_CAL_NO_RETURN __attribute__((noreturn))
171# define VSF_CAL_ROOT __attribute__((used))
172# define VSF_CAL_INLINE __inline
173# define VSF_CAL_NO_INLINE __attribute__((noinline))
174# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
175# define VSF_CAL_WEAK(...) __attribute__((weak))
176# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
177# define __asm__ __asm
178# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
179# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((section (".ARM.__at_" #__ADDR)))
180# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section (__SEC_STR)))
181# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
182 __attribute__((weakref(__VSF_STR(__ALIAS))))
184# define VSF_CAL_PACKED __attribute__((packed))
185# define VSF_CAL_UNALIGNED __unaligned
186# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
187# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
189# define __VSF_CAL_ISR(__VEC) void __VEC(void)
197#if __IS_COMPILER_IAR__
198# define ENABLE_GLOBAL_INTERRUPT() __enable_interrupt()
200# define ENABLE_GLOBAL_INTERRUPT() __enable_irq()
204#if __IS_COMPILER_IAR__
205# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
207static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
209 uint32_t wPRIMASK = __get_interrupt_state();
210 __disable_interrupt();
214#elif __IS_COMPILER_ARM_COMPILER_5__
215# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
216#elif __IS_COMPILER_ARM_COMPILER_6__ && !defined(__CMSIS_ARMCC_V6_H)
217# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
218#elif __IS_COMPILER_GCC_
219# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
222# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
224static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
230 : [cpsr]
"=r"(cpsr));
235#if __IS_COMPILER_IAR__
236# define GET_GLOBAL_INTERRUPT_STATE() __get_interrupt_state()
237# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_interrupt_state(__STATE)
239#elif __IS_COMPILER_ARM_COMPILER_5__ || __IS_COMPILER_ARM_COMPILER_6__
240# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
241# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
243#elif __IS_COMPILER_GCC__
244# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
245# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
249# define GET_GLOBAL_INTERRUPT_STATE() ____get_PRIMASK()
256VSF_CAL_ALWAYS_INLINE
static inline uint32_t ____get_PRIMASK(
void)
260 __asm__
volatile (
"MRS %0, primask" :
"=r" (result) );
264# define SET_GLOBAL_INTERRUPT_STATE(__STATE) ____set_PRIMASK(__STATE)
271VSF_CAL_ALWAYS_INLINE
static inline void ____set_PRIMASK(
uint32_t priMask)
273 __asm__
volatile (
"MSR primask, %0" : :
"r" (priMask) :
"memory");
280#if __IS_COMPILER_IAR__
282#ifndef __VECTOR_TABLE
283# define __VECTOR_TABLE __vector_table
285#ifndef __VECTOR_TABLE_ATTRIBUTE
286# define __VECTOR_TABLE_ATTRIBUTE @".intvec"
288#ifndef __PROGRAM_START
289# define __PROGRAM_START __iar_program_start
292# define __INITIAL_SP CSTACK$$Limit
295#elif __IS_COMPILER_ARM_COMPILER_6__ || __IS_COMPILER_ARM_COMPILER_5__
297#ifndef __VECTOR_TABLE
298# define __VECTOR_TABLE __Vectors
300#ifndef __VECTOR_TABLE_ATTRIBUTE
301# define __VECTOR_TABLE_ATTRIBUTE ROOT SECTION("RESET")
303#ifndef __PROGRAM_START
304# define __PROGRAM_START __main
307# define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
312#ifndef __PROGRAM_START
313#define __PROGRAM_START __cmsis_start
318#define __INITIAL_SP __StackTop
322#define __STACK_LIMIT __StackLimit
325#ifndef __VECTOR_TABLE
326#define __VECTOR_TABLE __Vectors
329#ifndef __VECTOR_TABLE_ATTRIBUTE
330#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors")))
#define __volatile__
Definition __compiler.h:56
uint32_t vsf_gint_state_t
Definition arm_compiler.h:251
unsigned uint32_t
Definition stdint.h:9