aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--src/badlib.h17
-rw-r--r--src/main.c2
3 files changed, 11 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index c3ab930..97a1814 100644
--- a/Makefile
+++ b/Makefile
@@ -26,9 +26,9 @@ BIN := $(BUILD_DIR)/$(TARGET)
26 26
27# Compiler and linker configuration. 27# Compiler and linker configuration.
28CC := cc 28CC := cc
29CFLAGS := -Wall -Wextra -pedantic -std=c11 -DBIN_NAME=\"$(TARGET)\" 29CFLAGS := -Wall -Wextra -std=gnu11 -DBIN_NAME=\"$(TARGET)\"
30CFLAGS += $(INC_FLAGS) 30CFLAGS += $(INC_FLAGS)
31LDFLAGS := 31LDFLAGS := -lm
32LDLIBS := 32LDLIBS :=
33RELEASE_CFLAGS := -DNDEBUG -O2 33RELEASE_CFLAGS := -DNDEBUG -O2
34DEBUG_CFLAGS := -DDEBUG -g -fsanitize=address,undefined 34DEBUG_CFLAGS := -DDEBUG -g -fsanitize=address,undefined
diff --git a/src/badlib.h b/src/badlib.h
index 25e4914..c47f2b9 100644
--- a/src/badlib.h
+++ b/src/badlib.h
@@ -20,7 +20,9 @@
20#include <stdint.h> 20#include <stdint.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <strings.h> 23#include <string.h>
24#include <time.h>
25#include <unistd.h>
24 26
25// 27//
26// Basic types. 28// Basic types.
@@ -43,7 +45,7 @@ typedef ptrdiff_t sz;
43typedef uintptr_t ptrsize; 45typedef uintptr_t ptrsize;
44typedef size_t usize; 46typedef size_t usize;
45 47
46#define KB(N) ((sz)(N)*1024) 48#define KB(N) ((sz)(N) * 1024)
47#define MB(N) ((sz)KB(N) * 1024) 49#define MB(N) ((sz)KB(N) * 1024)
48#define GB(N) ((sz)MB(N) * 1024) 50#define GB(N) ((sz)MB(N) * 1024)
49#define TB(N) ((sz)GB(N) * 1024) 51#define TB(N) ((sz)GB(N) * 1024)
@@ -287,9 +289,9 @@ buf_pop(Buf *buf, void *dst, sz size) {
287typedef Array Str; 289typedef Array Str;
288 290
289// Create a string object from a C literal. 291// Create a string object from a C literal.
290#define cstr(s) \ 292#define cstr(s) \
291 (Str) { \ 293 (Str) { \
292 (u8 *)(s), LEN(s) - 1 \ 294 .mem = (u8 *)(s), .size = LEN(s) - 1, \
293 } 295 }
294 296
295// Create a string object from a char* array. 297// Create a string object from a char* array.
@@ -945,7 +947,7 @@ _int_eq(sz a, sz b) {
945 return a == b; 947 return a == b;
946} 948}
947 949
948bool 950u64
949_int_hash(sz a) { 951_int_hash(sz a) {
950 return a * UINT64_C(11400714819323198485); 952 return a * UINT64_C(11400714819323198485);
951} 953}
@@ -1235,9 +1237,6 @@ Allocator os_allocator = {
1235 .free = platform_free, 1237 .free = platform_free,
1236}; 1238};
1237 1239
1238#include <time.h>
1239#include <unistd.h>
1240
1241void 1240void
1242platform_sleep(size_t microseconds) { 1241platform_sleep(size_t microseconds) {
1243 usleep(microseconds); 1242 usleep(microseconds);
diff --git a/src/main.c b/src/main.c
index 618d325..e14ef43 100644
--- a/src/main.c
+++ b/src/main.c
@@ -171,7 +171,7 @@ process_file(Str path) {
171 array_zero(chunk.constants, 256, &bytecode_arena); 171 array_zero(chunk.constants, 256, &bytecode_arena);
172 array_zero(chunk.code, 0xffff, &bytecode_arena); 172 array_zero(chunk.code, 0xffff, &bytecode_arena);
173 sz n_roots = array_size(parser.nodes); 173 sz n_roots = array_size(parser.nodes);
174 CompResult res; 174 CompResult res = {0};
175 for (sz i = 0; i < n_roots; i++) { 175 for (sz i = 0; i < n_roots; i++) {
176 // The parser stores the root nodes as a stack. 176 // The parser stores the root nodes as a stack.
177 Node *root = parser.nodes[i]; 177 Node *root = parser.nodes[i];