From da1e4ff5eb50b713f2235b6b1ecfac78d4b69232 Mon Sep 17 00:00:00 2001
From: squidbus <175574877+squidbus@users.noreply.github.com>
Date: Mon, 16 Sep 2024 02:54:47 -0700
Subject: [PATCH] signals: Fix compilation on GCC. (#934)

---
 src/core/signals.cpp | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/core/signals.cpp b/src/core/signals.cpp
index 0d65f4f71..a16c150e9 100644
--- a/src/core/signals.cpp
+++ b/src/core/signals.cpp
@@ -59,7 +59,7 @@ static LONG WINAPI SignalHandler(EXCEPTION_POINTERS* pExp) noexcept {
 #endif
 
 #ifndef IS_WRITE_ERROR
-#error "Missing IS_WRITE_ERROR() implementation for target OS and CPU architecture.
+#error "Missing IS_WRITE_ERROR() implementation for target OS and CPU architecture."
 #endif
 
 static std::string DisassembleInstruction(void* code_address) {
@@ -120,9 +120,11 @@ SignalDispatch::SignalDispatch() {
     ASSERT_MSG(handle = AddVectoredExceptionHandler(0, SignalHandler),
                "Failed to register exception handler.");
 #else
-    constexpr struct sigaction action {
-        .sa_flags = SA_SIGINFO | SA_ONSTACK, .sa_sigaction = SignalHandler, .sa_mask = 0,
-    };
+    struct sigaction action {};
+    action.sa_sigaction = SignalHandler;
+    action.sa_flags = SA_SIGINFO | SA_ONSTACK;
+    sigemptyset(&action.sa_mask);
+
     ASSERT_MSG(sigaction(SIGSEGV, &action, nullptr) == 0 &&
                    sigaction(SIGBUS, &action, nullptr) == 0,
                "Failed to register access violation signal handler.");
@@ -135,9 +137,11 @@ SignalDispatch::~SignalDispatch() {
 #if defined(_WIN32)
     ASSERT_MSG(RemoveVectoredExceptionHandler(handle), "Failed to remove exception handler.");
 #else
-    constexpr struct sigaction action {
-        .sa_flags = 0, .sa_handler = SIG_DFL, .sa_mask = 0,
-    };
+    struct sigaction action {};
+    action.sa_handler = SIG_DFL;
+    action.sa_flags = 0;
+    sigemptyset(&action.sa_mask);
+
     ASSERT_MSG(sigaction(SIGSEGV, &action, nullptr) == 0 &&
                    sigaction(SIGBUS, &action, nullptr) == 0,
                "Failed to remove access violation signal handler.");