Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:02

0001 /**************************************************************************//**
0002  * @file     cmsis_compiler.h
0003  * @brief    CMSIS compiler generic header file
0004  * @version  V5.3.0
0005  * @date     04. April 2023
0006  ******************************************************************************/
0007 /*
0008  * Copyright (c) 2009-2023 Arm Limited. All rights reserved.
0009  *
0010  * SPDX-License-Identifier: Apache-2.0
0011  *
0012  * Licensed under the Apache License, Version 2.0 (the License); you may
0013  * not use this file except in compliance with the License.
0014  * You may obtain a copy of the License at
0015  *
0016  * www.apache.org/licenses/LICENSE-2.0
0017  *
0018  * Unless required by applicable law or agreed to in writing, software
0019  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
0020  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0021  * See the License for the specific language governing permissions and
0022  * limitations under the License.
0023  */
0024 
0025 #ifndef __CMSIS_COMPILER_H
0026 #define __CMSIS_COMPILER_H
0027 
0028 #include <stdint.h>
0029 
0030 /*
0031  * Arm Compiler 4/5
0032  */
0033 #if   defined ( __CC_ARM )
0034   #include "cmsis_armcc.h"
0035 
0036 
0037 /*
0038  * Arm Compiler 6.6 LTM (armclang)
0039  */
0040 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
0041   #include "cmsis_armclang_ltm.h"
0042 
0043   /*
0044  * Arm Compiler above 6.10.1 (armclang)
0045  */
0046 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
0047   #include "cmsis_armclang.h"
0048 
0049 /*
0050  * TI Arm Clang Compiler (tiarmclang)
0051  */
0052 #elif defined (__ti__)
0053   #include "cmsis_tiarmclang.h"
0054 
0055 /*
0056  * GNU Compiler
0057  */
0058 #elif defined ( __GNUC__ )
0059   #include "cmsis_gcc.h"
0060 
0061 
0062 /*
0063  * IAR Compiler
0064  */
0065 #elif defined ( __ICCARM__ )
0066   #include <cmsis_iccarm.h>
0067 
0068 
0069 /*
0070  * TI Arm Compiler (armcl)
0071  */
0072 #elif defined ( __TI_ARM__ )
0073   #include <cmsis_ccs.h>
0074 
0075   #ifndef   __ASM
0076     #define __ASM                                  __asm
0077   #endif
0078   #ifndef   __INLINE
0079     #define __INLINE                               inline
0080   #endif
0081   #ifndef   __STATIC_INLINE
0082     #define __STATIC_INLINE                        static inline
0083   #endif
0084   #ifndef   __STATIC_FORCEINLINE
0085     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
0086   #endif
0087   #ifndef   __NO_RETURN
0088     #define __NO_RETURN                            __attribute__((noreturn))
0089   #endif
0090   #ifndef   __USED
0091     #define __USED                                 __attribute__((used))
0092   #endif
0093   #ifndef   __WEAK
0094     #define __WEAK                                 __attribute__((weak))
0095   #endif
0096   #ifndef   __PACKED
0097     #define __PACKED                               __attribute__((packed))
0098   #endif
0099   #ifndef   __PACKED_STRUCT
0100     #define __PACKED_STRUCT                        struct __attribute__((packed))
0101   #endif
0102   #ifndef   __PACKED_UNION
0103     #define __PACKED_UNION                         union __attribute__((packed))
0104   #endif
0105   #ifndef   __UNALIGNED_UINT32        /* deprecated */
0106     struct __attribute__((packed)) T_UINT32 { uint32_t v; };
0107     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
0108   #endif
0109   #ifndef   __UNALIGNED_UINT16_WRITE
0110     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
0111     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
0112   #endif
0113   #ifndef   __UNALIGNED_UINT16_READ
0114     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
0115     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
0116   #endif
0117   #ifndef   __UNALIGNED_UINT32_WRITE
0118     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
0119     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
0120   #endif
0121   #ifndef   __UNALIGNED_UINT32_READ
0122     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
0123     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
0124   #endif
0125   #ifndef   __ALIGNED
0126     #define __ALIGNED(x)                           __attribute__((aligned(x)))
0127   #endif
0128   #ifndef   __RESTRICT
0129     #define __RESTRICT                             __restrict
0130   #endif
0131   #ifndef   __COMPILER_BARRIER
0132     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
0133     #define __COMPILER_BARRIER()                   (void)0
0134   #endif
0135   #ifndef __NO_INIT
0136     #define __NO_INIT                              __attribute__ ((section (".bss.noinit")))
0137   #endif
0138   #ifndef __ALIAS
0139     #define __ALIAS(x)                             __attribute__ ((alias(x)))
0140   #endif
0141 
0142 /*
0143  * TASKING Compiler
0144  */
0145 #elif defined ( __TASKING__ )
0146   /*
0147    * The CMSIS functions have been implemented as intrinsics in the compiler.
0148    * Please use "carm -?i" to get an up to date list of all intrinsics,
0149    * Including the CMSIS ones.
0150    */
0151 
0152   #ifndef   __ASM
0153     #define __ASM                                  __asm
0154   #endif
0155   #ifndef   __INLINE
0156     #define __INLINE                               inline
0157   #endif
0158   #ifndef   __STATIC_INLINE
0159     #define __STATIC_INLINE                        static inline
0160   #endif
0161   #ifndef   __STATIC_FORCEINLINE
0162     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
0163   #endif
0164   #ifndef   __NO_RETURN
0165     #define __NO_RETURN                            __attribute__((noreturn))
0166   #endif
0167   #ifndef   __USED
0168     #define __USED                                 __attribute__((used))
0169   #endif
0170   #ifndef   __WEAK
0171     #define __WEAK                                 __attribute__((weak))
0172   #endif
0173   #ifndef   __PACKED
0174     #define __PACKED                               __packed__
0175   #endif
0176   #ifndef   __PACKED_STRUCT
0177     #define __PACKED_STRUCT                        struct __packed__
0178   #endif
0179   #ifndef   __PACKED_UNION
0180     #define __PACKED_UNION                         union __packed__
0181   #endif
0182   #ifndef   __UNALIGNED_UINT32        /* deprecated */
0183     struct __packed__ T_UINT32 { uint32_t v; };
0184     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
0185   #endif
0186   #ifndef   __UNALIGNED_UINT16_WRITE
0187     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
0188     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
0189   #endif
0190   #ifndef   __UNALIGNED_UINT16_READ
0191     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
0192     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
0193   #endif
0194   #ifndef   __UNALIGNED_UINT32_WRITE
0195     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
0196     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
0197   #endif
0198   #ifndef   __UNALIGNED_UINT32_READ
0199     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
0200     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
0201   #endif
0202   #ifndef   __ALIGNED
0203     #define __ALIGNED(x)              __align(x)
0204   #endif
0205   #ifndef   __RESTRICT
0206     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
0207     #define __RESTRICT
0208   #endif
0209   #ifndef   __COMPILER_BARRIER
0210     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
0211     #define __COMPILER_BARRIER()                   (void)0
0212   #endif
0213   #ifndef __NO_INIT
0214     #define __NO_INIT                              __attribute__ ((section (".bss.noinit")))
0215   #endif
0216   #ifndef __ALIAS
0217     #define __ALIAS(x)                             __attribute__ ((alias(x)))
0218   #endif
0219 
0220 /*
0221  * COSMIC Compiler
0222  */
0223 #elif defined ( __CSMC__ )
0224    #include <cmsis_csm.h>
0225 
0226  #ifndef   __ASM
0227     #define __ASM                                  _asm
0228   #endif
0229   #ifndef   __INLINE
0230     #define __INLINE                               inline
0231   #endif
0232   #ifndef   __STATIC_INLINE
0233     #define __STATIC_INLINE                        static inline
0234   #endif
0235   #ifndef   __STATIC_FORCEINLINE
0236     #define __STATIC_FORCEINLINE                   __STATIC_INLINE
0237   #endif
0238   #ifndef   __NO_RETURN
0239     // NO RETURN is automatically detected hence no warning here
0240     #define __NO_RETURN
0241   #endif
0242   #ifndef   __USED
0243     #warning No compiler specific solution for __USED. __USED is ignored.
0244     #define __USED
0245   #endif
0246   #ifndef   __WEAK
0247     #define __WEAK                                 __weak
0248   #endif
0249   #ifndef   __PACKED
0250     #define __PACKED                               @packed
0251   #endif
0252   #ifndef   __PACKED_STRUCT
0253     #define __PACKED_STRUCT                        @packed struct
0254   #endif
0255   #ifndef   __PACKED_UNION
0256     #define __PACKED_UNION                         @packed union
0257   #endif
0258   #ifndef   __UNALIGNED_UINT32        /* deprecated */
0259     @packed struct T_UINT32 { uint32_t v; };
0260     #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
0261   #endif
0262   #ifndef   __UNALIGNED_UINT16_WRITE
0263     __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
0264     #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
0265   #endif
0266   #ifndef   __UNALIGNED_UINT16_READ
0267     __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
0268     #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
0269   #endif
0270   #ifndef   __UNALIGNED_UINT32_WRITE
0271     __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
0272     #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
0273   #endif
0274   #ifndef   __UNALIGNED_UINT32_READ
0275     __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
0276     #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
0277   #endif
0278   #ifndef   __ALIGNED
0279     #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
0280     #define __ALIGNED(x)
0281   #endif
0282   #ifndef   __RESTRICT
0283     #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
0284     #define __RESTRICT
0285   #endif
0286   #ifndef   __COMPILER_BARRIER
0287     #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
0288     #define __COMPILER_BARRIER()                   (void)0
0289   #endif
0290   #ifndef __NO_INIT
0291     #define __NO_INIT                              __attribute__ ((section (".bss.noinit")))
0292   #endif
0293   #ifndef __ALIAS
0294     #define __ALIAS(x)                             __attribute__ ((alias(x)))
0295   #endif
0296 
0297 #else
0298   #error Unknown compiler.
0299 #endif
0300 
0301 
0302 #endif /* __CMSIS_COMPILER_H */
0303