diff options
author | Ben Smith <binji@chromium.org> | 2020-07-21 13:39:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-21 13:39:04 -0700 |
commit | cd5ff133f84854f0b269f5cb06193ad8205f05d3 (patch) | |
tree | d8717f0e0978dc94e9f65109cd9a7c9414d2cbc7 /wasm2c/wasm-rt.h | |
parent | 4942d3b0b3281a2e3c1fa207ca7e62fc10c2fa88 (diff) | |
download | wabt-cd5ff133f84854f0b269f5cb06193ad8205f05d3.tar.gz wabt-cd5ff133f84854f0b269f5cb06193ad8205f05d3.tar.bz2 wabt-cd5ff133f84854f0b269f5cb06193ad8205f05d3.zip |
Completely disable signal handler on 32-bit (#1488)
The previous change prevented `WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX`
from being defined, but `WASM_RT_MEMCHECK_SIGNAL_HANDLER` was still
defined, which would prevent the memory bounds check.
Diffstat (limited to 'wasm2c/wasm-rt.h')
-rw-r--r-- | wasm2c/wasm-rt.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/wasm2c/wasm-rt.h b/wasm2c/wasm-rt.h index a2f70fc5..2797e8f7 100644 --- a/wasm2c/wasm-rt.h +++ b/wasm2c/wasm-rt.h @@ -35,28 +35,37 @@ extern "C" { #define WASM_RT_MAX_CALL_STACK_DEPTH 500 #endif -/** Whether to enable memory checking via a signal handler. +/** Enable memory checking via a signal handler via the following definition: + * + * #define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1 * * This is usually 10%-25% faster, but requires OS-specific support. * */ + +/** Check whether the signal handler is supported at all. */ +#if (defined(__linux__) || defined(__unix__) || defined(__APPLE__)) && \ + defined(__WORDSIZE) && __WORDSIZE == 64 + +/* If the signal handler is supported, then use it by default. */ #ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER #define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1 #endif #if WASM_RT_MEMCHECK_SIGNAL_HANDLER -#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) -#if defined(__WORDSIZE) && __WORDSIZE != 64 -#warning "Signal handler is only supported on 64-bit architectures" -#else #define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 1 #endif + #else -#error "No signal handler implementation for OS!" -#endif + +/* The signal handler is not supported, error out if the user was trying to + * enable it. */ +#if WASM_RT_MEMCHECK_SIGNAL_HANDLER +#error "Signal handler is not supported for this OS/Architecture!" #endif -#ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX +#define WASM_RT_MEMCHECK_SIGNAL_HANDLER 0 #define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 0 + #endif /** Reason a trap occurred. Provide this to `wasm_rt_trap`. */ |