From 5343411623897c4f0ed2b14220f1be619c9d2adc Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 27 Apr 2022 17:22:43 +0900 Subject: [PATCH] libc-wasi/sandboxed-system-primitives: Convert signals only when available (#1125) Many of these signal constants are not available on NuttX. Maybe we can remove these signal stuff sooner or later: https://github.com/WebAssembly/WASI/issues/7 https://github.com/WebAssembly/wasi-libc/pull/278 --- .../sandboxed-system-primitives/src/posix.c | 83 +++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index e55d6301..b802d6c0 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -2687,11 +2687,84 @@ wasmtime_ssp_proc_raise(__wasi_signal_t sig) { static const int signals[] = { #define X(v) [__WASI_##v] = v - X(SIGABRT), X(SIGALRM), X(SIGBUS), X(SIGCHLD), X(SIGCONT), X(SIGFPE), - X(SIGHUP), X(SIGILL), X(SIGINT), X(SIGKILL), X(SIGPIPE), X(SIGQUIT), - X(SIGSEGV), X(SIGSTOP), X(SIGSYS), X(SIGTERM), X(SIGTRAP), X(SIGTSTP), - X(SIGTTIN), X(SIGTTOU), X(SIGURG), X(SIGUSR1), X(SIGUSR2), X(SIGVTALRM), - X(SIGXCPU), X(SIGXFSZ), +#if defined(SIGABRT) + X(SIGABRT), +#endif +#if defined(SIGALRM) + X(SIGALRM), +#endif +#if defined(SIGBUS) + X(SIGBUS), +#endif +#if defined(SIGCHLD) + X(SIGCHLD), +#endif +#if defined(SIGCONT) + X(SIGCONT), +#endif +#if defined(SIGFPE) + X(SIGFPE), +#endif +#if defined(SIGHUP) + X(SIGHUP), +#endif +#if defined(SIGILL) + X(SIGILL), +#endif +#if defined(SIGINT) + X(SIGINT), +#endif +#if defined(SIGKILL) + X(SIGKILL), +#endif +#if defined(SIGPIPE) + X(SIGPIPE), +#endif +#if defined(SIGQUIT) + X(SIGQUIT), +#endif +#if defined(SIGSYS) + X(SIGSEGV), +#endif +#if defined(SIGSTOP) + X(SIGSTOP), +#endif +#if defined(SIGSYS) + X(SIGSYS), +#endif +#if defined(SIGTERM) + X(SIGTERM), +#endif +#if defined(SIGTRAP) + X(SIGTRAP), +#endif +#if defined(SIGTSTP) + X(SIGTSTP), +#endif +#if defined(SIGTTIN) + X(SIGTTIN), +#endif +#if defined(SIGTTOU) + X(SIGTTOU), +#endif +#if defined(SIGURG) + X(SIGURG), +#endif +#if defined(SIGUSR1) + X(SIGUSR1), +#endif +#if defined(SIGUSR2) + X(SIGUSR2), +#endif +#if defined(SIGVTALRM) + X(SIGVTALRM), +#endif +#if defined(SIGXCPU) + X(SIGXCPU), +#endif +#if defined(SIGXFSZ) + X(SIGXFSZ), +#endif #undef X }; if (sig >= sizeof(signals) / sizeof(signals[0]) || signals[sig] == 0)