[FFmpeg-devel] [PATCH 2/3] tests/checkasm: Add partial support for wasm

Zhao Zhili quinkblack at foxmail.com
Wed Nov 13 16:16:27 EET 2024


From: Zhao Zhili <zhilizhao at tencent.com>

WASI mssing signal and siglongjmp support. This patch workaround
build error and add simd128 flag. Please note that many tests use
large array on stack, so you need to increase the stack size when
build checkasm, e.g., --extra-ldflags='-Wl,-z,stack-size=10485760'
---
 tests/checkasm/checkasm.c |  8 ++++++++
 tests/checkasm/checkasm.h | 15 +++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index c9d2b5faf1..2fd482684a 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -358,6 +358,8 @@ static const struct {
 #elif ARCH_LOONGARCH
     { "LSX",      "lsx",      AV_CPU_FLAG_LSX },
     { "LASX",     "lasx",     AV_CPU_FLAG_LASX },
+#elif ARCH_WASM
+    { "SIMD128",    "simd128",  AV_CPU_FLAG_SIMD128 },
 #endif
     { NULL }
 };
@@ -765,6 +767,8 @@ static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) {
 }
 #endif
 #else
+
+#ifndef _WASI_EMULATED_SIGNAL
 static void signal_handler(int s);
 
 static const struct sigaction signal_handler_act = {
@@ -779,6 +783,8 @@ static void signal_handler(int s) {
         checkasm_load_context(s);
     }
 }
+#endif // _WASI_EMULATED_SIGNAL
+
 #endif
 
 /* Compares a string with a wildcard pattern. */
@@ -928,10 +934,12 @@ int main(int argc, char *argv[])
     AddVectoredExceptionHandler(0, signal_handler);
 #endif
 #else
+#ifndef _WASI_EMULATED_SIGNAL
     sigaction(SIGBUS,  &signal_handler_act, NULL);
     sigaction(SIGFPE,  &signal_handler_act, NULL);
     sigaction(SIGILL,  &signal_handler_act, NULL);
     sigaction(SIGSEGV, &signal_handler_act, NULL);
+#endif // _WASI_EMULATED_SIGNAL
 #endif
 #if HAVE_PRCTL && defined(PR_SET_UNALIGN)
     prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 866eef01e9..8cf709107d 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -66,12 +66,23 @@ typedef struct { CONTEXT c; int status; } checkasm_context;
 #define checkasm_save_context() 0
 #define checkasm_load_context() do {} while (0)
 #endif
-#else
+#else  // _WIN32
+
+#ifdef _WASI_EMULATED_SIGNAL
+
+#define checkasm_context void*
+#define checkasm_save_context() 0
+#define checkasm_load_context() do {} while (0)
+
+#else  // _WASI_EMULATED_SIGNAL
+
 #include <setjmp.h>
 typedef sigjmp_buf checkasm_context;
 #define checkasm_save_context() checkasm_handle_signal(sigsetjmp(checkasm_context_buf, 1))
 #define checkasm_load_context(s) siglongjmp(checkasm_context_buf, s)
-#endif
+#endif  // _WASI_EMULATED_SIGNAL
+
+#endif  // _WIN32
 
 void checkasm_check_aacencdsp(void);
 void checkasm_check_aacpsdsp(void);
-- 
2.46.0



More information about the ffmpeg-devel mailing list