This commit is contained in:
Krzosa Karol
2023-03-28 21:43:28 +02:00
parent 5495f96b3b
commit 622a5bd487
9 changed files with 35 additions and 42 deletions

View File

@@ -57,33 +57,6 @@ os_decommit_pos(OS_Memory *m, size_t pos) {
return false;
}
CORE_Static void
test_os_memory() {
assert(align_down(4096, 4096) == 4096);
assert(align_down(4095, 4096) == 0);
OS_Memory memory = os_reserve(9000);
assert(memory.reserve == 4096 * 3 && memory.data && memory.commit == 0);
os_commit(&memory, 100);
assert(memory.commit == 4096);
os_commit(&memory, 100);
assert(memory.commit == 4096 * 2);
os_commit(&memory, 9000);
assert(memory.commit == 4096 * 3);
os_commit(&memory, 9000);
assert(memory.commit == 4096 * 3);
os_decommit_pos(&memory, 4096);
assert(memory.commit == 4096);
os_decommit_pos(&memory, 4096);
assert(memory.commit == 4096);
os_decommit_pos(&memory, 0);
assert(memory.commit == 0);
os_release(&memory);
assert(memory.data == 0);
}
//-----------------------------------------------------------------------------
// Time
//-----------------------------------------------------------------------------
@@ -241,3 +214,27 @@ os_list_dir(Arena *scratch, Allocator *a, String dir, U32 flags = LIST_NO_FLAGS)
return result;
}
bool os_enable_console_colors() {
// Set output mode to handle virtual terminal sequences
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut != INVALID_HANDLE_VALUE) {
DWORD dwMode = 0;
if (GetConsoleMode(hOut, &dwMode)) {
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (SetConsoleMode(hOut, dwMode)) {
return true;
}
else {
printf("Failed to enable colored terminal output C\n");
}
}
else {
printf("Failed to enable colored terminal output B\n");
}
}
else {
printf("Failed to enable colored terminal output A\n");
}
return false;
}