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
76#elif __IS_COMPILER_GCC__
78#elif __IS_COMPILER_LLVM__
80#elif defined(__TMS470__)
82#elif defined(__TASKING__)
85 #warning Not supported compiler type
92#if __IS_COMPILER_ARM_COMPILER_6__
93# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
102 #define NOP() __asm__ __volatile__ ("nop");
107#if __IS_COMPILER_IAR__
108# define LOW_LEVEL_INIT_RET_T int
109# define VSF_CAL_NO_INIT __no_init
110# define VSF_CAL_NO_RETURN __attribute__((noreturn))
111# define VSF_CAL_ROOT __root
112# define VSF_CAL_INLINE inline
113# define VSF_CAL_NO_INLINE __attribute__((noinline))
114# define VSF_CAL_ALWAYS_INLINE inline __attribute__((always_inline))
115# define VSF_CAL_WEAK(...) __weak
116# define VSF_CAL_RAMFUNC __ramfunc
117# define __asm__ __asm
118# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
119# define __VSF_CAL_AT_ADDR(__ADDR) @ __ADDR
120# define __VSF_CAL_SECTION(__SEC) __attribute__((section (__SEC)))
121# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
122 _Pragma(__VSF_STR(weak __ORIGIN=__ALIAS))
123# define VSF_CAL_PACKED __attribute__((packed))
124# define VSF_CAL_UNALIGNED __packed
125# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
126# define __VSF_CAL_ALIGN_OF(...) __ALIGNOF__(__VA_ARGS__)
128# define __IAR_STARTUP_DATA_INIT __iar_data_init3
130# define __VSF_CAL_ISR(__VEC) void __VEC(void)
132#elif __IS_COMPILER_ARM_COMPILER_5__
133# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit"),zero_init) )
134# define VSF_CAL_NO_RETURN __attribute__((noreturn))
135# define VSF_CAL_ROOT __attribute__((used))
136# define VSF_CAL_INLINE __inline
137# define VSF_CAL_NO_INLINE __attribute__((noinline))
138# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
139# define VSF_CAL_WEAK(...) __attribute__((weak))
140# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
141# define __asm__ __asm
142# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
143# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((at(__ADDR)))
144# define __VSF_CAL_SECTION(__SEC) __attribute__((section (__SEC)))
145# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
146 __attribute__((weakref(__VSF_STR(__ALIAS))))
148# define VSF_CAL_PACKED __attribute__((packed))
149# define VSF_CAL_UNALIGNED __packed
150# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
151# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
153# define __VSF_CAL_ISR(__VEC) void __VEC(void)
155#elif __IS_COMPILER_ARM_COMPILER_6__
156# define VSF_CAL_NO_INIT __attribute__( ( section( ".bss.noinit")) )
157# define VSF_CAL_NO_RETURN __attribute__((noreturn))
158# define VSF_CAL_ROOT __attribute__((used))
159# define VSF_CAL_INLINE __inline
160# define VSF_CAL_NO_INLINE __attribute__((noinline))
161# define VSF_CAL_ALWAYS_INLINE __inline __attribute__((always_inline))
162# define VSF_CAL_WEAK(...) __attribute__((weak))
163# define VSF_CAL_RAMFUNC __attribute__((section (".textrw")))
164# define __asm__ __asm
165# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
166# define __VSF_CAL_AT_ADDR(__ADDR) __attribute__((section (".ARM.__at_" #__ADDR)))
167# define __VSF_CAL_SECTION(__SEC) __attribute__((section (__SEC)))
168# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
169 __attribute__((weakref(__VSF_STR(__ALIAS))))
171# define VSF_CAL_PACKED __attribute__((packed))
172# define VSF_CAL_UNALIGNED __unaligned
173# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
174# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
176# define __VSF_CAL_ISR(__VEC) void __VEC(void)
184#if __IS_COMPILER_IAR__
185# define ENABLE_GLOBAL_INTERRUPT() __enable_interrupt()
187# define ENABLE_GLOBAL_INTERRUPT() __enable_irq()
191#if __IS_COMPILER_IAR__
192# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
194static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
196 uint32_t wPRIMASK = __get_interrupt_state();
197 __disable_interrupt();
201#elif __IS_COMPILER_ARM_COMPILER_5__
202# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
203#elif __IS_COMPILER_ARM_COMPILER_6__ && !defined(__CMSIS_ARMCC_V6_H)
204# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
205#elif __IS_COMPILER_GCC_
206# define DISABLE_GLOBAL_INTERRUPT() __disable_irq()
209# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
211static VSF_CAL_ALWAYS_INLINE
uint32_t ____disable_irq(
void)
217 : [cpsr]
"=r"(cpsr));
222#if __IS_COMPILER_IAR__
223# define GET_GLOBAL_INTERRUPT_STATE() __get_interrupt_state()
224# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_interrupt_state(__STATE)
226#elif __IS_COMPILER_ARM_COMPILER_5__ || __IS_COMPILER_ARM_COMPILER_6__
227# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
228# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
230#elif __IS_COMPILER_GCC__
231# define GET_GLOBAL_INTERRUPT_STATE() __get_PRIMASK()
232# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_PRIMASK(__STATE)
236# define GET_GLOBAL_INTERRUPT_STATE() ____get_PRIMASK()
243VSF_CAL_ALWAYS_INLINE
static inline uint32_t ____get_PRIMASK(
void)
247 __asm__
volatile (
"MRS %0, primask" :
"=r" (result) );
251# define SET_GLOBAL_INTERRUPT_STATE(__STATE) ____set_PRIMASK(__STATE)
258VSF_CAL_ALWAYS_INLINE
static inline void ____set_PRIMASK(
uint32_t priMask)
260 __asm__
volatile (
"MSR primask, %0" : :
"r" (priMask) :
"memory");
267#if __IS_COMPILER_IAR__
269#ifndef __VECTOR_TABLE
270# define __VECTOR_TABLE __vector_table
272#ifndef __VECTOR_TABLE_ATTRIBUTE
273# define __VECTOR_TABLE_ATTRIBUTE @".intvec"
275#ifndef __PROGRAM_START
276# define __PROGRAM_START __iar_program_start
279# define __INITIAL_SP CSTACK$$Limit
282#elif __IS_COMPILER_ARM_COMPILER_6__ || __IS_COMPILER_ARM_COMPILER_5__
284#ifndef __VECTOR_TABLE
285# define __VECTOR_TABLE __Vectors
287#ifndef __VECTOR_TABLE_ATTRIBUTE
288# define __VECTOR_TABLE_ATTRIBUTE ROOT SECTION("RESET")
290#ifndef __PROGRAM_START
291# define __PROGRAM_START __main
294# define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
299#ifndef __PROGRAM_START
300#define __PROGRAM_START __cmsis_start
305#define __INITIAL_SP __StackTop
309#define __STACK_LIMIT __StackLimit
312#ifndef __VECTOR_TABLE
313#define __VECTOR_TABLE __Vectors
316#ifndef __VECTOR_TABLE_ATTRIBUTE
317#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors")))
#define __volatile__
Definition __compiler.h:56
uint32_t vsf_gint_state_t
Definition arm_compiler.h:238
unsigned uint32_t
Definition stdint.h:9