Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/kernel/src/wasm/posix/string.zig
1068 views
1
pub fn keepalive() void {}
2
const string = @cImport(@cInclude("string.h"));
3
const std = @import("std");
4
const expect = std.testing.expect;
5
6
// This was fun to write, but it's also built into zig via -lwasi-emulated-signal
7
// export fn strsignal(sig: c_int) [*:0]const u8 {
8
// if (sig <= 0 or sig > 31) {
9
// return "SIGINVALID";
10
// }
11
// const SIGNALS: [32]([*:0]const u8) = .{ "SIGINVALID", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF", "SIGWINCH", "SIGPOLL", "SIGPWR", "SIGSYS" };
12
// const n = @intCast(usize, sig);
13
// return SIGNALS[n];
14
// }
15
16
// test "strsignal" {
17
// try expect(strsignal(1) == "SIGHUP");
18
// try expect(strsignal(2) == "SIGINT");
19
// try expect(strsignal(0) == "SIGINVALID");
20
// try expect(strsignal(32) == "SIGINVALID");
21
// try expect(strsignal(31) == "SIGSYS");
22
// }
23
24