From ea3d21c349db5bbfee7840857de81e4b2fc757fa Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Wed, 20 Nov 2024 20:45:35 +0800 Subject: [PATCH] tests/checkasm: Add partial support for wasm 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' Signed-off-by: Zhao Zhili --- 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 f30c53cec2..544e3ee9ba 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -363,6 +363,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 } }; @@ -770,6 +772,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 = { @@ -784,6 +788,8 @@ static void signal_handler(int s) { checkasm_load_context(s); } } +#endif // _WASI_EMULATED_SIGNAL + #endif /* Compares a string with a wildcard pattern. */ @@ -933,10 +939,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 0ba5c3040d..a1bd19c54a 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 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);