Skip to content

Commit

Permalink
修复一些宏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
copi143 committed Jan 2, 2025
1 parent 3a40950 commit 864458a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions include/data-structure/ordered-set/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,12 @@ static void list_print(list_t list) {
*\param[in] list 链表头指针
*\param[in] node 用于迭代的节点指针变量
*/
#define list_foreach_cnt(list, i, node, code) \
#define list_foreach_cnt(list, i, node, ...) \
({ \
size_t i = 0; \
for (list_t node = (list); node; (node) = (node)->next, (i)++) \
(code); \
for (list_t node = (list); node; (node) = (node)->next, (i)++) { \
(__VA_ARGS__); \
} \
})

#define list_first_node(list, node, expr) \
Expand Down
8 changes: 4 additions & 4 deletions include/define/define/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
#define CONCAT(a, b) CONCAT_(a, b)

#if STD_SAFE_API
# define __std_safe__(code) ((void)({code}))
# define __std_safe__(...) ((void)({__VA_ARGS__}))
#else
# define __std_safe__(code) ((void)(0))
# define __std_safe__(...) ((void)(0))
#endif

#if SAFE_API
# define __safe__(code) ((void)({code}))
# define __safe__(...) ((void)({__VA_ARGS__}))
#else
# define __safe__(code) ((void)(0))
# define __safe__(...) ((void)(0))
#endif

#define __ARGN_PRIVATE__(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, \
Expand Down
4 changes: 2 additions & 2 deletions include/libc-base/asm/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ finline void load_tr(size_t selector) {
asm volatile("ltr %0\n\t" : : "m"(selector));
}

#define with_no_interrupts(code) \
#define with_no_interrupts(...) \
({ \
const bool _is_sti_ = asm_is_sti; \
asm_cli; \
(code); \
(__VA_ARGS__); \
if (_is_sti_) asm_sti; \
})

0 comments on commit 864458a

Please sign in to comment.