clang-format the source. Not exactly how I want it, but automated is better than perfect.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4845 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-02-15 23:35:01 +00:00
parent c8812b1add
commit fbc3cfeda4
37 changed files with 3141 additions and 1764 deletions

View File

@ -208,8 +208,7 @@ static tf_trace_thread_t* _tf_trace_get_thread(tf_trace_t* trace, pthread_t self
if (!found)
{
found = tf_malloc(sizeof(tf_trace_thread_t));
*found = (tf_trace_thread_t)
{
*found = (tf_trace_thread_t) {
.id = self,
};
#if defined(__linux__) && !defined(__ANDROID__)
@ -242,7 +241,6 @@ static void _tf_push_stack(tf_trace_t* trace, pthread_t self, const char* name,
stack->names[stack->count] = name;
stack->tags[stack->count] = tag;
stack->count++;
}
static const char* _tf_pop_stack(tf_trace_t* trace, pthread_t self, void* tag)
@ -254,9 +252,7 @@ static const char* _tf_pop_stack(tf_trace_t* trace, pthread_t self, void* tag)
stack = stack->next;
}
const char* name = NULL;
if (stack &&
stack->count > 0 &&
stack->tags[stack->count - 1] == tag)
if (stack && stack->count > 0 && stack->tags[stack->count - 1] == tag)
{
name = stack->names[stack->count - 1];
stack->count--;
@ -302,9 +298,10 @@ static void _tf_trace_end_tagged(tf_trace_t* trace, void* tag)
}
char line[1024];
int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": %" PRId64 ", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts());
int p =
snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": %" PRId64 ", \"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 += snprintf(line + p, sizeof(line) - p, "\"},");
p = tf_min(p, tf_countof(line));
trace->callback(trace, line, p, trace->user_data);
}
@ -330,20 +327,15 @@ char* tf_trace_export(tf_trace_t* trace)
size += snprintf(buffer, k_buffer_size, "{\"displayTimeUnit\": \"ns\",\n\"traceEvents\": [\n");
if (*trace->process_name)
{
size += snprintf(buffer + size, k_buffer_size - size,
"{\"ph\":\"M\",\"pid\":%d,\"name\":\"process_name\",\"args\":{\"name\":\"%s\"}},\n",
getpid(),
trace->process_name);
size += snprintf(
buffer + size, k_buffer_size - size, "{\"ph\":\"M\",\"pid\":%d,\"name\":\"process_name\",\"args\":{\"name\":\"%s\"}},\n", getpid(), trace->process_name);
}
uv_rwlock_rdlock(&trace->threads_lock);
for (int i = 0; i < trace->threads_count; i++)
{
tf_trace_thread_t* thread = trace->threads[i];
size += snprintf(buffer + size, k_buffer_size - size,
"{\"ph\":\"M\",\"pid\":%d,\"tid\":%" PRId64 ",\"name\":\"thread_name\",\"args\":{\"name\":\"%s\"}},\n",
getpid(),
(uint64_t)thread->id,
thread->name);
size += snprintf(buffer + size, k_buffer_size - size, "{\"ph\":\"M\",\"pid\":%d,\"tid\":%" PRId64 ",\"name\":\"thread_name\",\"args\":{\"name\":\"%s\"}},\n",
getpid(), (uint64_t)thread->id, thread->name);
}
uv_rwlock_rdunlock(&trace->threads_lock);
if (begin)