RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
rtcompiler.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2024, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2024-01-18 Shell Separate the compiler porting from rtdef.h
9 */
10#ifndef __RT_COMPILER_H__
11#define __RT_COMPILER_H__
12
13#include <rtconfig.h>
14
15#if defined(__ARMCC_VERSION) /* ARM Compiler */
16#define rt_section(x) __attribute__((section(x)))
17#define rt_used __attribute__((used))
18#define rt_align(n) __attribute__((aligned(n)))
19#if __ARMCC_VERSION >= 6010050
20#define rt_packed(declare) declare __attribute__((packed))
21#else
22#define rt_packed(declare) declare
23#endif
24#define rt_weak __attribute__((weak))
25#define rt_typeof typeof
26#define rt_noreturn
27#define rt_inline static __inline
28#define rt_always_inline rt_inline
29#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
30#define rt_section(x) @ x
31#define rt_used __root
32#define PRAGMA(x) _Pragma(#x)
33#define rt_align(n) PRAGMA(data_alignment=n)
34#define rt_packed(declare) declare
35#define rt_weak __weak
36#define rt_typeof __typeof
37#define rt_noreturn
38#define rt_inline static inline
39#define rt_always_inline rt_inline
40#elif defined (__GNUC__) /* GNU GCC Compiler */
41#define __RT_STRINGIFY(x...) #x
42#define RT_STRINGIFY(x...) __RT_STRINGIFY(x)
43#define rt_section(x) __attribute__((section(x)))
44#define rt_used __attribute__((used))
45#define rt_align(n) __attribute__((aligned(n)))
46#define rt_packed(declare) declare __attribute__((packed))
47#define rt_weak __attribute__((weak))
48#define rt_typeof __typeof__
49#define rt_noreturn __attribute__ ((noreturn))
50#define rt_inline static __inline
51#define rt_always_inline static inline __attribute__((always_inline))
52#elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
53#define rt_section(x) __attribute__((section(x)))
54#define rt_used __attribute__((used))
55#define rt_align(n) __attribute__((aligned(n)))
56#define rt_packed(declare) declare
57#define rt_weak __attribute__((weak))
58#define rt_typeof typeof
59#define rt_noreturn
60#define rt_inline static inline
61#define rt_always_inline rt_inline
62#elif defined (_MSC_VER) /* for Visual Studio Compiler */
63#define rt_section(x)
64#define rt_used
65#define rt_align(n) __declspec(align(n))
66#define rt_packed(declare) __pragma(pack(push, 1)) declare __pragma(pack(pop))
67#define rt_weak
68#define rt_typeof typeof
69#define rt_noreturn
70#define rt_inline static __inline
71#define rt_always_inline rt_inline
72#elif defined (__TI_COMPILER_VERSION__) /* for TI CCS Compiler */
78#define rt_section(x) __attribute__((section(x)))
79#ifdef __TI_EABI__
80#define rt_used __attribute__((retain)) __attribute__((used))
81#else
82#define rt_used __attribute__((used))
83#endif
84#define PRAGMA(x) _Pragma(#x)
85#define rt_align(n) __attribute__((aligned(n)))
86#define rt_packed(declare) declare __attribute__((packed))
87#ifdef __TI_EABI__
88#define rt_weak __attribute__((weak))
89#else
90#define rt_weak
91#endif
92#define rt_typeof typeof
93#define rt_noreturn
94#define rt_inline static inline
95#define rt_always_inline rt_inline
96#elif defined (__TASKING__) /* for TASKING Compiler */
97#define rt_section(x) __attribute__((section(x)))
98#define rt_used __attribute__((used, protect))
99#define PRAGMA(x) _Pragma(#x)
100#define rt_align(n) __attribute__((__align(n)))
101#define rt_packed(declare) declare __packed__
102#define rt_weak __attribute__((weak))
103#define rt_typeof typeof
104#define rt_noreturn
105#define rt_inline static inline
106#define rt_always_inline rt_inline
107#else /* Unkown Compiler */
108 #error not supported tool chain
109#endif /* __ARMCC_VERSION */
110
111#endif /* __RT_COMPILER_H__ */