diff --git a/core/filesystem.c b/core/filesystem.c index 4da300c..baa6d6e 100644 --- a/core/filesystem.c +++ b/core/filesystem.c @@ -381,7 +381,7 @@ OS_API OS_Date OS_GetDate(void) { return result; } -#else +#elif __linux__ || __APPLE__ || __unix__ #include #include #include @@ -690,9 +690,9 @@ OS_API OS_Result OS_WriteFile(S8_String path, S8_String string) { return result; } #endif - #endif +#if _WIN32 || __linux__ || __APPLE__ || __unix__ OS_API int OS_SystemF(const char *string, ...) { MA_Checkpoint scratch = MA_GetScratch(); S8_FORMAT(scratch.arena, string, result); @@ -746,3 +746,4 @@ OS_API S8_String OS_ExpandIncludes(MA_Arena *arena, S8_String filepath) { } return result; } +#endif \ No newline at end of file diff --git a/standalone_libraries/arena.c b/standalone_libraries/arena.c index 0cc8d67..fced116 100644 --- a/standalone_libraries/arena.c +++ b/standalone_libraries/arena.c @@ -434,7 +434,7 @@ MA_API bool MV_DecommitPos(MV_Memory *m, size_t pos) { return false; } -#else +#elif __unix__ || __linux__ || __APPLE__ #include #define MV__UNIX_PAGE_SIZE 4096 MA_API MV_Memory MV_Reserve(size_t size) { @@ -465,4 +465,17 @@ MA_API void MV_Deallocate(MV_Memory *m) { int result = munmap(m->data, m->reserve); MA_Assertf(result == 0, "Failed to release virtual memory using munmap"); } +#else +MA_API MV_Memory MV_Reserve(size_t size) { + MV_Memory result = {0}; + return result; +} + +MA_API bool MV_Commit(MV_Memory *m, size_t commit) { + return false; +} + +MA_API void MV_Deallocate(MV_Memory *m) { +} + #endif \ No newline at end of file diff --git a/standalone_libraries/io.c b/standalone_libraries/io.c index b15f9b6..935c00b 100644 --- a/standalone_libraries/io.c +++ b/standalone_libraries/io.c @@ -203,9 +203,8 @@ IO_API IO_ErrorResult IO_OutputError(char *str, int len) { IO_API void IO_Exit(int error_code) { ExitProcess(error_code); } -#else // _WIN32 else // LIBC +#elif __linux__ || __unix__ || __APPLE__ #include - IO_API IO_ErrorResult IO_OutputError(char *str, int len) { fprintf(stderr, "%.*s", len, str); return IO_ErrorResult_Exit; @@ -222,4 +221,19 @@ IO_API void IO_Exit(int error_code) { IO_API bool IO_IsDebuggerPresent(void) { return false; } +#else +IO_API IO_ErrorResult IO_OutputError(char *str, int len) { + return IO_ErrorResult_Exit; +} + +IO_API void IO_OutputMessage(char *str, int len) { +} + +IO_API void IO_Exit(int error_code) { +} + +IO_API bool IO_IsDebuggerPresent(void) { + return false; +} + #endif // LIBC diff --git a/standalone_libraries/preproc_env.h b/standalone_libraries/preproc_env.h index a6a5383..77b8084 100644 --- a/standalone_libraries/preproc_env.h +++ b/standalone_libraries/preproc_env.h @@ -11,6 +11,7 @@ #elif defined(__linux__) #define OS_POSIX 1 #define OS_LINUX 1 +#elif OS_WASM #else #error Unsupported platform #endif @@ -109,6 +110,8 @@ #define OS_NAME "linux" #elif OS_MAC #define OS_NAME "mac_os" +#elif OS_WASM + #define OS_NAME "wasm" #else #error couldnt figure out OS #endif