summaryrefslogtreecommitdiff
path: root/wasm2c/wasm-rt-impl.c
diff options
context:
space:
mode:
Diffstat (limited to 'wasm2c/wasm-rt-impl.c')
-rw-r--r--wasm2c/wasm-rt-impl.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c
index 72e4d66e..5f22d3bf 100644
--- a/wasm2c/wasm-rt-impl.c
+++ b/wasm2c/wasm-rt-impl.c
@@ -25,7 +25,8 @@
#include <stdlib.h>
#include <string.h>
-#if WASM_RT_INSTALL_SIGNAL_HANDLER && !defined(_WIN32)
+#if (WASM_RT_INSTALL_SIGNAL_HANDLER || !WASM_RT_USE_STACK_DEPTH_COUNT) && \
+ !defined(_WIN32)
#include <signal.h>
#include <unistd.h>
#endif
@@ -163,17 +164,7 @@ static void os_print_last_error(const char* msg) {
perror(msg);
}
-#if WASM_RT_INSTALL_SIGNAL_HANDLER
-static void os_signal_handler(int sig, siginfo_t* si, void* unused) {
- if (si->si_code == SEGV_ACCERR) {
- wasm_rt_trap(WASM_RT_TRAP_OOB);
- } else {
- wasm_rt_trap(WASM_RT_TRAP_EXHAUSTION);
- }
-}
-
#if !WASM_RT_USE_STACK_DEPTH_COUNT
-/* These routines set up an altstack to handle SIGSEGV from stack overflow. */
static bool os_has_altstack_installed() {
/* check for altstack already in place */
stack_t ss;
@@ -184,7 +175,19 @@ static bool os_has_altstack_installed() {
return !(ss.ss_flags & SS_DISABLE);
}
+#endif
+
+#if WASM_RT_INSTALL_SIGNAL_HANDLER
+static void os_signal_handler(int sig, siginfo_t* si, void* unused) {
+ if (si->si_code == SEGV_ACCERR) {
+ wasm_rt_trap(WASM_RT_TRAP_OOB);
+ } else {
+ wasm_rt_trap(WASM_RT_TRAP_EXHAUSTION);
+ }
+}
+#if !WASM_RT_USE_STACK_DEPTH_COUNT
+/* These routines set up an altstack to handle SIGSEGV from stack overflow. */
static void os_allocate_and_install_altstack(void) {
/* verify altstack not already allocated */
assert(!g_alt_stack &&