From eb3c9cd6f33d20d871ea1975a3c1c383199b8e71 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 6 Dec 2023 00:52:47 +0000 Subject: [PATCH] Compile fix. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4660 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/trace.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/trace.c b/src/trace.c index 1aa89323..e4a45cf5 100644 --- a/src/trace.c +++ b/src/trace.c @@ -16,9 +16,7 @@ #include #include -#if !defined(_countof) -#define _countof(a) ((int)(sizeof((a)) / sizeof(*(a)))) -#endif +#define tf_countof(a) ((int)(sizeof((a)) / sizeof(*(a)))) enum { @@ -139,7 +137,7 @@ void tf_trace_counter(tf_trace_t* trace, const char* name, int argc, const char* { p += snprintf(line + p, sizeof(line) - p, "\"%s\": %" PRId64 "%s", arg_names[i], arg_values[i], i == argc - 1 ? "}}," : ", "); } - p = tf_min(p, _countof(line)); + p = tf_min(p, tf_countof(line)); trace->callback(trace, line, p, trace->user_data); } @@ -229,7 +227,7 @@ static tf_trace_thread_t* _tf_trace_get_thread(tf_trace_t* trace, pthread_t self static void _tf_push_stack(tf_trace_t* trace, pthread_t self, const char* name, void* tag) { tf_trace_thread_t* thread = _tf_trace_get_thread(trace, self); - if (!thread->stack || thread->stack->count + 1 > (int)_countof(thread->stack->names)) + if (!thread->stack || thread->stack->count + 1 > tf_countof(thread->stack->names)) { tf_trace_stack_t* stack = tf_malloc(sizeof(tf_trace_stack_t)); memset(stack, 0, sizeof(*stack)); @@ -237,7 +235,7 @@ static void _tf_push_stack(tf_trace_t* trace, pthread_t self, const char* name, thread->stack = stack; } tf_trace_stack_t* stack = thread->stack; - while (stack->count == 0 && stack->next && stack->next->count + 1 <= (int)_countof(thread->stack->names)) + while (stack->count == 0 && stack->next && stack->next->count + 1 <= tf_countof(thread->stack->names)) { stack = stack->next; } @@ -280,7 +278,7 @@ static void _tf_trace_begin_tagged(tf_trace_t* trace, const char* name, void* ta int p = snprintf(line, sizeof(line), "{\"ph\": \"B\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)self, _trace_ts()); p += _tf_trace_escape_name(line + p, sizeof(line) - p, name); p += snprintf(line + p, sizeof(line) - p, "\"},"); - p = tf_min(p, _countof(line)); + p = tf_min(p, tf_countof(line)); trace->callback(trace, line, p, trace->user_data); } @@ -307,7 +305,7 @@ static void _tf_trace_end_tagged(tf_trace_t* trace, void* tag) int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": \"0x%" PRIx64 "\", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts()); p += _tf_trace_escape_name(line + p, sizeof(line) - p, name); p += snprintf(line + p, sizeof(line) - p, "\"},"); - p = tf_min(p, _countof(line)); + p = tf_min(p, tf_countof(line)); trace->callback(trace, line, p, trace->user_data); }