emscripten: Restore compatibility with existing emsdk releases. (cherry picked from commit 5008521538ffe7931ecd0d11c4a5e75a05f54b5b)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index f036fc3..fe7619b 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -42,7 +42,15 @@
#endif
#if defined(__EMSCRIPTEN__)
-#include <emscripten.h>
+ #include <emscripten.h>
+ /* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
+ #ifndef MAIN_THREAD_EM_ASM_PTR
+ #ifdef __wasm64__
+ #error You need to upgrade your Emscripten compiler to support wasm64
+ #else
+ #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
+ #endif
+ #endif
#endif
/* The size of the stack buffer to use for rendering assert messages. */
@@ -251,7 +259,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
for (;;) {
SDL_bool okay = SDL_TRUE;
/* *INDENT-OFF* */ /* clang-format off */
- char *buf = (char *) EM_ASM_PTR({
+ char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
var str =
UTF8ToString($0) + '\n\n' +
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c
index a5a5e58..51829d4 100644
--- a/src/video/emscripten/SDL_emscriptenmouse.c
+++ b/src/video/emscripten/SDL_emscriptenmouse.c
@@ -31,6 +31,15 @@
#include "../../events/SDL_mouse_c.h"
+/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
+#ifndef MAIN_THREAD_EM_ASM_PTR
+ #ifdef __wasm64__
+ #error You need to upgrade your Emscripten compiler to support wasm64
+ #else
+ #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
+ #endif
+#endif
+
static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL_bool is_custom)
{
SDL_Cursor *cursor;