Commit: 29bd43ea39daa74725499b178b4050610efdf7bb
Parent: b9d57c873356ce080dd0ac539c663b082f9689cd
Author: Randy Palamar
Date: Tue, 15 Oct 2024 08:18:11 -0600
remove stdlib.h
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/jdict.c b/jdict.c
@@ -2,7 +2,6 @@
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
-#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -23,6 +22,10 @@ typedef ptrdiff_t size;
#define ASSERT(c) {}
#endif
+#ifndef unreachable
+#define unreachable() __builtin_unreachable()
+#endif
+
#define ARRAY_COUNT(a) (sizeof(a) / sizeof(*a))
#define ISSPACE(c) ((c) == ' ' || (c) == '\n' || (c) == '\t')
@@ -84,6 +87,7 @@ typedef struct {
#define os_path_sep s8("/")
static b32 os_write(i32, s8);
+static void __attribute__((noreturn)) os_exit(i32);
static Stream error_stream;
@@ -139,7 +143,14 @@ die(Stream *s)
if (s->data[s->widx - 1] != '\n')
stream_append_byte(s, '\n');
stream_flush(s);
- exit(1);
+ os_exit(1);
+}
+
+static void
+os_exit(i32 code)
+{
+ _exit(code);
+ unreachable();
}
static Arena