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__)) 
  121#   define VSF_CAL_TRANSPARENT_UNION    __attribute__((__transparent_union__)) 
  122#   define __VSF_CAL_ALIGN_OF(...)      __alignof__(__VA_ARGS__) 
  124#   define __VSF_CAL_ISR(__VEC)         void __VEC(void) 
  125#   define __VSF_CAL_WRAPPER(__API)     __wrap_ ## __API 
  127#elif  __IS_COMPILER_GCC__ 
  128#   define VSF_CAL_NO_INIT              __attribute__((section(".bss.noinit"))) 
  129#   define VSF_CAL_NO_RETURN            __attribute__((noreturn)) 
  130#   define VSF_CAL_ROOT                 __attribute__((used)) 
  131#   define VSF_CAL_INLINE               inline 
  132#   define VSF_CAL_NO_INLINE            __attribute__((noinline)) 
  133#   define VSF_CAL_ALWAYS_INLINE        inline __attribute__((always_inline)) 
  134#   define VSF_CAL_WEAK(...)            __attribute__((weak)) 
  135#   define VSF_CAL_RAMFUNC              __attribute__((section(".ramfunc"))) 
  136#   define __asm__                      __asm 
  137#   define __VSF_CAL_ALIGN(__N)         __attribute__((aligned(__N))) 
  138#   define __VSF_CAL_AT_ADDR(__ADDR)    Not Supported by GCC 
  139#   define __VSF_CAL_SECTION(__SEC_STR) __attribute__((section(__SEC_STR))) 
  140#   define VSF_CAL_SECTION_DECLARE(__SEC)   extern void *__start_ ## __SEC;\ 
  141                                            extern void *__stop_ ## __SEC; 
  142#   define VSF_CAL_SECTION_START(__SEC) __start_ ## __SEC 
  143#   define VSF_CAL_SECTION_END(__SEC)   __stop_ ## __SEC 
  144#   define VSF_CAL_SECTION_SIZE(__SEC)    (__VSF_CAL_SECTION_END(__SEC) - __VSF_CAL_SECTION_START(__SEC)) 
  145#   define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \ 
  146                                        __attribute__((weakref(__VSF_STR(__ORIGIN)))) 
  148#   define VSF_CAL_PACKED               __attribute__((packed)) 
  150#   undef VSF_CAL_UNALIGNED                                              
  151#   define VSF_CAL_TRANSPARENT_UNION    __attribute__((transparent_union)) 
  152#   define __VSF_CAL_ALIGN_OF(...)      __alignof__(__VA_ARGS__) 
  154#   define __VSF_CAL_ISR(__VEC)         void __VEC(void) 
  155#   define __VSF_CAL_WRAPPER(__API)     __wrap_ ## __API 
  157#elif  __IS_COMPILER_TCC__ 
  158#   define VSF_CAL_NO_INIT              __attribute__((section( ".bss.noinit"))) 
  159#   define VSF_CAL_NO_RETURN            __attribute__((noreturn)) 
  160#   define VSF_CAL_ROOT                 __attribute__((used)) 
  161#   define VSF_CAL_INLINE               inline 
  162#   define VSF_CAL_NO_INLINE            __attribute__((noinline)) 
  163#   define VSF_CAL_ALWAYS_INLINE        inline __attribute__((always_inline)) 
  164#   define VSF_CAL_WEAK(...)            __attribute__((weak)) 
  165#   define __asm__                      __asm 
  166#   define __VSF_CAL_ALIGN(__N)         __attribute__((aligned (__N))) 
  167#   define __VSF_CAL_AT_ADDR(__ADDR)    Not Supported by TCC 
  168#   define __VSF_CAL_SECTION(__SEC_STR) 
  169#   define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \ 
  170                                        __attribute__((weakref(__VSF_STR(__ORIGIN)))) 
  172#   define VSF_CAL_PACKED               __attribute__((packed)) 
  173#   define VSF_CAL_UNALIGNED            __attribute__((packed)) 
  174#   define VSF_CAL_TRANSPARENT_UNION    __attribute__((transparent_union)) 
  175#   define __VSF_CAL_ALIGN_OF(...)      __alignof__(__VA_ARGS__) 
  177#   define __VSF_CAL_ISR(__VEC)         void __VEC(void) 
  178#   define __VSF_CAL_WRAPPER(__API)     __wrap_ ## __API 
  181#define VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS)                                   \ 
  182                                        __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) 
  183#define VSF_CAL_AT_ADDR(__ADDR)         __VSF_CAL_AT_ADDR(__ADDR) 
  184#define VSF_CAL_ALIGN(__N)              __VSF_CAL_ALIGN(__N) 
  186#define VSF_CAL_SECTION(__SEC_STR)      __VSF_CAL_SECTION(__SEC_STR) 
  188#ifdef __VSF_CAL_WRAPPER 
  189#   define VSF_CAL_WRAPPER(__API)      __VSF_CAL_WRAPPER(__API) 
  192#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus) 
  193#define VSF_CAL_ALIGN_OF(__TYPE)        __VSF_CAL_ALIGN_OF(__TYPE) 
  194#define VSF_CAL_ALIGN_WITH(__TYPE)      VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__TYPE)) 
  195#define VSF_CAL_ISR(__VECT)             __VSF_CAL_ISR(__VECT) 
  197#define VSF_CAL_ALIGN_OF(...)           __VSF_CAL_ALIGN_OF(__VA_ARGS__) 
  198#define VSF_CAL_ALIGN_WITH(...)         VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__VA_ARGS__)) 
  199#define VSF_CAL_ISR(...)                __VSF_CAL_ISR(__VA_ARGS__) 
  206#if defined(__clang__)  
  207#pragma clang diagnostic ignored "-Wmissing-declarations" 
  208#pragma clang diagnostic ignored "-Wdeprecated-declarations" 
  209#pragma clang diagnostic ignored "-Wmicrosoft-anon-tag" 
  210#pragma clang diagnostic ignored "-Wmissing-braces" 
  211#pragma clang diagnostic ignored "-Wconstant-conversion" 
  212#pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference" 
  213#pragma clang diagnostic ignored "-Wbuiltin-requires-header" 
  214#pragma clang diagnostic ignored "-Winitializer-overrides" 
  215#pragma clang diagnostic ignored "-Wbraced-scalar-init" 
  216#pragma clang diagnostic ignored "-Wempty-body" 
  217#pragma clang diagnostic ignored "-Wgnu-empty-struct" 
  218#pragma clang diagnostic ignored "-Wmicrosoft-include" 
  219#pragma clang diagnostic ignored "-Wpragma-pack" 
  220#pragma clang diagnostic ignored "-Wunused-function" 
  221#pragma clang diagnostic ignored "-Wswitch" 
  222#pragma clang diagnostic ignored "-Wembedded-directive" 
  223#pragma clang diagnostic ignored "-Wundef" 
  224#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" 
  225#pragma clang diagnostic ignored "-Wpadded" 
  226#pragma clang diagnostic ignored "-Wnewline-eof" 
  227#pragma clang diagnostic ignored "-Wduplicate-enum" 
  228#pragma clang diagnostic ignored "-Wextra-semi" 
  229#pragma clang diagnostic ignored "-Wunknown-warning-option" 
  230#pragma clang diagnostic ignored "-Wextra-semi-stmt" 
  231#pragma clang diagnostic ignored "-Wzero-length-array" 
  232#pragma clang diagnostic ignored "-Wmissing-prototypes" 
  233#pragma clang diagnostic ignored "-Wimplicit-int-conversion" 
  234#pragma clang diagnostic ignored "-Wnonportable-include-path" 
  235#pragma clang diagnostic ignored "-Wmissing-variable-declarations" 
  236#pragma clang diagnostic ignored "-Wc++-compat" 
  237#pragma clang diagnostic ignored "-Wsign-conversion" 
  238#pragma clang diagnostic ignored "-Wimplicit-fallthrough" 
  239#pragma clang diagnostic ignored "-Wmissing-noreturn" 
  240#pragma clang diagnostic ignored "-Wcast-qual" 
  241#pragma clang diagnostic ignored "-Wbad-function-cast" 
  242#pragma clang diagnostic ignored "-Wswitch-enum" 
  243#pragma clang diagnostic ignored "-Wdisabled-macro-expansion" 
  244#pragma clang diagnostic ignored "-Wmissing-field-initializers" 
  245#pragma clang diagnostic ignored "-Wtautological-pointer-compare" 
  246#pragma clang diagnostic ignored "-Wunused-value" 
  247#pragma clang diagnostic ignored "-Wbuiltin-requires-header" 
  248#pragma clang diagnostic ignored "-Wmain-return-type" 
  249#pragma clang diagnostic ignored "-Wextern-c-compat" 
  250#pragma clang diagnostic ignored "-Wunused-label" 
  251#pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end" 
  252#pragma clang diagnostic ignored "-Wself-assign" 
  261#elif __IS_COMPILER_GCC__ 
  263#pragma GCC diagnostic ignored "-Wmissing-declarations" 
  264#pragma GCC diagnostic ignored "-Wdeprecated-declarations" 
  265#pragma GCC diagnostic ignored "-Wmissing-braces" 
  266#pragma GCC diagnostic ignored "-Wempty-body" 
  267#pragma GCC diagnostic ignored "-Wunused-function" 
  268#pragma GCC diagnostic ignored "-Wswitch" 
  269#pragma GCC diagnostic ignored "-Wundef" 
  270#pragma GCC diagnostic ignored "-Wpadded" 
  271#pragma GCC diagnostic ignored "-Wsign-conversion" 
  272#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" 
  273#pragma GCC diagnostic ignored "-Wmissing-noreturn" 
  274#pragma GCC diagnostic ignored "-Wcast-qual" 
  275#pragma GCC diagnostic ignored "-Wswitch-enum" 
  276#pragma GCC diagnostic ignored "-Wmissing-field-initializers" 
  277#pragma GCC diagnostic ignored "-Wunused-value" 
  278#pragma GCC diagnostic ignored "-Wcomment" 
  279#pragma GCC diagnostic ignored "-Wstrict-aliasing" 
  280#pragma GCC diagnostic ignored "-Wnonnull-compare" 
  281#pragma GCC diagnostic ignored "-Woverflow" 
  284#   pragma GCC diagnostic ignored "-Wmissing-prototypes" 
  285#   pragma GCC diagnostic ignored "-Wc++-compat" 
  286#   pragma GCC diagnostic ignored "-Wbad-function-cast" 
  287#   pragma GCC diagnostic ignored "-Wint-conversion" 
  288#   pragma GCC diagnostic ignored "-Woverride-init-side-effects" 
  301#elif __IS_COMPILER_IAR__ 
  304#pragma diag_suppress=Pa082 
  307#pragma diag_suppress=pe301 
  310#pragma diag_suppress=pe188 
  313#pragma diag_suppress=pe381 
  316#pragma diag_suppress=pa089 
  319#pragma diag_suppress=pa039 
  322#pragma diag_suppress=pe231 
  325#pragma diag_suppress=pe174 
  328#pragma diag_suppress=pe177 
  331#pragma diag_suppress=pe618 
  341#if defined(__VSF_DEBUG__) 
  342#   if defined(__clang__)  
  343#       pragma clang diagnostic warning "-Wcast-align" 
  344#   elif __IS_COMPILER_GCC__ 
  345#       pragma GCC diagnostic warning "-Wcast-align" 
void vsf_stdio_init(void)