aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-08-23 15:16:04 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-08-27 11:44:07 +0200
commit03b645f22bfc7afadc5a8aa6d59edf0eba74a048 (patch)
treedda64286a408e104879be2544f9c7dc8aa8e333a /include
parent6836db9b00d4f13a78a53cc5bdb0b63028188b55 (diff)
cleanup & json string simd parsing
Diffstat (limited to 'include')
-rw-r--r--include/assert.h14
-rw-r--r--include/json.h2
-rw-r--r--include/types.h2
3 files changed, 17 insertions, 1 deletions
diff --git a/include/assert.h b/include/assert.h
new file mode 100644
index 0000000..ad9c2fd
--- /dev/null
+++ b/include/assert.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define assert(condition, ...) \
+ do { \
+ if (!(condition)) { \
+ fprintf(stderr, "Assertion failed: %s:%d in %s(): ", __FILE__, __LINE__, __func__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ abort(); \
+ } \
+ } while (0)
diff --git a/include/json.h b/include/json.h
index 9bd668e..52566ab 100644
--- a/include/json.h
+++ b/include/json.h
@@ -30,5 +30,5 @@ typedef struct {
} JSON;
JSON *JSONObject_get(JSONObject obj, Str key);
i32 JSON_fprint(FILE *w, JSON json);
-JSON JSON_parse(Arena *a, byte *src);
+JSON JSON_parse(Arena *a, byte *src, uptr len);
JSON JSON_Int(Arena *a, i32 val);
diff --git a/include/types.h b/include/types.h
index bacedf8..da3a093 100644
--- a/include/types.h
+++ b/include/types.h
@@ -1,6 +1,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <immintrin.h>
typedef ptrdiff_t size;
typedef char byte;
@@ -8,6 +9,7 @@ typedef uintptr_t uptr;
typedef int32_t i32;
typedef uint64_t u64;
typedef float f32;
+typedef __m256i byte_32;
#define sizeof(x) (size)sizeof(x)
#define countof(a) (sizeof(a) / sizeof(*(a)))