From 018ec4fe5f259253aad8736f9be29b3421a0d3e7 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Wed, 4 Dec 2024 19:36:47 +0800 Subject: [PATCH] tests/checkasm: Simplify logic for WASI signal handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhao Zhili Reviewed-by: Martin Storsjö --- tests/checkasm/checkasm.c | 10 ++-------- tests/checkasm/checkasm.h | 13 +++---------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 544e3ee9ba..b00c3c2a9f 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -771,9 +771,7 @@ static LONG NTAPI signal_handler(EXCEPTION_POINTERS *e) { return EXCEPTION_CONTINUE_EXECUTION; /* never reached, but shuts up gcc */ } #endif -#else - -#ifndef _WASI_EMULATED_SIGNAL +#elif !defined(_WASI_EMULATED_SIGNAL) static void signal_handler(int s); static const struct sigaction signal_handler_act = { @@ -788,8 +786,6 @@ static void signal_handler(int s) { checkasm_load_context(s); } } -#endif // _WASI_EMULATED_SIGNAL - #endif /* Compares a string with a wildcard pattern. */ @@ -938,13 +934,11 @@ int main(int argc, char *argv[]) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) AddVectoredExceptionHandler(0, signal_handler); #endif -#else -#ifndef _WASI_EMULATED_SIGNAL +#elif !defined(_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 a1bd19c54a..cb6333fd5b 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -66,23 +66,16 @@ typedef struct { CONTEXT c; int status; } checkasm_context; #define checkasm_save_context() 0 #define checkasm_load_context() do {} while (0) #endif -#else // _WIN32 - -#ifdef _WASI_EMULATED_SIGNAL - +#elif defined(_WASI_EMULATED_SIGNAL) #define checkasm_context void* #define checkasm_save_context() 0 #define checkasm_load_context() do {} while (0) - -#else // _WASI_EMULATED_SIGNAL - +#else #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 // _WASI_EMULATED_SIGNAL - -#endif // _WIN32 +#endif void checkasm_check_aacencdsp(void); void checkasm_check_aacpsdsp(void);