setup os_init() for manually starting up os_context

This commit is contained in:
ed
2025-02-09 02:20:36 -05:00
parent 83ce4d1bb2
commit d867a8b0c0
9 changed files with 170 additions and 18 deletions
+4 -6
View File
@@ -10,17 +10,15 @@
void init(Context* ctx)
{
if (ctx->backing[0].proc != nullptr) {
tctx_init_and_equip_alloc(& ctx->thread_ctx, ctx->backing[0]);
}
else {
tctx_init_and_equip(& ctx->thread_ctx);
if ( ! ctx->dont_init_os) {
os_init(& ctx->os_ctx, & ctx->thread_ctx);
}
}
void deinit(Context* ctx)
{
tctx_release();
}
////////////////////////////////
+13 -6
View File
@@ -230,14 +230,18 @@ struct Context
// Currently, this is only relevant if the user is utilizing this library via bindings
// or they are not utilizing metadesk's hosted `entry_point` runtime
// Note: Only used so far as the first fallback if the user did not preset the thread_context's arenas
// Otherwise it will just reserve its own Arena backed by chained virutal address space
AllocatorInfo backing[2];
// Its recommended that the user hooks up
// their own arena allocators to the thread context
// which will be utilized for thread local scratch arena
// which will be utilized for thread local scratch arena
TCTX thread_ctx;
// Just as with TCTX its recommended the user setup the arena allocators
// for te os context
OS_Context os_ctx;
// This skips the os_init process but that means the user is expected to setup
// the thread context for the process
B32 dont_init_os;
};
////////////////////////////////
@@ -263,8 +267,11 @@ nil_node()
////////////////////////////////
// Context lifetime Functios
// NOTE(Ed): The are see comments in Context struct, this is only necessary when not utilizing
// the metadesk os runtime provided entry_point interface
MD_API void init (Context* ctx);
MD_API void deinit(Context* ctx);
// MD_API void deinit(Context* ctx);
////////////////////////////////
//~ rjf: Message Type Functions