/**************************************************************************//**
 * @item     CosyOS-III Kernel
 * @file     os_cmsis.h
 * @brief    CMSIS compiler specific defines
 * @author   迟凯峰
 * @version  v3.0.0
 * @date     2026.07.21
 ******************************************************************************/

#ifndef __OS_CMSIS_H
#define __OS_CMSIS_H

/*
 * Keil C51
 */
#if   defined ( __C51__ )

  #ifndef   __WEAK
    #define __WEAK
  #endif
  #ifndef   __NOP
    #define __NOP _nop_
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE static
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X) X = X
  #endif


/*
 * Keil C251
 */
#elif defined ( __C251__ )

  #ifndef   __WEAK
    #define __WEAK
  #endif
  #ifndef   __NOP
    #define __NOP _nop_
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE static
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X) void *p_##X = (void *)X
  #endif


/*
 * Arm Compiler 4/5
 */
#elif defined ( __CC_ARM )

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               __inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static __inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   static __forceinline
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __attribute__((weak))
  #endif
  #ifndef   __ALIGNED
    #define __ALIGNED(x)                           __attribute__((aligned(x)))
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             __attribute__((noinline))
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X)                            (void)X
  #endif


/*
 * Arm Compiler 6.6 LTM / above 6.10.1 (armclang)
 */
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               __inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static __inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static __inline
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __attribute__((weak))
  #endif
  #ifndef   __ALIGNED
    #define __ALIGNED(x)                           __attribute__((aligned(x)))
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             __attribute__((noinline))
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X)                            (void)X
  #endif


/*
 * GNU Compiler
 */
#elif defined ( __GNUC__ )

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static inline
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __attribute__((weak))
  #endif
  #ifndef   __ALIGNED
    #define __ALIGNED(x)                           __attribute__((aligned(x)))
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             __attribute__((noinline))
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X)                            (void)X
  #endif


/*
 * IAR Compiler
 */
#elif defined ( __ICCARM__ )

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static inline
  #endif
  #ifndef   __FORCEINLINE
    #define __FORCEINLINE                          _Pragma("inline=forced")
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __FORCEINLINE __STATIC_INLINE
  #endif
  #ifndef   __WEAK
    #if (__VER__ >= 8000000)
    #define __WEAK                                 __attribute__((weak))
    #else
    #define __WEAK                                 _Pragma("__weak")
    #endif
  #endif
  #ifndef   __ALIGNED
    #if (__VER__ >= 7080000)/* If Version < V8, Needs IAR language extensions */
    #define __ALIGNED(x)                           __attribute__((aligned(x)))
    #else
    #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
    #define __ALIGNED(x)
    #endif
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             //_Pragma("optimize = no_inline")
  #endif
  #ifndef   __UNUSED
    #define __UNUSED(X)                            (void)X
  #endif


/*
 * TI Arm Compiler
 */
#elif defined ( __TI_ARM__ )

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __STATIC_INLINE
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __attribute__((weak))
  #endif
  #ifndef   __ALIGNED
    #define __ALIGNED(x)                           __attribute__((aligned(x)))
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             
  #endif


/*
 * TASKING Compiler
 */
#elif defined ( __TASKING__ )

  #ifndef   __ASM
    #define __ASM                                  __asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __STATIC_INLINE
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __attribute__((weak))
  #endif
  #ifndef   __ALIGNED
    #define __ALIGNED(x)                           __align(x)
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             
  #endif


/*
 * COSMIC Compiler
 */
#elif defined ( __CSMC__ )

 #ifndef    __ASM
    #define __ASM                                  _asm
  #endif
  #ifndef   __INLINE
    #define __INLINE                               inline
  #endif
  #ifndef   __STATIC_INLINE
    #define __STATIC_INLINE                        static inline
  #endif
  #ifndef   __STATIC_FORCEINLINE
    #define __STATIC_FORCEINLINE                   __STATIC_INLINE
  #endif
  #ifndef   __WEAK
    #define __WEAK                                 __weak
  #endif
  #ifndef   __ALIGNED
    #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
    #define __ALIGNED(x)
  #endif
  #ifndef   __NOINLINE
    #define __NOINLINE                             
  #endif


/*
 * Unknown Compiler
 */
#else

    #error Unknown compiler.
#endif


#endif
