Add stubs, wanted to compile to wasm

This commit is contained in:
Krzosa Karol
2024-03-15 16:23:33 +01:00
parent 0c4d19c9b8
commit 1b48585308
4 changed files with 36 additions and 5 deletions

View File

@@ -434,7 +434,7 @@ MA_API bool MV_DecommitPos(MV_Memory *m, size_t pos) {
return false;
}
#else
#elif __unix__ || __linux__ || __APPLE__
#include <sys/mman.h>
#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

View File

@@ -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 <stdio.h>
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

View File

@@ -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