From c87454220d0e34bf1517886349e65da4dcfd9716 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Mon, 20 Nov 2023 16:43:06 +0800 Subject: [PATCH] note: change sched_note_counter to a macro Signed-off-by: yinshengkai --- include/nuttx/sched_note.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index 0ee171a2a9..ecbd608f7b 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -142,8 +142,6 @@ sched_note_printf_ip(tag, SCHED_NOTE_IP, fmt, ##__VA_ARGS__) #define sched_note_bprintf(tag, fmt, ...) \ sched_note_bprintf_ip(tag, SCHED_NOTE_IP, fmt, ##__VA_ARGS__) -#define sched_note_counter(tag, name, value) \ - sched_note_counter_ip(tag, SCHED_NOTE_IP, name, value) #define sched_note_begin(tag) \ sched_note_event(tag, NOTE_DUMP_BEGIN, NULL, 0) @@ -156,6 +154,17 @@ #define sched_note_mark(tag, str) \ sched_note_event(tag, NOTE_DUMP_MARK, str, strlen(str)) +#define sched_note_counter(tag, name_, value_) \ + do \ + { \ + struct note_counter_s counter; \ + counter.value = value_; \ + strlcpy(counter.name, name_, NAME_MAX); \ + sched_note_event(tag, NOTE_DUMP_COUNTER, \ + &counter, sizeof(counter)); \ + } \ + while (0) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -591,16 +600,6 @@ void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt, ...) printf_like(3, 4); void sched_note_bprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt, ...) printf_like(3, 4); - -static inline void sched_note_counter_ip(uint32_t tag, uintptr_t ip, - FAR const char *name, - long int value) -{ - struct note_counter_s counter; - counter.value = value; - strlcpy(counter.name, name, sizeof(counter.name)); - sched_note_event_ip(tag, ip, NOTE_DUMP_COUNTER, &counter, sizeof(counter)); -} #else # define sched_note_string_ip(t,ip,b) # define sched_note_event_ip(t,ip,e,b,l) @@ -608,7 +607,6 @@ static inline void sched_note_counter_ip(uint32_t tag, uintptr_t ip, # define sched_note_vbprintf_ip(t,ip,f,v) # define sched_note_printf_ip(t,ip,f,...) # define sched_note_bprintf_ip(t,ip,f,...) -# define sched_note_counter_ip(t,ip,n,v) #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */ #if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)