aboutsummaryrefslogtreecommitdiffstats
path: root/tests/checkasm/checkasm.h
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi@remlab.net>2023-07-12 22:48:53 +0300
committerRémi Denis-Courmont <remi@remlab.net>2023-11-23 19:04:07 +0200
commit7212466e735aa187d82f51dadbce957fe3da77f0 (patch)
tree1b33d3ea67fd8493389ec244824520029323767c /tests/checkasm/checkasm.h
parent286d6742218ba0235c32876b50bf593cb1986353 (diff)
downloadffmpeg-7212466e735aa187d82f51dadbce957fe3da77f0.tar.gz
checkasm/riscv: report an error upon SIGILL
Terminating the whole checkasm process is not very helpful. This will report if an illegal instruction occurs while executing a tested function. This is a common occurrence whilst developping RISC-V assembler, due to the compatibility between vector configuration and instruction done at run-time.
Diffstat (limited to 'tests/checkasm/checkasm.h')
-rw-r--r--tests/checkasm/checkasm.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 8a1df43ab6..41093f2dca 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -23,6 +23,7 @@
#ifndef TESTS_CHECKASM_CHECKASM_H
#define TESTS_CHECKASM_CHECKASM_H
+#include <setjmp.h>
#include <stdint.h>
#include "config.h"
@@ -211,14 +212,20 @@ void checkasm_checked_call(void *func, ...);
checked_call(func_new, 0, 0, 0, 0, 0, 0, 0, __VA_ARGS__,\
7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0))
#elif ARCH_RISCV
-void checkasm_set_function(void *);
+void checkasm_set_function(void *, sigjmp_buf);
void *checkasm_get_wrapper(void);
+void checkasm_handle_signal(int signum);
#if (__riscv_xlen == 64) && defined (__riscv_d)
#define declare_new(ret, ...) \
+ int checked_call_signum = 0; \
+ sigjmp_buf checked_call_jb; \
ret (*checked_call)(__VA_ARGS__) = checkasm_get_wrapper();
#define call_new(...) \
- (checkasm_set_function(func_new), checked_call(__VA_ARGS__))
+ (checkasm_set_function(func_new, checked_call_jb), \
+ (checked_call_signum = sigsetjmp(checked_call_jb, 1)) == 0 \
+ ? checked_call(__VA_ARGS__) \
+ : (checkasm_fail_signal(checked_call_signum), 0))
#endif
#else
#define declare_new(ret, ...)