From dc661b7d37740d7f852b9cdcfeb303f9cdaa9ad9 Mon Sep 17 00:00:00 2001
From: Alam Ed Arias <alam@srb2.org>
Date: Thu, 20 Mar 2025 10:08:29 -0400
Subject: [PATCH] Add support for emscripten SDK

---
 src/doomtype.h     | 2 +-
 src/sdl/i_system.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/doomtype.h b/src/doomtype.h
index 415669ac47..9edbd32316 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -110,7 +110,7 @@ int startswith (const char *base, const char *tag);
 int endswith (const char *base, const char *tag);
 char *xstrtok(char *line, const char *delims);
 
-#if defined (_WIN32) || defined (__HAIKU__)
+#if defined (_WIN32) || defined (__HAIKU__) || defined (__EMSCRIPTEN__)
 #define HAVE_DOSSTR_FUNCS
 #endif
 
diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index b2396e269b..f5e6614d7c 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -79,7 +79,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
 #define HAVE_SDLCPUINFO
 
 #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
-#if defined (__linux__) || defined (__HAIKU__)
+#if defined (__linux__) || defined (__HAIKU__) || defined (__EMSCRIPTEN__)
 #include <sys/statvfs.h>
 #else
 #include <sys/statvfs.h>
@@ -111,9 +111,11 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
 #include <errno.h>
 #include <sys/wait.h>
 #ifndef __HAIKU__ // haiku's crash dialog is just objectively better
+#ifndef __EMSCRIPTEN__ // WASM does not have a rell fork()
 #define NEWSIGNALHANDLER
 #endif
 #endif
+#endif
 
 #ifndef NOMUMBLE
 #ifdef __linux__ // need -lrt
@@ -145,12 +147,14 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
 #endif
 
 #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
+#if !defined (__EMSCRIPTEN__)
 #ifndef NOEXECINFO
 #include <execinfo.h>
 #endif
 #include <time.h>
 #define UNIXBACKTRACE
 #endif
+#endif
 
 // Locations to directly check for srb2.pk3 in
 const char *wadDefaultPaths[] = {
-- 
GitLab