add ability to override entry point type

This commit is contained in:
Nikita Smith
2024-11-07 11:54:25 -08:00
parent ce9d43a92e
commit 0dd05169ee
5 changed files with 28 additions and 9 deletions
+15 -6
View File
@@ -4,21 +4,21 @@
global U64 global_update_tick_idx = 0; global U64 global_update_tick_idx = 0;
internal void internal void
main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count) main_thread_base_entry_point(EntryPoint entry_point, int argc, char **argv)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
ThreadNameF("[main thread]"); ThreadNameF("[main thread]");
//- rjf: set up telemetry //- rjf: set up telemetry
#if PROFILE_TELEMETRY #if PROFILE_TELEMETRY
local_persist U8 tm_data[MB(64)]; local_persist char tm_data[MB(64)];
tmLoadLibrary(TM_RELEASE); tmLoadLibrary(TM_RELEASE);
tmSetMaxThreadCount(256); tmSetMaxThreadCount(256);
tmInitialize(sizeof(tm_data), (char *)tm_data); tmInitialize(sizeof(tm_data), tm_data);
#endif #endif
//- rjf: parse command line //- rjf: parse command line
String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, (int)arguments_count, arguments); String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, argc, argv);
CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings); CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings);
//- rjf: begin captures //- rjf: begin captures
@@ -27,6 +27,10 @@ main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **argum
{ {
ProfBeginCapture(arguments[0]); ProfBeginCapture(arguments[0]);
} }
#if PROFILE_TELEMETRY
tmMessage(0, TMMF_ICON_NOTE, BUILD_TITLE);
#endif
//- rjf: initialize all included layers //- rjf: initialize all included layers
#if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL) #if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL)
@@ -83,16 +87,21 @@ main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **argum
#if defined(RADDBG_CORE_H) && !defined(RD_INIT_MANUAL) #if defined(RADDBG_CORE_H) && !defined(RD_INIT_MANUAL)
rd_init(&cmdline); rd_init(&cmdline);
#endif #endif
//- rjf: call into entry point //- rjf: call into entry point
#if BASE_ENTRY_POINT_ARGCV
scratch_end(scratch); // release command line memory
entry_point(argc, argv);
#else
entry_point(&cmdline); entry_point(&cmdline);
scratch_end(scratch);
#endif
//- rjf: end captures //- rjf: end captures
if(capture) if(capture)
{ {
ProfEndCapture(); ProfEndCapture();
} }
scratch_end(scratch);
} }
internal void internal void
+7 -1
View File
@@ -4,7 +4,13 @@
#ifndef BASE_ENTRY_POINT_H #ifndef BASE_ENTRY_POINT_H
#define BASE_ENTRY_POINT_H #define BASE_ENTRY_POINT_H
internal void main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count); #if BASE_ENTRY_POINT_ARGCV
typedef void (*EntryPoint)(int argc, char **argv);
#else
typedef void (*EntryPoint)(CmdLine *cmdline);
#endif
internal void main_thread_base_entry_point(EntryPoint entry_point, int argc, char **argv);
internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params); internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params);
internal U64 update_tick_idx(void); internal U64 update_tick_idx(void);
internal B32 update(void); internal B32 update(void);
+1 -1
View File
@@ -1259,5 +1259,5 @@ main(int argc, char **argv)
} }
//- rjf: call into "real" entry point //- rjf: call into "real" entry point
main_thread_base_entry_point(entry_point, argv, (U64)argc); main_thread_base_entry_point(entry_point, argc, argv);
} }
+4
View File
@@ -342,7 +342,11 @@ internal OS_Guid os_make_guid(void);
// into the standard codebase program entry points, named "entry_point". // into the standard codebase program entry points, named "entry_point".
#if BUILD_ENTRY_DEFINING_UNIT #if BUILD_ENTRY_DEFINING_UNIT
# if BASE_ENTRY_POINT_ARGCV
internal void entry_point(int argc, char **argv);
# else
internal void entry_point(CmdLine *cmdline); internal void entry_point(CmdLine *cmdline);
#endif #endif
#endif
#endif // OS_CORE_H #endif // OS_CORE_H
+1 -1
View File
@@ -1678,7 +1678,7 @@ w32_entry_point_caller(int argc, WCHAR **wargv)
os_w32_state.entity_arena = arena_alloc(); os_w32_state.entity_arena = arena_alloc();
//- rjf: call into "real" entry point //- rjf: call into "real" entry point
main_thread_base_entry_point(entry_point, argv, (U64)argc); main_thread_base_entry_point(entry_point, argc, argv);
} }
#if BUILD_CONSOLE_INTERFACE #if BUILD_CONSOLE_INTERFACE