aboutsummaryrefslogtreecommitdiff
path: root/stdlib/stdlib.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-24 16:13:23 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-24 16:13:23 -0500
commit0e10313d64f54dd587ebbcd5f413bd999333c911 (patch)
tree16a07c4b01467d59807611b23f91f9eb125959e2 /stdlib/stdlib.c
parent6ecf6a272446af04f3affd354520d21127a5b952 (diff)
Switch `NaN` to be identical to the null value
Diffstat (limited to 'stdlib/stdlib.c')
-rw-r--r--stdlib/stdlib.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c
index 5dac3d3a..0e72dfc4 100644
--- a/stdlib/stdlib.c
+++ b/stdlib/stdlib.c
@@ -27,6 +27,18 @@
public bool USE_COLOR;
+static void signal_handler(int sig, siginfo_t *, void *)
+{
+ assert(sig == SIGILL);
+ fflush(stdout);
+ if (USE_COLOR) fputs("\x1b[31;7m ===== ILLEGAL INSTRUCTION ===== \n\n\x1b[m", stderr);
+ else fputs("===== ILLEGAL INSTRUCTION =====\n\n", stderr);
+ print_stack_trace(stderr, 3, 4);
+ fflush(stderr);
+ raise(SIGABRT);
+ _exit(1);
+}
+
public void tomo_init(void)
{
GC_INIT();
@@ -44,6 +56,12 @@ public void tomo_init(void)
if (register_printf_specifier('k', printf_text, printf_text_size))
errx(1, "Couldn't set printf specifier");
+
+ struct sigaction sigact;
+ sigact.sa_sigaction = signal_handler;
+ sigemptyset(&sigact.sa_mask);
+ sigact.sa_flags = 0;
+ sigaction(SIGILL, &sigact, (struct sigaction *)NULL);
}
static bool parse_single_arg(const TypeInfo_t *info, char *arg, void *dest)