diff --git a/src/base/base_entry_point.c b/src/base/base_entry_point.c new file mode 100644 index 00000000..e94561a8 --- /dev/null +++ b/src/base/base_entry_point.c @@ -0,0 +1,37 @@ +internal void +main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count) +{ +#if PROFILE_TELEMETRY + local_persist U8 tm_data[MB(64)]; + tmLoadLibrary(TM_RELEASE); + tmSetMaxThreadCount(256); + tmInitialize(sizeof(tm_data), (char *)tm_data); +#endif + TCTX tctx; + tctx_init_and_equip(&tctx); + ThreadNameF("[main thread]"); + Temp scratch = scratch_begin(0, 0); + String8List command_line_argument_strings = os_string_list_from_argcv(scratch.arena, (int)arguments_count, arguments); + CmdLine cmdline = cmd_line_from_string_list(scratch.arena, command_line_argument_strings); + B32 capture = cmd_line_has_flag(&cmdline, str8_lit("capture")); + if(capture) + { + ProfBeginCapture(arguments[0]); + } + entry_point(&cmdline); + if(capture) + { + ProfEndCapture(); + } + scratch_end(scratch); + tctx_release(); +} + +internal void +supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params) +{ + TCTX tctx; + tctx_init_and_equip(&tctx); + entry_point(params); + tctx_release(); +} diff --git a/src/base/base_entry_point.h b/src/base/base_entry_point.h new file mode 100644 index 00000000..fd6c0d92 --- /dev/null +++ b/src/base/base_entry_point.h @@ -0,0 +1,10 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef 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); +internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params); + +#endif // BASE_ENTRY_POINT_H diff --git a/src/base/base_inc.c b/src/base/base_inc.c index 9e26e544..684cb1f6 100644 --- a/src/base/base_inc.c +++ b/src/base/base_inc.c @@ -15,3 +15,4 @@ #include "base_thread_context.c" #include "base_command_line.c" #include "base_markup.c" +#include "base_entry_point.c" diff --git a/src/base/base_inc.h b/src/base/base_inc.h index 6ecfea56..5757b895 100644 --- a/src/base/base_inc.h +++ b/src/base/base_inc.h @@ -17,5 +17,6 @@ #include "base_thread_context.h" #include "base_command_line.h" #include "base_markup.h" +#include "base_entry_point.h" #endif // BASE_INC_H