From 6385442711e9b0d6bcc94879695c3e9548bd6387 Mon Sep 17 00:00:00 2001 From: Igor Kolokolnikov Date: Mon, 17 Aug 2026 04:24:40 -0700 Subject: [PATCH] changes... --- Makefile | 10 +++++++++- profiler.h | 28 +++++++++++++--------------- sdl_handmade.c | 4 ---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 8975c57..f5fb881 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,8 @@ else ifeq ($(CC),gcc) COMP := COMPILER_GCC endif +# printf '\x01\x00' | od -to2 | head -n 1 + # -ansi -pedantic -pedantic-errors CFLAGS = -Wno-long-long -Wall -Wextra \ -Wincompatible-pointer-types \ @@ -33,7 +35,13 @@ CFLAGS = -Wno-long-long -Wall -Wextra \ -Wno-strict-prototypes -Wno-missing-field-initializers \ -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable \ -Wno-unused-but-set-variable \ - -fno-caret-diagnostics -fno-show-column + -fno-show-column + +ifeq ($(COMP),COMPILER_CLANG) + CFLAGS += -fno-caret-diagnostics +else ifeq ($(COMP),COMPILER_GCC) + CFLAGS += -fno-diagnostics-show-caret +endif ifeq ($(OS),OS_MACOS) FLAGS = -glldb diff --git a/profiler.h b/profiler.h index be0c807..4b93f5f 100644 --- a/profiler.h +++ b/profiler.h @@ -59,7 +59,7 @@ static struct profiler_tree_node *profiler_tree_node(const char *name) void profiler_begin(const char *name) { if(!profiler_root_node) { /* create root node */ - profiler_root_node = profiler_tree_node("TOTAL"); + profiler_root_node = profiler_tree_node(""); profiler_last_node = profiler_root_node; } @@ -80,14 +80,20 @@ void profiler_begin(const char *name) profiler_last_node = node; } +void profiler_end() +{ + profiler_last_node->data.end = profiler_get_time(); + profiler_last_node = profiler_last_node->parent; +} + static void profiler_do_print(struct profiler_tree_node *node, - int indent_level) + int indentation_level) { if(node) { unsigned long long difference; int i; - for(i = 0; i < indent_level; i++) + for(i = 0; i < indentation_level; i++) fprintf(stderr, " "); difference = node->data.end - node->data.start; @@ -97,12 +103,10 @@ static void profiler_do_print(struct profiler_tree_node *node, difference, (double)(difference) / 1000000.0); - if(node->first_child) { - profiler_do_print(node->first_child, indent_level+1); - } - if(node->next_sibling) { - profiler_do_print(node->next_sibling, indent_level); - } + if(node->first_child) + profiler_do_print(node->first_child, indentation_level+1); + if(node->next_sibling) + profiler_do_print(node->next_sibling, indentation_level); } } @@ -111,12 +115,6 @@ void profiler_print() profiler_do_print(profiler_root_node->first_child, 0); } -void profiler_end() -{ - profiler_last_node->data.end = profiler_get_time(); - profiler_last_node = profiler_last_node->parent; -} - #else #define profiler_begin(...) diff --git a/sdl_handmade.c b/sdl_handmade.c index 936146b..3e79658 100644 --- a/sdl_handmade.c +++ b/sdl_handmade.c @@ -766,16 +766,12 @@ U64 __rdtsc() } #endif -#include "profiler.h" - int main(int argc, char *argv[]) { struct sdl_state sdl_state; SDL_Window *window; - int i; - memset(&sdl_state, 0, sizeof(sdl_state)); sdl_get_exe_dir_path(sdl_state.exe_dir_path,