[FFmpeg-devel] [PATCH] tests/checkasm: Simplify logic for WASI signal handling
Zhao Zhili
quinkblack at foxmail.com
Wed Dec 4 13:36:47 EET 2024
From: Zhao Zhili <zhilizhao at tencent.com>
---
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 <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 // _WASI_EMULATED_SIGNAL
-
-#endif // _WIN32
+#endif
void checkasm_check_aacencdsp(void);
void checkasm_check_aacpsdsp(void);
--
2.46.0
More information about the ffmpeg-devel
mailing list