History

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'

Zhao Zhili committed 1 year ago

Commit ea3d21c1 parent 2dc55f52 files · +21 −2Browse files

Unified · Split

2 files
  1. tests/checkasm/checkasm.c +8 −0
  2. tests/checkasm/checkasm.h +13 −2
tests/checkasm/checkasm.c+8−0
@@ -363,6 +363,8 @@ static const struct { · 362 unmodified lines
363#elif ARCH_LOONGARCH363#elif ARCH_LOONGARCH
364 { "LSX", "lsx", AV_CPU_FLAG_LSX },364 { "LSX", "lsx", AV_CPU_FLAG_LSX },
365 { "LASX", "lasx", AV_CPU_FLAG_LASX },365 { "LASX", "lasx", AV_CPU_FLAG_LASX },
366#elif ARCH_WASM
367 { "SIMD128", "simd128", AV_CPU_FLAG_SIMD128 },
366#endif368#endif
367 { NULL }369 { NULL }
368};370};
@@ -770,6 +772,8 @@ static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) { · 401 unmodified lines
770}772}
771#endif773#endif
772#else774#else
775
776#ifndef _WASI_EMULATED_SIGNAL
773static void signal_handler(int s);777static void signal_handler(int s);
774 778
775static const struct sigaction signal_handler_act = {779static const struct sigaction signal_handler_act = {
@@ -784,6 +788,8 @@ static void signal_handler(int s) { · 8 unmodified lines
784 checkasm_load_context(s);788 checkasm_load_context(s);
785 }789 }
786}790}
791#endif // _WASI_EMULATED_SIGNAL
792
787#endif793#endif
788 794
789/* Compares a string with a wildcard pattern. */795/* Compares a string with a wildcard pattern. */
@@ -933,10 +939,12 @@ int main(int argc, char *argv[]) · 143 unmodified lines
933 AddVectoredExceptionHandler(0, signal_handler);939 AddVectoredExceptionHandler(0, signal_handler);
934#endif940#endif
935#else941#else
942#ifndef _WASI_EMULATED_SIGNAL
936 sigaction(SIGBUS, &signal_handler_act, NULL);943 sigaction(SIGBUS, &signal_handler_act, NULL);
937 sigaction(SIGFPE, &signal_handler_act, NULL);944 sigaction(SIGFPE, &signal_handler_act, NULL);
938 sigaction(SIGILL, &signal_handler_act, NULL);945 sigaction(SIGILL, &signal_handler_act, NULL);
939 sigaction(SIGSEGV, &signal_handler_act, NULL);946 sigaction(SIGSEGV, &signal_handler_act, NULL);
947#endif // _WASI_EMULATED_SIGNAL
940#endif948#endif
941#if HAVE_PRCTL && defined(PR_SET_UNALIGN)949#if HAVE_PRCTL && defined(PR_SET_UNALIGN)
942 prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);950 prctl(PR_SET_UNALIGN, PR_UNALIGN_SIGBUS);
tests/checkasm/checkasm.h+13−2
@@ -66,12 +66,23 @@ typedef struct { CONTEXT c; int status; } checkasm_context; · 65 unmodified lines
66#define checkasm_save_context() 066#define checkasm_save_context() 0
67#define checkasm_load_context() do {} while (0)67#define checkasm_load_context() do {} while (0)
68#endif68#endif
69#else69#else // _WIN32
70
71#ifdef _WASI_EMULATED_SIGNAL
72
73#define checkasm_context void*
74#define checkasm_save_context() 0
75#define checkasm_load_context() do {} while (0)
76
77#else // _WASI_EMULATED_SIGNAL
78
70#include <setjmp.h>79#include <setjmp.h>
71typedef sigjmp_buf checkasm_context;80typedef sigjmp_buf checkasm_context;
72#define checkasm_save_context() checkasm_handle_signal(sigsetjmp(checkasm_context_buf, 1))81#define checkasm_save_context() checkasm_handle_signal(sigsetjmp(checkasm_context_buf, 1))
73#define checkasm_load_context(s) siglongjmp(checkasm_context_buf, s)82#define checkasm_load_context(s) siglongjmp(checkasm_context_buf, s)
74#endif83#endif // _WASI_EMULATED_SIGNAL
84
85#endif // _WIN32
75 86
76void checkasm_check_aacencdsp(void);87void checkasm_check_aacencdsp(void);
77void checkasm_check_aacpsdsp(void);88void checkasm_check_aacpsdsp(void);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t