VSF Documented
__compiler.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __USE_COMMON_COMPILER_H__
19#define __USE_COMMON_COMPILER_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26
27#include "vsf_cfg.h"
28
29/*============================ MACROS ========================================*/
30
31#ifndef __REG_MACRO__
32#define __REG_MACRO__
33
34#define __DEF_REG \
35 union { \
36 struct {
37#define __END_DEF_REG(__NAME, __BIT_LEN) \
38 }; \
39 reg##__BIT_LEN##_t VALUE; \
40 } __NAME;
41
42#define DEF_REG __DEF_REG
43#define END_DEF_REG(__NAME, __BIT_LEN) \
44 __END_DEF_REG(__NAME, __BIT_LEN)
45
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)
52
53#endif // __REG_MACRO__
54
55#ifndef __volatile__
56# define __volatile__ volatile
57#endif
58
59#undef __IS_COMPILER_SUPPORT_GNUC_EXTENSION__
60#if defined(__GNUC__) || defined(__clang__)
61# define __IS_COMPILER_SUPPORT_GNUC_EXTENSION__ 1
62#endif
63
64#ifndef __IS_COMPILER_LLVM__
65# define __IS_COMPILER_LLVM__ 0
66#endif
67
68#ifndef __IS_COMPILER_GCC__
69# define __IS_COMPILER_GCC__ 0
70#endif
71
72#ifndef __IS_COMPILER_IAR__
73# define __IS_COMPILER_IAR__ 0
74#endif
75
76#ifndef __IS_COMPILER_TCC__
77# define __IS_COMPILER_TCC__ 0
78#endif
79
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
85# endif
86#endif
87
89#if __IS_COMPILER_LLVM__
90# ifdef __APPLE__
91# define VSF_CAL_NO_INIT
92# else
93# define VSF_CAL_NO_INIT __attribute__((__section__(".bss.noinit")))
94# endif
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__))
101# ifdef __APPLE__
102# define VSF_CAL_RAMFUNC Not Supported by Apple LLVM
103# else
104# define VSF_CAL_RAMFUNC __attribute__((__section__(".ramfunc")))
105# endif
106# define __asm__ __asm
107# define __VSF_CAL_ALIGN(__N) __attribute__((__aligned__(__N)))
108# define __VSF_CAL_AT_ADDR(__ADDR) Not Supported by LLVM
109# ifdef __APPLE__
110# define __VSF_CAL_SECTION(__SEC_STR)
111# else
112# define __VSF_CAL_SECTION(__SEC_STR) __attribute__((__section__(__SEC_STR)))
113# endif
114# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
115 __asm__(".weak " #__ALIAS); \
116 __asm__(".equ " #__ALIAS ", " #__ORIGIN)
117
118# define VSF_CAL_PACKED __attribute__((__packed__))
119//# define VSF_CAL_UNALIGNED __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__)
124
125# define __VSF_CAL_ISR(__VEC) void __VEC(void)
126# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
127
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))))
148
149# define VSF_CAL_PACKED __attribute__((packed))
150//# define VSF_CAL_UNALIGNED __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__)
155
156# define __VSF_CAL_ISR(__VEC) void __VEC(void)
157# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
158
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))))
173
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__)
179
180# define __VSF_CAL_ISR(__VEC) void __VEC(void)
181# define __VSF_CAL_WRAPPER(__API) __wrap_ ## __API
182#endif
183
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)
188
189#define VSF_CAL_SECTION(__SEC_STR) __VSF_CAL_SECTION(__SEC_STR)
190
191#ifdef __VSF_CAL_WRAPPER
192# define VSF_CAL_WRAPPER(__API) __VSF_CAL_WRAPPER(__API)
193#endif
194
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)
199#else
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__)
203#endif
204
205
206/*----------------------------------------------------------------------------*
207 * Warning Mitigation *
208 *----------------------------------------------------------------------------*/
209#if defined(__clang__) //__IS_COMPILER_LLVM__
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"
257//#pragma clang diagnostic ignored "-Wbitfield-constant-conversion"
258//#pragma clang diagnostic ignored "-Wpointer-integer-compare"
259
260//#pragma clang diagnostic ignored "-Wno-sometimes-uninitialized"
261//#pragma clang diagnostic ignored "-Wdeprecated-declarations"
262//#pragma clang diagnostic ignored "-Wunused-variable"
263
264#elif __IS_COMPILER_GCC__
265
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"
285
286#ifndef __cplusplus
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"
292#else
293
294#endif
295
297//#pragma GCC diagnostic ignored "-Wbitfield-constant-conversion"
298//#pragma GCC diagnostic ignored "-Wpointer-integer-compare"
299//
300//#pragma GCC diagnostic ignored "-Wno-sometimes-uninitialized"
301//#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
302//#pragma GCC diagnostic ignored "-Wunused-variable"
303
304#elif __IS_COMPILER_IAR__
305
307#pragma diag_suppress=Pa082
308
310#pragma diag_suppress=pe301
311
313#pragma diag_suppress=pe188
314
316#pragma diag_suppress=pe381
317
319#pragma diag_suppress=pa089
320
322#pragma diag_suppress=pa039
323
325#pragma diag_suppress=pe231
326
328#pragma diag_suppress=pe174
329
331#pragma diag_suppress=pe177
332
334#pragma diag_suppress=pe618
335
336//,Pe186,Pe111,,pe128,,,Pe1866,Pe064,Pa039
337
338#endif
339
340/*----------------------------------------------------------------------------*
341 * Warning Emphasize *
342 *----------------------------------------------------------------------------*/
343
344#if defined(__VSF_DEBUG__)
345# if defined(__clang__) //__IS_COMPILER_LLVM__
346# pragma clang diagnostic warning "-Wcast-align"
347# elif __IS_COMPILER_GCC__
348# pragma GCC diagnostic warning "-Wcast-align"
349# endif
350#endif
351
352/*----------------------------------------------------------------------------*
353 * Signal & Interrupt Definition *
354 *----------------------------------------------------------------------------*/
355
356/*----------------------------------------------------------------------------*
357 * Startup Source Code *
358 *----------------------------------------------------------------------------*/
359
360/*============================ TYPES =========================================*/
361/*============================ INCLUDES ======================================*/
362/*============================ PROTOTYPES ====================================*/
363
364extern void vsf_stdio_init(void);
365
366#ifdef __cplusplus
367}
368#endif
369
370#endif
void vsf_stdio_init(void)
Generated from commit: vsfteam/vsf@377865b