From 16e80b04a762e57fb2dafd2db0e5a8de5bfbee7f Mon Sep 17 00:00:00 2001 From: X512 Date: Wed, 13 Apr 2022 22:41:57 +0900 Subject: [PATCH] kernel: add missing support of simple signal handler for riscv64 Change-Id: Iab9d09344a99013b381b64d5438ded0a083b3a52 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5202 Reviewed-by: Rene Gollent Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/system/kernel/arch/riscv64/arch_commpage.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/arch/riscv64/arch_commpage.cpp b/src/system/kernel/arch/riscv64/arch_commpage.cpp index 6a5c039aba..8ad16a5965 100644 --- a/src/system/kernel/arch/riscv64/arch_commpage.cpp +++ b/src/system/kernel/arch/riscv64/arch_commpage.cpp @@ -18,15 +18,17 @@ extern "C" void arch_user_thread_exit(); -typedef void (*SignalHandler)(int signal, siginfo_t* signalInfo, - ucontext_t* ctx); - -extern "C" void +extern "C" void __attribute__((noreturn)) arch_user_signal_handler(signal_frame_data* data) { - SignalHandler handler = (SignalHandler)data->handler; - handler(data->info.si_signo, &data->info, &data->context); + if (data->siginfo_handler) { + auto handler = (void (*)(int, siginfo_t*, void*, void*))data->handler; + handler(data->info.si_signo, &data->info, &data->context, data->user_data); + } else { + auto handler = (void (*)(int, void*, vregs*))data->handler; + handler(data->info.si_signo, data->user_data, &data->context.uc_mcontext); + } #define TO_STRING_LITERAL_HELPER(number) #number #define TO_STRING_LITERAL(number) TO_STRING_LITERAL_HELPER(number) @@ -41,6 +43,8 @@ arch_user_signal_handler(signal_frame_data* data) #undef TO_STRING_LITERAL_HELPER #undef TO_STRING_LITERAL + + __builtin_unreachable(); }