18#ifndef __USE_COMMON_COMPILER_H__
19#define __USE_COMMON_COMPILER_H__
37#define __END_DEF_REG(__NAME, __BIT_LEN) \
39 reg##__BIT_LEN##_t VALUE; \
42#define DEF_REG __DEF_REG
43#define END_DEF_REG(__NAME, __BIT_LEN) \
44 __END_DEF_REG(__NAME, __BIT_LEN)
46#define DEF_REG8 DEF_REG
47#define END_DEF_REG8(__NAME) END_DEF_REG(__NAME, 8)
48#define DEF_REG16 DEF_REG
49#define END_DEF_REG16(__NAME) END_DEF_REG(__NAME, 16)
50#define DEF_REG32 DEF_REG
51#define END_DEF_REG32(__NAME) END_DEF_REG(__NAME, 32)
56# define __volatile__ volatile
59#undef __IS_COMPILER_SUPPORT_GNUC_EXTENSION__
60#if defined(__GNUC__) || defined(__clang__)
61# define __IS_COMPILER_SUPPORT_GNUC_EXTENSION__ 1
64#ifndef __IS_COMPILER_LLVM__
65# define __IS_COMPILER_LLVM__ 0
68#ifndef __IS_COMPILER_GCC__
69# define __IS_COMPILER_GCC__ 0
72#ifndef __IS_COMPILER_IAR__
73# define __IS_COMPILER_IAR__ 0
76#ifndef __IS_COMPILER_TCC__
77# define __IS_COMPILER_TCC__ 0
80#ifndef MAX_CONSTRUCTOR_PRIORITY
81# if __IS_COMPILER_GCC__
82# define MAX_CONSTRUCTOR_PRIORITY 65535
83# elif __IS_COMPILER_LLVM__
84# define MAX_CONSTRUCTOR_PRIORITY 0xFFFFFFFF
89#if __IS_COMPILER_LLVM__
91# define VSF_CAL_NO_INIT
93# define VSF_CAL_NO_INIT __attribute__((__section__(".bss.noinit")))
95# define VSF_CAL_NO_RETURN __attribute__((__noreturn__))
96# define VSF_CAL_ROOT __attribute__((__used__))
97# define VSF_CAL_INLINE __inline__
98# define VSF_CAL_NO_INLINE __attribute__((__noinline__))
99# define VSF_CAL_ALWAYS_INLINE __inline__ __attribute__((__always_inline__))
100# define VSF_CAL_WEAK(...) __attribute__((__weak__))
102# define VSF_CAL_RAMFUNC Not Supported by Apple LLVM
104# define VSF_CAL_RAMFUNC __attribute__((__section__(".ramfunc")))
106# define __asm__ __asm
107# define __VSF_CAL_ALIGN(__N) __attribute__((__aligned__(__N)))
108# define __VSF_CAL_AT_ADDR(__ADDR) Not Supported by LLVM
110# define __VSF_CAL_SECTION(__SEC_STR)
112# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((__section__(__SEC_STR)))
114# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
115 __asm__(".weak " #__ALIAS); \
116 __asm__(".equ " #__ALIAS ", " #__ORIGIN)
118# define VSF_CAL_PACKED __attribute__((__packed__))
120# undef VSF_CAL_UNALIGNED
121# define VSF_CAL_NAKED __attribute__((naked))
122# define VSF_CAL_TRANSPARENT_UNION __attribute__((__transparent_union__))
123# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
125# define __VSF_CAL_ISR(__VEC) void __VEC(void)
126# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
128#elif __IS_COMPILER_GCC__
129# define VSF_CAL_NO_INIT __attribute__((section(".bss.noinit")))
130# define VSF_CAL_NO_RETURN __attribute__((noreturn))
131# define VSF_CAL_ROOT __attribute__((used))
132# define VSF_CAL_INLINE inline
133# define VSF_CAL_NO_INLINE __attribute__((noinline))
134# define VSF_CAL_ALWAYS_INLINE inline __attribute__((always_inline))
135# define VSF_CAL_WEAK(...) __attribute__((weak))
136# define VSF_CAL_RAMFUNC __attribute__((section(".ramfunc")))
137# define __asm__ __asm
138# define __VSF_CAL_ALIGN(__N) __attribute__((aligned(__N)))
139# define __VSF_CAL_AT_ADDR(__ADDR) Not Supported by GCC
140# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section(__SEC_STR)))
141# define VSF_CAL_SECTION_DECLARE(__SEC) extern void *__start_ ## __SEC;\
142 extern void *__stop_ ## __SEC;
143# define VSF_CAL_SECTION_START(__SEC) __start_ ## __SEC
144# define VSF_CAL_SECTION_END(__SEC) __stop_ ## __SEC
145# define VSF_CAL_SECTION_SIZE(__SEC) (__VSF_CAL_SECTION_END(__SEC) - __VSF_CAL_SECTION_START(__SEC))
146# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
147 __attribute__((weakref(__VSF_STR(__ORIGIN))))
149# define VSF_CAL_PACKED __attribute__((packed))
151# undef VSF_CAL_UNALIGNED
152# define VSF_CAL_NAKED __attribute__((naked))
153# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
154# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
156# define __VSF_CAL_ISR(__VEC) void __VEC(void)
157# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
159#elif __IS_COMPILER_TCC__
160# define VSF_CAL_NO_INIT __attribute__((section( ".bss.noinit")))
161# define VSF_CAL_NO_RETURN __attribute__((noreturn))
162# define VSF_CAL_ROOT __attribute__((used))
163# define VSF_CAL_INLINE inline
164# define VSF_CAL_NO_INLINE __attribute__((noinline))
165# define VSF_CAL_ALWAYS_INLINE inline __attribute__((always_inline))
166# define VSF_CAL_WEAK(...) __attribute__((weak))
167# define __asm__ __asm
168# define __VSF_CAL_ALIGN(__N) __attribute__((aligned (__N)))
169# define __VSF_CAL_AT_ADDR(__ADDR) Not Supported by TCC
170# define __VSF_CAL_SECTION(__SEC_STR)
171# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
172 __attribute__((weakref(__VSF_STR(__ORIGIN))))
174# define VSF_CAL_PACKED __attribute__((packed))
175# define VSF_CAL_UNALIGNED __attribute__((packed))
176# define VSF_CAL_NAKED __attribute__((naked))
177# define VSF_CAL_TRANSPARENT_UNION __attribute__((transparent_union))
178# define __VSF_CAL_ALIGN_OF(...) __alignof__(__VA_ARGS__)
180# define __VSF_CAL_ISR(__VEC) void __VEC(void)
181# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
184#define VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
185 __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS)
186#define VSF_CAL_AT_ADDR(__ADDR) __VSF_CAL_AT_ADDR(__ADDR)
187#define VSF_CAL_ALIGN(__N) __VSF_CAL_ALIGN(__N)
189#define VSF_CAL_SECTION(__SEC_STR) __VSF_CAL_SECTION(__SEC_STR)
191#ifdef __VSF_CAL_WRAPPER
192# define VSF_CAL_WRAPPER(__API) __VSF_CAL_WRAPPER(__API)
195#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
196#define VSF_CAL_ALIGN_OF(__TYPE) __VSF_CAL_ALIGN_OF(__TYPE)
197#define VSF_CAL_ALIGN_WITH(__TYPE) VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__TYPE))
198#define VSF_CAL_ISR(__VECT) __VSF_CAL_ISR(__VECT)
200#define VSF_CAL_ALIGN_OF(...) __VSF_CAL_ALIGN_OF(__VA_ARGS__)
201#define VSF_CAL_ALIGN_WITH(...) VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__VA_ARGS__))
202#define VSF_CAL_ISR(...) __VSF_CAL_ISR(__VA_ARGS__)
209#if defined(__clang__)
210#pragma clang diagnostic ignored "-Wmissing-declarations"
211#pragma clang diagnostic ignored "-Wdeprecated-declarations"
212#pragma clang diagnostic ignored "-Wmicrosoft-anon-tag"
213#pragma clang diagnostic ignored "-Wmissing-braces"
214#pragma clang diagnostic ignored "-Wconstant-conversion"
215#pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
216#pragma clang diagnostic ignored "-Wbuiltin-requires-header"
217#pragma clang diagnostic ignored "-Winitializer-overrides"
218#pragma clang diagnostic ignored "-Wbraced-scalar-init"
219#pragma clang diagnostic ignored "-Wempty-body"
220#pragma clang diagnostic ignored "-Wgnu-empty-struct"
221#pragma clang diagnostic ignored "-Wmicrosoft-include"
222#pragma clang diagnostic ignored "-Wpragma-pack"
223#pragma clang diagnostic ignored "-Wunused-function"
224#pragma clang diagnostic ignored "-Wswitch"
225#pragma clang diagnostic ignored "-Wembedded-directive"
226#pragma clang diagnostic ignored "-Wundef"
227#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
228#pragma clang diagnostic ignored "-Wpadded"
229#pragma clang diagnostic ignored "-Wnewline-eof"
230#pragma clang diagnostic ignored "-Wduplicate-enum"
231#pragma clang diagnostic ignored "-Wextra-semi"
232#pragma clang diagnostic ignored "-Wunknown-warning-option"
233#pragma clang diagnostic ignored "-Wextra-semi-stmt"
234#pragma clang diagnostic ignored "-Wzero-length-array"
235#pragma clang diagnostic ignored "-Wmissing-prototypes"
236#pragma clang diagnostic ignored "-Wimplicit-int-conversion"
237#pragma clang diagnostic ignored "-Wnonportable-include-path"
238#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
239#pragma clang diagnostic ignored "-Wc++-compat"
240#pragma clang diagnostic ignored "-Wsign-conversion"
241#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
242#pragma clang diagnostic ignored "-Wmissing-noreturn"
243#pragma clang diagnostic ignored "-Wcast-qual"
244#pragma clang diagnostic ignored "-Wbad-function-cast"
245#pragma clang diagnostic ignored "-Wswitch-enum"
246#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
247#pragma clang diagnostic ignored "-Wmissing-field-initializers"
248#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
249#pragma clang diagnostic ignored "-Wunused-value"
250#pragma clang diagnostic ignored "-Wbuiltin-requires-header"
251#pragma clang diagnostic ignored "-Wmain-return-type"
252#pragma clang diagnostic ignored "-Wextern-c-compat"
253#pragma clang diagnostic ignored "-Wunused-label"
254#pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
255#pragma clang diagnostic ignored "-Wself-assign"
264#elif __IS_COMPILER_GCC__
266#pragma GCC diagnostic ignored "-Wmissing-declarations"
267#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
268#pragma GCC diagnostic ignored "-Wmissing-braces"
269#pragma GCC diagnostic ignored "-Wempty-body"
270#pragma GCC diagnostic ignored "-Wunused-function"
271#pragma GCC diagnostic ignored "-Wswitch"
272#pragma GCC diagnostic ignored "-Wundef"
273#pragma GCC diagnostic ignored "-Wpadded"
274#pragma GCC diagnostic ignored "-Wsign-conversion"
275#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
276#pragma GCC diagnostic ignored "-Wmissing-noreturn"
277#pragma GCC diagnostic ignored "-Wcast-qual"
278#pragma GCC diagnostic ignored "-Wswitch-enum"
279#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
280#pragma GCC diagnostic ignored "-Wunused-value"
281#pragma GCC diagnostic ignored "-Wcomment"
282#pragma GCC diagnostic ignored "-Wstrict-aliasing"
283#pragma GCC diagnostic ignored "-Wnonnull-compare"
284#pragma GCC diagnostic ignored "-Woverflow"
287# pragma GCC diagnostic ignored "-Wmissing-prototypes"
288# pragma GCC diagnostic ignored "-Wc++-compat"
289# pragma GCC diagnostic ignored "-Wbad-function-cast"
290# pragma GCC diagnostic ignored "-Wint-conversion"
291# pragma GCC diagnostic ignored "-Woverride-init-side-effects"
304#elif __IS_COMPILER_IAR__
307#pragma diag_suppress=Pa082
310#pragma diag_suppress=pe301
313#pragma diag_suppress=pe188
316#pragma diag_suppress=pe381
319#pragma diag_suppress=pa089
322#pragma diag_suppress=pa039
325#pragma diag_suppress=pe231
328#pragma diag_suppress=pe174
331#pragma diag_suppress=pe177
334#pragma diag_suppress=pe618
344#if defined(__VSF_DEBUG__)
345# if defined(__clang__)
346# pragma clang diagnostic warning "-Wcast-align"
347# elif __IS_COMPILER_GCC__
348# pragma GCC diagnostic warning "-Wcast-align"
void vsf_stdio_init(void)