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
This commit is contained in:
YAMAMOTO Takashi 2022-04-27 17:22:43 +09:00 committed by GitHub
parent 2fe83e29cd
commit 5343411623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2687,11 +2687,84 @@ wasmtime_ssp_proc_raise(__wasi_signal_t sig)
{ {
static const int signals[] = { static const int signals[] = {
#define X(v) [__WASI_##v] = v #define X(v) [__WASI_##v] = v
X(SIGABRT), X(SIGALRM), X(SIGBUS), X(SIGCHLD), X(SIGCONT), X(SIGFPE), #if defined(SIGABRT)
X(SIGHUP), X(SIGILL), X(SIGINT), X(SIGKILL), X(SIGPIPE), X(SIGQUIT), X(SIGABRT),
X(SIGSEGV), X(SIGSTOP), X(SIGSYS), X(SIGTERM), X(SIGTRAP), X(SIGTSTP), #endif
X(SIGTTIN), X(SIGTTOU), X(SIGURG), X(SIGUSR1), X(SIGUSR2), X(SIGVTALRM), #if defined(SIGALRM)
X(SIGXCPU), X(SIGXFSZ), 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 #undef X
}; };
if (sig >= sizeof(signals) / sizeof(signals[0]) || signals[sig] == 0) if (sig >= sizeof(signals) / sizeof(signals[0]) || signals[sig] == 0)