Skip to content

Commit de6ac91

Browse files
committed
fix 给 ek_def 中的常用属性宏都加上了 __EK 前缀
1 parent ee8edec commit de6ac91

7 files changed

Lines changed: 72 additions & 79 deletions

File tree

‎L2_Core/port/stm32f429zi/st_dma2d_port.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static ek_hal_dma2d_t drv_dma2d1;
6868

6969
__WEAK void ek_dma2d_transfer_cplt_callback(DMA2D_HandleTypeDef *hdma2d)
7070
{
71-
__UNUSED(hdma2d);
71+
__EK_UNUSED(hdma2d);
7272
}
7373

7474
// 注册到 HAL

‎L2_Core/utils/inc/ek_def.h‎

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define EK_DEF_H
1717

1818
#include <inttypes.h>
19-
#include <stdarg.h>
2019
#include <string.h>
2120
#include <stddef.h>
2221
#include <stdint.h>
@@ -35,69 +34,63 @@
3534
/* ========== GCC 编译器宏定义 ========== */
3635
#if defined(__GNUC__) && !defined(__ARMCC_VERSION)
3736

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
5049
/* ========== ARM Compiler 6 宏定义 ========== */
5150
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
5251

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
6564

6665
/* ========== ARM Compiler 5 宏定义 ========== */
6766
#elif defined(__CC_ARM)
6867

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+
/* ========== 不支持的编译器(空定义) ========== */
8281
#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
10194
#endif
10295

10396
/* ========== 功能宏 ========== */

