Read totk.ini in mem_init before the pool size: the size asks resolution.c, which decides output_res and render_scale once on that first call, and main read the file only after mem_init, so both settings from totk.ini and the menu were ignored and only TOTK_* environment variables reached them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-28 21:45:48 +03:00
1 parent 3af201b43b
commit 1274fb65d8
3 files changed
+5 -3

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
// is kept). A name without the TOTK_ prefix goes to getenv unchanged. Safe from any thread once cfg_init has returned.
const char *cfg_get(const char *name);
// Reads totk.ini once, first thing in main. Logs the file, its key count, unknown keys and environment overrides.
// Reads totk.ini once, from mem_init after the address space is claimed and before any setting is read. Logs the file, its key count, unknown keys and environment overrides.
void cfg_init(void);
// Replaces the loaded keys with those of the file at path (tests). 1 when the file was read, 0 when missing.
+1 -2
View File
@@ -427,10 +427,9 @@ static void portable_paths(RtConfig *c) {
}
int main(int argc, char **argv) {
mem_init(); // first: claim the guest address space before anything else can land there
mem_init(); // first: claim the guest address space before anything else can land there; reads totk.ini
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
cfg_init(); // before any setting is read
AddVectoredExceptionHandler(0, crash_handler);
parse_trace();
prof_start();
+3
View File
@@ -253,6 +253,9 @@ void mem_init(void) {
AddVectoredExceptionHandler(1, thaw_handler); // before the crash handler
alias_pages = VirtualAlloc(NULL, ALIAS_PAGES, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (!alias_pages) rt_fatal("memory: cannot allocate the alias page map");
// totk.ini is read here, once the address space is claimed and before the first setting: the pool size below
// depends on TOTK_APP_POOL and on the resolution settings (resolution.c decides them once, on this first call).
cfg_init();
const char *pool = cfg_get("TOTK_APP_POOL");
L = (RtGuestLayout){
.aslr = {low, RT_ADDRESS_LIMIT - low},