IF_PLATFORM_WINDOWS

This commit is contained in:
krzosa
2024-12-29 11:04:17 +01:00
parent d7c5b72bb9
commit 061c59c865
2 changed files with 23 additions and 19 deletions

View File

@@ -78,23 +78,6 @@ b32 vmem_decommit(void *p, usize size) { return true; }
#if PLATFORM_WASM #if PLATFORM_WASM
f64 s8_deserial_f64(s8_t string); f64 s8_deserial_f64(s8_t string);
#else
f64 s8_deserial_f64(s8_t string) { return strtod(string.str, NULL); }
#endif
#if PLATFORM_WINDOWS
void core_log_message(char *string) {
if (IsDebuggerPresent()) {
OutputDebugStringA(string);
}
printf("%s", string);
fflush(stdout);
}
void core_panic(void) {
if (core_desc.on_exit) core_desc.on_exit();
ExitProcess(1);
}
#elif PLATFORM_WASM
void write_to_console(char *string); void write_to_console(char *string);
void core_log_message(char *string) { void core_log_message(char *string) {
write_to_console(string); write_to_console(string);
@@ -104,16 +87,21 @@ void core_panic(void) {
debug_break(); debug_break();
} }
#else #else
f64 s8_deserial_f64(s8_t string) { return strtod(string.str, NULL); }
void core_log_message(char *string) { void core_log_message(char *string) {
printf("%s"); IF_PLATFORM_WINDOWS(if (IsDebuggerPresent()) OutputDebugStringA(string));
printf("%s", string);
fflush(stdout); fflush(stdout);
} }
void core_panic(void) { void core_panic(void) {
if (core_desc.on_exit) core_desc.on_exit(); if (core_desc.on_exit) core_desc.on_exit();
debug_break(); IF_PLATFORM_WINDOWS(ExitProcess(1));
IF_NOT_PLATFORM_WINDOWS(exit(1));
} }
#endif #endif
void core_on_exit(void) { void core_on_exit(void) {
debugf("program panicked! exiting..."); debugf("program panicked! exiting...");
} }

View File

@@ -67,3 +67,19 @@
#ifndef PLATFORM_ADDRESS_SANITIZER #ifndef PLATFORM_ADDRESS_SANITIZER
#define PLATFORM_ADDRESS_SANITIZER 0 #define PLATFORM_ADDRESS_SANITIZER 0
#endif #endif
#if PLATFORM_WINDOWS
#define IF_PLATFORM_WINDOWS(x) x
#define IF_NOT_PLATFORM_WINDOWS(x)
#else
#define IF_PLATFORM_WINDOWS(x)
#define IF_NOT_PLATFORM_WINDOWS(x) x
#endif
#if PLATFORM_WASM
#define IF_PLATFORM_WASM(x) x
#define IF_NOT_PLATFORM_WASM(x)
#else
#define IF_PLATFORM_WASM(x)
#define IF_NOT_PLATFORM_WASM(x) x
#endif