‎L2_Core/utils/inc/ek_list.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct ek_list_node_t
7373
*
7474
* @note 使用前必须初始化,使头节点的 prev 和 next 都指向自己
7575
*/
76-
__STATIC_INLINE void ek_list_init(ek_list_node_t *head)
76+
__EK_STATIC_INLINE void ek_list_init(ek_list_node_t *head)
7777
{
7878
head->next = head;
7979
head->prev = head;
@@ -85,7 +85,7 @@ __STATIC_INLINE void ek_list_init(ek_list_node_t *head)
8585
* @param prev 前一个节点(插入位置之前)
8686
* @param next 后一个节点(插入位置之后)
8787
*/
88-
__STATIC_INLINE void __ek_list_add(ek_list_node_t *new_node, ek_list_node_t *prev, ek_list_node_t *next)
88+
__EK_STATIC_INLINE void __ek_list_add(ek_list_node_t *new_node, ek_list_node_t *prev, ek_list_node_t *next)
8989
{
9090
prev->next = new_node;
9191
new_node->next = next;
@@ -98,7 +98,7 @@ __STATIC_INLINE void __ek_list_add(ek_list_node_t *new_node, ek_list_node_t *pre
9898
* @param head 链表头节点指针
9999
* @param new_node 要添加的新节点
100100
*/
101-
__STATIC_INLINE void ek_list_add_head(ek_list_node_t *head, ek_list_node_t *new_node)
101+
__EK_STATIC_INLINE void ek_list_add_head(ek_list_node_t *head, ek_list_node_t *new_node)
102102
{
103103
__ek_list_add(new_node, head, head->next);
104104
}
@@ -108,7 +108,7 @@ __STATIC_INLINE void ek_list_add_head(ek_list_node_t *head, ek_list_node_t *new_
108108
* @param head 链表头节点指针
109109
* @param new_node 要添加的新节点
110110
*/
111-
__STATIC_INLINE void ek_list_add_tail(ek_list_node_t *head, ek_list_node_t *new_node)
111+
__EK_STATIC_INLINE void ek_list_add_tail(ek_list_node_t *head, ek_list_node_t *new_node)
112112
{
113113
__ek_list_add(new_node, head->prev, head);
114114
}
@@ -118,7 +118,7 @@ __STATIC_INLINE void ek_list_add_tail(ek_list_node_t *head, ek_list_node_t *new_
118118
* @param prev 前一个节点
119119
* @param next 后一个节点
120120
*/
121-
__STATIC_INLINE void __ek_list_remove(ek_list_node_t *prev, ek_list_node_t *next)
121+
__EK_STATIC_INLINE void __ek_list_remove(ek_list_node_t *prev, ek_list_node_t *next)
122122
{
123123
next->prev = prev;
124124
prev->next = next;
@@ -130,7 +130,7 @@ __STATIC_INLINE void __ek_list_remove(ek_list_node_t *prev, ek_list_node_t *next
130130
*
131131
* @note 移除后节点的 prev 和 next 被置为 NULL,可用于检测节点是否在链表中
132132
*/
133-
__STATIC_INLINE void ek_list_remove(ek_list_node_t *remove)
133+
__EK_STATIC_INLINE void ek_list_remove(ek_list_node_t *remove)
134134
{
135135
__ek_list_remove(remove->prev, remove->next);
136136
remove->prev = NULL;
@@ -143,7 +143,7 @@ __STATIC_INLINE void ek_list_remove(ek_list_node_t *remove)
143143
* @return true 链表为空
144144
* @return false 链表非空
145145
*/
146-
__STATIC_INLINE bool ek_list_empty(ek_list_node_t *head)
146+
__EK_STATIC_INLINE bool ek_list_empty(ek_list_node_t *head)
147147
{
148148
return head->next == head;
149149
}
@@ -155,7 +155,7 @@ __STATIC_INLINE bool ek_list_empty(ek_list_node_t *head)
155155
* @return true 是最后一个节点
156156
* @return false 不是最后一个节点
157157
*/
158-
__STATIC_INLINE bool ek_list_is_last(ek_list_node_t *list, ek_list_node_t *head)
158+
__EK_STATIC_INLINE bool ek_list_is_last(ek_list_node_t *list, ek_list_node_t *head)
159159
{
160160
return list->next == head;
161161
}
@@ -165,7 +165,7 @@ __STATIC_INLINE bool ek_list_is_last(ek_list_node_t *list, ek_list_node_t *head)
165165
* @param head 链表头节点指针
166166
* @return 第一个节点指针,如果链表为空则返回 head
167167
*/
168-
__STATIC_INLINE ek_list_node_t *ek_list_get_first(ek_list_node_t *head)
168+
__EK_STATIC_INLINE ek_list_node_t *ek_list_get_first(ek_list_node_t *head)
169169
{
170170
return head->next;
171171
}
@@ -175,7 +175,7 @@ __STATIC_INLINE ek_list_node_t *ek_list_get_first(ek_list_node_t *head)
175175
* @param head 链表头节点指针
176176
* @return 最后一个节点指针,如果链表为空则返回 head
177177
*/
178-
__STATIC_INLINE ek_list_node_t *ek_list_get_last(ek_list_node_t *head)
178+
__EK_STATIC_INLINE ek_list_node_t *ek_list_get_last(ek_list_node_t *head)
179179
{
180180
return head->prev;
181181
}

‎L2_Core/utils/src/ek_assert.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ void ek_assert_fault(const char *file, uint32_t line, const char *expr)
1313
EK_LOG_FILE_TAG("ek_assert.c");
1414
EK_LOG_ERROR("file:%s,line:%" PRIu32 ",expr: %s", EK_GET_FILE_NAME(file), line, expr);
1515
#else
16-
__UNUSED(file);
17-
__UNUSED(line);
18-
__UNUSED(expr);
16+
__EK_UNUSED(file);
17+
__EK_UNUSED(line);
18+
__EK_UNUSED(expr);
1919
#endif /* EK_ASSERT_WITH_LOG */
2020

2121
while (1)

‎L2_Core/utils/src/ek_io.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
# include "../inc/ek_def.h"
1212

13-
__WEAK void _ek_io_fputc(int ch)
13+
__EK_WEAK void _ek_io_fputc(int ch)
1414
{
15-
__UNUSED(ch);
15+
__EK_UNUSED(ch);
1616
}
1717

1818
static int _ek_io_printf(int ch, lwprintf_t *lwp)
1919
{
20-
__UNUSED(lwp);
20+
__EK_UNUSED(lwp);
2121
if (ch != '\0')
2222
{
2323
_ek_io_fputc(ch);

‎L2_Core/utils/src/ek_log.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static const char *ek_log_type_table[EK_LOG_TYPE_MAX] = {
3434

3535
static char ek_log_buffer[EK_LOG_BUFFER_SIZE];
3636

37-
__WEAK uint32_t _ek_log_get_tick(void)
37+
__EK_WEAK uint32_t _ek_log_get_tick(void)
3838
{
3939
return 0;
4040
}

‎L2_Core/utils/src/ek_mem.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,26 @@ tlsf_t ek_default_tlsf;
6666
static size_t ek_unused_bytes = 0;
6767
static size_t ek_used_bytes = 0;
6868

69-
__WEAK void *_ek_malloc(size_t size)
69+
__EK_WEAK void *_ek_malloc(size_t size)
7070
{
7171
return tlsf_malloc(ek_default_tlsf, size);
7272
}
7373

74-
__WEAK void *_ek_realloc(void *ptr, size_t size)
74+
__EK_WEAK void *_ek_realloc(void *ptr, size_t size)
7575
{
7676
return tlsf_realloc(ek_default_tlsf, ptr, size);
7777
}
7878

79-
__WEAK void _ek_free(void *ptr)
79+
__EK_WEAK void _ek_free(void *ptr)
8080
{
8181
tlsf_free(ek_default_tlsf, ptr);
8282
}
8383

8484
// walker 函数:统计空闲内存
8585
static void ek_mem_walker(void *ptr, size_t size, int used, void *user)
8686
{
87-
__UNUSED(ptr);
88-
__UNUSED(user);
87+
__EK_UNUSED(ptr);
88+
__EK_UNUSED(user);
8989

9090
if (!used)
9191
{

0 commit comments

Comments
 (0)