diff --git a/public/build.c b/public/build.c index 52710139..38dfd16c 100644 --- a/public/build.c +++ b/public/build.c @@ -119,6 +119,8 @@ const char *Q_PlatformStringByID( const int platform ) return "nswitch"; case PLATFORM_PSVITA: return "psvita"; + case PLATFORM_WASI: + return "wasi"; } assert( 0 ); @@ -204,6 +206,8 @@ const char *Q_ArchitectureStringByID( const int arch, const uint abi, const int return is64 ? "riscv64d" : "riscv32d"; } break; + case ARCHITECTURE_WASM: + return is64 ? "wasm64" : "wasm32"; } assert( 0 ); diff --git a/public/build.h b/public/build.h index 851939b5..718dc01a 100644 --- a/public/build.h +++ b/public/build.h @@ -85,6 +85,8 @@ Then you can use another oneliner to query all variables: #undef XASH_X86 #undef XASH_NSWITCH #undef XASH_PSVITA +#undef XASH_WASI +#undef XASH_WASM //================================================================ // @@ -126,6 +128,8 @@ Then you can use another oneliner to query all variables: #define XASH_NSWITCH 1 #elif defined __vita__ #define XASH_PSVITA 1 + #elif defined __wasi__ + #define XASH_WASI 1 #else #error #endif @@ -234,6 +238,11 @@ Then you can use another oneliner to query all variables: #else #error "Unknown RISC-V float ABI" #endif +#elif defined __wasm__ + #if defined __wasm64__ + #define XASH_64BIT 1 + #endif + #define XASH_WASM 1 #else #error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug" #endif diff --git a/public/buildenums.h b/public/buildenums.h index 5bdfdfb3..99a62b55 100644 --- a/public/buildenums.h +++ b/public/buildenums.h @@ -41,6 +41,7 @@ GNU General Public License for more details. #define PLATFORM_IRIX 12 #define PLATFORM_NSWITCH 13 #define PLATFORM_PSVITA 14 +#define PLATFORM_WASI 15 #if XASH_WIN32 #define XASH_PLATFORM PLATFORM_WIN32 @@ -70,6 +71,8 @@ GNU General Public License for more details. #define XASH_PLATFORM PLATFORM_NSWITCH #elif XASH_PSVITA #define XASH_PLATFORM PLATFORM_PSVITA +#elif XASH_WASI + #define XASH_PLATFORM PLATFORM_WASI #else #error #endif @@ -87,6 +90,7 @@ GNU General Public License for more details. #define ARCHITECTURE_E2K 7 #define ARCHITECTURE_RISCV 8 #define ARCHITECTURE_PPC 9 +#define ARCHITECTURE_WASM 10 #if XASH_AMD64 #define XASH_ARCHITECTURE ARCHITECTURE_AMD64 @@ -104,6 +108,8 @@ GNU General Public License for more details. #define XASH_ARCHITECTURE ARCHITECTURE_RISCV #elif XASH_PPC #define XASH_ARCHITECTURE ARCHITECTURE_PPC +#elif XASH_WASM + #define XASH_ARCHITECTURE ARCHITECTURE_WASM #else #error #endif diff --git a/public/tests/test_build.c b/public/tests/test_build.c index e2f148f4..016505dc 100644 --- a/public/tests/test_build.c +++ b/public/tests/test_build.c @@ -24,6 +24,7 @@ static struct { PLATFORM_IRIX, "irix" }, { PLATFORM_NSWITCH, "nswitch" }, { PLATFORM_PSVITA, "psvita" }, +{ PLATFORM_WASI, "wasi" }, }; static struct @@ -40,6 +41,10 @@ static struct { ARCHITECTURE_E2K, 0, -1, -1, "e2k" }, { ARCHITECTURE_JS, 0, -1, -1, "javascript" }, +// all possible WebAssembly names +{ ARCHITECTURE_WASM, 0, -1, true, "wasm64" }, +{ ARCHITECTURE_WASM, 0, -1, false, "wasm32" }, + // all possible MIPS names { ARCHITECTURE_MIPS, 0, ENDIANNESS_BIG, true, "mips64" }, { ARCHITECTURE_MIPS, 0, ENDIANNESS_BIG, false, "mips" },