More build fixes

This commit is contained in:
2025-11-09 17:10:08 +11:00
parent ea7cd4638c
commit d4dcead4f2
9 changed files with 129 additions and 117 deletions
+51 -46
View File
@@ -1,4 +1,4 @@
// Generated by the DN single header generator 2025-11-09 15:37:40
// Generated by the DN single header generator 2025-11-09 17:09:52
#define DN_BASE_INC_CPP
@@ -827,7 +827,7 @@ static DN_ArenaBlock *DN_ArenaBlockFromMemFuncs_(DN_U64 reserve, DN_U64 commit,
}
if (track_alloc && result)
DN_LeakTrackAlloc(dn->leak, result, result->reserve, alloc_can_leak);
DN_LeakTrackAlloc(&g_dn_->leak, result, result->reserve, alloc_can_leak);
return result;
}
@@ -1512,14 +1512,15 @@ DN_API DN_I64 DN_I64FromPtrUnsafe(void const *data, DN_USize size, char separato
DN_API DN_FmtAppendResult DN_FmtVAppend(char *buf, DN_USize *buf_size, DN_USize buf_max, char const *fmt, va_list args)
{
DN_FmtAppendResult result = {};
result.size_req = DN_VSNPrintF(buf + *buf_size, DN_Cast(int)(buf_max - *buf_size), fmt, args);
*buf_size += result.size_req;
DN_FmtAppendResult result = {};
DN_USize starting_size = *buf_size;
result.size_req = DN_VSNPrintF(buf + *buf_size, DN_Cast(int)(buf_max - *buf_size), fmt, args);
*buf_size += result.size_req;
if (*buf_size >= (buf_max - 1))
*buf_size = buf_max - 1;
DN_Assert(*buf_size <= (buf_max - 1));
result.str8 = DN_Str8FromPtr(buf, *buf_size);
result.truncated = result.str8.size != result.size_req;
result.truncated = result.str8.size != (starting_size + result.size_req);
return result;
}
@@ -10277,8 +10278,9 @@ enum DN_InitFlags_
{
DN_InitFlags_Nil = 0,
DN_InitFlags_OS = 1 << 0,
DN_InitFlags_LogLibFeatures = 1 << 1,
DN_InitFlags_LogCPUFeatures = 1 << 2,
DN_InitFlags_OSLeakTracker = 1 << 1,
DN_InitFlags_LogLibFeatures = 1 << 2,
DN_InitFlags_LogCPUFeatures = 1 << 3,
DN_InitFlags_LogAllFeatures = DN_InitFlags_LogLibFeatures | DN_InitFlags_LogCPUFeatures,
};
@@ -10382,49 +10384,51 @@ DN_API void DN_Init(DN_Core *dn, DN_InitFlags flags, DN_InitArgs *args)
{
g_dn_ = dn;
#if defined(DN_OS_H) && defined(DN_OS_CPP)
DN_InitOS_(&dn->os, args);
#endif
// NOTE Initialise fields
#if defined(DN_LEAK_TRACKING)
// NOTE: Setup the allocation table with allocation tracking turned off on
// the arena we're using to initialise the table.
core->alloc_table_arena = DN_ArenaFromVMem(DN_Megabytes(1), DN_Kilobytes(512), DN_ArenaFlags_NoAllocTrack | DN_ArenaFlags_AllocCanLeak);
core->alloc_table = DN_DSMap_Init<DN_DebugAlloc>(&core->alloc_table_arena, 4096, DN_DSMapFlags_Nil);
#endif
if (flags & DN_InitFlags_OS) {
#if defined(DN_OS_H) && defined(DN_OS_CPP)
DN_InitOS_(&dn->os, args);
if (flags & DN_InitFlags_OSLeakTracker) {
// NOTE: Setup the allocation table with allocation tracking turned off on
// the arena we're using to initialise the table.
dn->leak.alloc_table_arena = DN_ArenaFromVMem(DN_Megabytes(1), DN_Kilobytes(512), DN_ArenaFlags_NoAllocTrack | DN_ArenaFlags_AllocCanLeak);
dn->leak.alloc_table = DN_DSMap_Init<DN_LeakAlloc>(&dn->leak.alloc_table_arena, 4096, DN_DSMapFlags_Nil);
}
#endif
}
// NOTE: Print out init features
DN_OSTLSTMem tmem = DN_OS_TLSPushTMem(nullptr);
DN_Str8Builder builder = DN_Str8BuilderFromArena(tmem.arena);
char buf[4096];
DN_USize buf_size = 0;
if (flags & DN_InitFlags_LogLibFeatures) {
DN_Str8BuilderAppendRef(&builder, DN_Str8Lit("DN initialised:\n"));
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), "DN initialised:\n");
#if defined(DN_OS_CPP)
DN_F32 page_size_kib = dn->os.page_size / 1024.0f;
DN_F32 alloc_granularity_kib = dn->os.alloc_granularity / 1024.0f;
DN_Str8BuilderAppendF(&builder,
" OS Page Size/Alloc Granularity: %.1f/%.1fKiB\n"
" Logical Processor Count: %u\n",
page_size_kib,
alloc_granularity_kib,
dn->os.logical_processor_count);
DN_F32 page_size_kib = dn->os.page_size / 1024.0f;
DN_F32 alloc_granularity_kib = dn->os.alloc_granularity / 1024.0f;
DN_FmtAppendTruncate(buf,
&buf_size,
sizeof(buf),
DN_Str8Lit("..."),
" OS Page Size/Alloc Granularity: %.1f/%.1fKiB\n"
" Logical Processor Count: %u\n",
page_size_kib,
alloc_granularity_kib,
dn->os.logical_processor_count);
#endif
#if DN_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
if (DN_ASAN_POISON) {
DN_Str8BuilderAppendF(
&builder, " ASAN manual poisoning%s\n", DN_ASAN_VET_POISON ? " (+vet sanity checks)" : "");
DN_Str8BuilderAppendF(&builder, " ASAN poison guard size: %u\n", DN_ASAN_POISON_GUARD_SIZE);
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), " ASAN manual poisoning%s\n", DN_ASAN_VET_POISON ? " (+vet sanity checks)" : "");
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), " ASAN poison guard size: %u\n", DN_ASAN_POISON_GUARD_SIZE);
}
#endif
#if defined(DN_LEAK_TRACKING)
DN_Str8BuilderAppendRef(&builder, DN_Str8Lit(" Allocation leak tracing\n"));
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), " Allocation leak tracing\n");
#endif
#if defined(DN_PLATFORM_EMSCRIPTEN) || defined(DN_PLATFORM_POSIX)
DN_POSIXCore *posix = DN_Cast(DN_POSIXCore *)g_dn_->os.platform_context;
DN_Str8BuilderAppendF(&builder, " Clock GetTime: %S\n", posix->clock_monotonic_raw ? DN_Str8Lit("CLOCK_MONOTONIC_RAW") : DN_Str8Lit("CLOCK_MONOTONIC"));
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), " Clock GetTime: %S\n", posix->clock_monotonic_raw ? DN_Str8Lit("CLOCK_MONOTONIC_RAW") : DN_Str8Lit("CLOCK_MONOTONIC"));
#endif
// TODO(doyle): Add stacktrace feature log
}
@@ -10434,7 +10438,7 @@ DN_API void DN_Init(DN_Core *dn, DN_InitFlags flags, DN_InitArgs *args)
DN_Str8 brand = DN_Str8TrimWhitespaceAround(DN_Str8FromPtr(report->brand, sizeof(report->brand) - 1));
DN_MSVC_WARNING_PUSH
DN_MSVC_WARNING_DISABLE(6284) // Object passed as _Param_(3) when a string is required in call to 'DN_Str8BuilderAppendF' Actual type: 'struct DN_Str8'.
DN_Str8BuilderAppendF(&builder, " CPU '%S' from '%s' detected:\n", brand, report->vendor);
DN_FmtAppendTruncate(buf, &buf_size, sizeof(buf), DN_Str8Lit("..."), " CPU '%S' from '%s' detected:\n", brand, report->vendor);
DN_MSVC_WARNING_POP
DN_USize longest_feature_name = 0;
@@ -10446,19 +10450,20 @@ DN_API void DN_Init(DN_Core *dn, DN_InitFlags flags, DN_InitArgs *args)
for (DN_ForIndexU(feature_index, DN_CPUFeature_Count)) {
DN_CPUFeatureDecl feature_decl = g_dn_cpu_feature_decl[feature_index];
bool has_feature = DN_CPUHasFeature(report, feature_decl.value);
DN_Str8BuilderAppendF(&builder,
" %.*s:%*s%s\n",
DN_Str8PrintFmt(feature_decl.label),
DN_Cast(int)(longest_feature_name - feature_decl.label.size),
"",
has_feature ? "available" : "not available");
DN_FmtAppendTruncate(buf,
&buf_size,
sizeof(buf),
DN_Str8Lit("..."),
" %.*s:%*s%s\n",
DN_Str8PrintFmt(feature_decl.label),
DN_Cast(int)(longest_feature_name - feature_decl.label.size),
"",
has_feature ? "available" : "not available");
}
}
DN_Str8 info_log = DN_Str8BuilderBuild(&builder, tmem.arena);
if (info_log.size)
DN_LOG_DebugF("%.*s", DN_Str8PrintFmt(info_log));
if (buf_size)
DN_LOG_DebugF("%.*s", DN_Cast(int)buf_size, buf);
}
DN_API void DN_BeginFrame()
+5 -4
View File
@@ -1,4 +1,4 @@
// Generated by the DN single header generator 2025-11-09 15:37:40
// Generated by the DN single header generator 2025-11-09 17:09:52
#if !defined(DN_BASE_INC_H)
#define DN_BASE_INC_H
@@ -4015,7 +4015,7 @@ DN_API void DN_LeakDump_ (DN_LeakTracker *leak);
#if defined(DN_LEAK_TRACKING)
#define DN_LeakTrackAlloc(leak, ptr, size, alloc_can_leak) DN_LeakTrackAlloc_(leak, ptr, size, alloc_can_leak)
#define DN_LeakTrackDealloc(leak, ptr) DN_LeakTrackDealloc_(leak, ptr)
#define DN_LeakDump(leak) DN_LeakDump(leak);
#define DN_LeakDump(leak) DN_LeakDump_(leak)
#else
#define DN_LeakTrackAlloc(leak, ptr, size, alloc_can_leak) do { (void)ptr; (void)size; (void)alloc_can_leak; } while (0)
#define DN_LeakTrackDealloc(leak, ptr) do { (void)ptr; } while (0)
@@ -6330,8 +6330,9 @@ enum DN_InitFlags_
{
DN_InitFlags_Nil = 0,
DN_InitFlags_OS = 1 << 0,
DN_InitFlags_LogLibFeatures = 1 << 1,
DN_InitFlags_LogCPUFeatures = 1 << 2,
DN_InitFlags_OSLeakTracker = 1 << 1,
DN_InitFlags_LogLibFeatures = 1 << 2,
DN_InitFlags_LogCPUFeatures = 1 << 3,
DN_InitFlags_LogAllFeatures = DN_InitFlags_LogLibFeatures | DN_InitFlags_LogCPUFeatures,
};