|
16 | 16 | #define EK_DEF_H |
17 | 17 |
|
18 | 18 | #include <inttypes.h> |
19 | | -#include <stdarg.h> |
20 | 19 | #include <string.h> |
21 | 20 | #include <stddef.h> |
22 | 21 | #include <stdint.h> |
|
35 | 34 | /* ========== GCC 编译器宏定义 ========== */ |
36 | 35 | #if defined(__GNUC__) && !defined(__ARMCC_VERSION) |
37 | 36 |
|
38 | | -# define __WEAK __attribute__((weak)) |
39 | | -# define __PACKED __attribute__((packed)) |
40 | | -# define __PACKED_STRUCT struct __attribute__((packed)) |
41 | | -# define __ALIGNED(x) __attribute__((aligned(x))) |
42 | | -# define __USED __attribute__((used)) |
43 | | -# define __SECTION(x) __attribute__((section(x))) |
44 | | -# define __NO_RETURN __attribute__((noreturn)) |
45 | | -# define __UNUSED(x) ((void)(x)) |
46 | | -# define __INLINE inline |
47 | | -# define __STATIC_INLINE static inline |
48 | | -# define __ALWAYS_INLINE __attribute__((always_inline)) static inline |
49 | | -# define __ASM __asm |
| 37 | +# define __EK_WEAK __attribute__((weak)) |
| 38 | +# define __EK_PACKED __attribute__((packed)) |
| 39 | +# define __EK_PACKED_STRUCT struct __attribute__((packed)) |
| 40 | +# define __EK_ALIGNED(x) __attribute__((aligned(x))) |
| 41 | +# define __EK_USED __attribute__((used)) |
| 42 | +# define __EK_SECTION(x) __attribute__((section(x))) |
| 43 | +# define __EK_NO_RETURN __attribute__((noreturn)) |
| 44 | +# define __EK_UNUSED(x) ((void)(x)) |
| 45 | +# define __EK_INLINE inline |
| 46 | +# define __EK_STATIC_INLINE static inline |
| 47 | +# define __EK_ALWAYS_INLINE __attribute__((always_inline)) static inline |
| 48 | +# define __EK_ASM __asm |
50 | 49 | /* ========== ARM Compiler 6 宏定义 ========== */ |
51 | 50 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
52 | 51 |
|
53 | | -# define __WEAK __attribute__((weak)) |
54 | | -# define __PACKED __attribute__((packed)) |
55 | | -# define __PACKED_STRUCT struct __attribute__((packed)) |
56 | | -# define __ALIGNED(x) __attribute__((aligned(x))) |
57 | | -# define __USED __attribute__((used)) |
58 | | -# define __SECTION(x) __attribute__((section(x))) |
59 | | -# define __NO_RETURN __attribute__((noreturn)) |
60 | | -# define __UNUSED(x) ((void)(x)) |
61 | | -# define __INLINE inline |
62 | | -# define __STATIC_INLINE static inline |
63 | | -# define __ALWAYS_INLINE __attribute__((always_inline)) static inline |
64 | | -# define __ASM __asm |
| 52 | +# define __EK_WEAK __attribute__((weak)) |
| 53 | +# define __EK_PACKED __attribute__((packed)) |
| 54 | +# define __EK_PACKED_STRUCT struct __attribute__((packed)) |
| 55 | +# define __EK_ALIGNED(x) __attribute__((aligned(x))) |
| 56 | +# define __EK_USED __attribute__((used)) |
| 57 | +# define __EK_SECTION(x) __attribute__((section(x))) |
| 58 | +# define __EK_NO_RETURN __attribute__((noreturn)) |
| 59 | +# define __EK_UNUSED(x) ((void)(x)) |
| 60 | +# define __EK_INLINE inline |
| 61 | +# define __EK_STATIC_INLINE static inline |
| 62 | +# define __EK_ALWAYS_INLINE __attribute__((always_inline)) static inline |
| 63 | +# define __EK_ASM __asm |
65 | 64 |
|
66 | 65 | /* ========== ARM Compiler 5 宏定义 ========== */ |
67 | 66 | #elif defined(__CC_ARM) |
68 | 67 |
|
69 | | -# define __WEAK __weak |
70 | | -# define __PACKED __packed |
71 | | -# define __PACKED_STRUCT __packed struct |
72 | | -# define __ALIGNED(x) __align((x)) |
73 | | -# define __USED __attribute__((used)) |
74 | | -# define __SECTION(x) __attribute__((section(x))) |
75 | | -# define __NO_RETURN __declspec(noreturn) |
76 | | -# define __UNUSED(x) ((void)(x)) |
77 | | -# define __INLINE __inline |
78 | | -# define __STATIC_INLINE static __inline |
79 | | -# define __ALWAYS_INLINE __forceinline |
80 | | -# define __ASM __asm |
81 | | -/* ========== 不支持的编译器(需手动适配,默认编译报错) ========== */ |
| 68 | +# define __EK_WEAK __weak |
| 69 | +# define __EK_PACKED __packed |
| 70 | +# define __EK_PACKED_STRUCT __packed struct |
| 71 | +# define __EK_ALIGNED(x) __align(x) |
| 72 | +# define __EK_USED __attribute__((used)) |
| 73 | +# define __EK_SECTION(x) __attribute__((section(x))) |
| 74 | +# define __EK_NO_RETURN __declspec(noreturn) |
| 75 | +# define __EK_UNUSED(x) ((void)(x)) |
| 76 | +# define __EK_INLINE __inline |
| 77 | +# define __EK_STATIC_INLINE static __inline |
| 78 | +# define __EK_ALWAYS_INLINE __forceinline |
| 79 | +# define __EK_ASM __asm |
| 80 | +/* ========== 不支持的编译器(空定义) ========== */ |
82 | 81 | #else |
83 | | - |
84 | | -# if 1 |
85 | | -# error \ |
86 | | - "Unsupported compiler detected. Please review and update the macro definitions in ek_def.h for this toolchain." |
87 | | -# endif |
88 | | - |
89 | | -# define __WEAK |
90 | | -# define __PACKED |
91 | | -# define __PACKED_STRUCT struct |
92 | | -# define __ALIGNED(x) |
93 | | -# define __USED |
94 | | -# define __SECTION(x) |
95 | | -# define __NO_RETURN |
96 | | -# define __UNUSED(x) ((void)(x)) |
97 | | -# define __INLINE inline |
98 | | -# define __STATIC_INLINE static inline |
99 | | -# define __ALWAYS_INLINE static inline |
100 | | -# define __ASM asm |
| 82 | +# define __EK_WEAK |
| 83 | +# define __EK_PACKED |
| 84 | +# define __EK_PACKED_STRUCT struct |
| 85 | +# define __EK_ALIGNED(x) |
| 86 | +# define __EK_USED |
| 87 | +# define __EK_SECTION(x) |
| 88 | +# define __EK_NO_RETURN |
| 89 | +# define __EK_UNUSED(x) ((void)(x)) |
| 90 | +# define __EK_INLINE inline |
| 91 | +# define __EK_STATIC_INLINE static inline |
| 92 | +# define __EK_ALWAYS_INLINE static inline |
| 93 | +# define __EK_ASM asm |
101 | 94 | #endif |
102 | 95 |
|
103 | 96 | /* ========== 功能宏 ========== */ |
|
0 commit comments