G

G Programming Language
git clone http://git.omkov.net/G
Log | Tree | Refs | README | Download

AuthorJakob Wakeling <[email protected]>
Date2021-11-30 04:16:03
Commit80fbb0b870c897471b46600470a4d3cadff1615c
Parent32a469567dece618c708260d4165727c7d13b5b5

meta: Upgrade libcll to libutil

Diffstat

R src/cll/error.c -> src/util/error.c | 14 +++++++++++---
D src/cll/error.h | 22 ----------------------
R src/cll/fnv.c -> src/util/fnv.c | 3 ++-
R src/cll/fnv.h -> src/util/fnv.h | 10 +++++-----
R src/cll/optget.c -> src/util/optget.c | 4 ++--
R src/cll/optget.h -> src/util/optget.h | 9 +++++----
M src/compile.c | 6 ++----
M src/compile.h | 1 +
M src/keyword.c | 7 +++----
M src/lex.c | 15 ++++++++-------
M src/lex.h | 6 +++---
M src/llvm/gen.c | 6 +++---
M src/main.c | 5 +++--
M src/map.c | 7 +++----
M src/map.h | 2 +-
M src/parse.c | 3 +--
M src/parse.h | 2 +-
M src/type.h | 2 +-
A src/util/alloc.c | 23 +++++++++++++++++++++++
A src/util/alloc.h | 17 +++++++++++++++++
M src/util/ast.h | 6 +++---
A src/util/error.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M src/util/stack.h | 2 +-
D src/util/util.c | 10 ----------
M src/util/util.h | 79 ++++++++++++++++++++++++++++++++++++++-----------------------------------------
M src/value.c | 2 +-

26 files changed, 200 insertions, 125 deletions

diff --git a/src/cll/error.h b/src/cll/error.h
deleted file mode 100644
index 7abddba..0000000
--- a/src/cll/error.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// error.h, version 1.0.2
-// Error header file for OMKOV lib
-// Copyright (C) 2020, Jakob Wakeling
-// All rights reserved.
-
-
-
-#ifndef OMKOV_LIB_ERROR_H_38W06M3W
-#define OMKOV_LIB_ERROR_H_38W06M3W
-
-#include <stdbool.h>
-#include <stdnoreturn.h>
-
-extern char *A0;
-extern bool warned;
-
-extern noreturn void error(int status, const char *format, ...);
-extern void warn(const char *format, ...);
-
-extern char *serr(void);
-
-#endif // OMKOV_LIB_ERROR_H_38W06M3W
diff --git a/src/compile.c b/src/compile.c
index 8bb0de6..3bf7f33 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -9,10 +9,9 @@
 #include "llvm/llvm.h"
 #include "parse.h"
 #include "util/ast.h"
+#include "util/error.h"
 #include "util/util.h"
 
-#include "cll/error.h"
-
 #include <llvm-c/Core.h>
 
 #include <stdio.h>
@@ -20,7 +19,7 @@
 
 bool lflag = false, pflag = false;
 
-void compile(u8 *src, usize len) {
+void compile(u8 *src, UINT len) {
 	lex l = lex_init(src, len);
 	if (lflag) { lex_debug(&l); goto ret; }
 
diff --git a/src/compile.h b/src/compile.h
index e3c9131..0186009 100644
--- a/src/compile.h
+++ b/src/compile.h
@@ -12,7 +12,7 @@
 
 extern bool lflag, pflag;
 
-extern void compile(u8 *src, usize len);
+extern void compile(u8 *src, UINT len);
 extern void compile_file(const char *file);
 
 #endif // G_COMPILE_H_DSDZQ0ZM
diff --git a/src/keyword.c b/src/keyword.c
index ef37447..f560b2c 100644
--- a/src/keyword.c
+++ b/src/keyword.c
@@ -6,10 +6,9 @@
 

 #include "keyword.h"
+#include "util/fnv.h"
 #include "util/util.h"
 
-#include "cll/fnv.h"
-
 #include <string.h>
 
 typedef enum { KK_PROC, KK_RETURN, } kwd_k;
@@ -23,7 +22,7 @@ kwd *k_proc = &kwds[KK_PROC]; kwd *k_return = &kwds[KK_RETURN];
 
 /* Return pointer to keyword or null if invalid. */
 kwd *kwd_find(u64 hash) {
-	for (usize i = 0; i < sizeof (kwds) / sizeof (*kwds); ++i) {
+	for (UINT i = 0; i < sizeof (kwds) / sizeof (*kwds); ++i) {
 		if (hash == kwds[i].h) { return &kwds[i]; }
 	} return NULL;
 }
diff --git a/src/lex.c b/src/lex.c
index 3aaf23f..1b0db6c 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -8,11 +8,10 @@
 #include "keyword.h"
 #include "lex.h"
 #include "type.h"
+#include "util/error.h"
+#include "util/fnv.h"
 #include "util/util.h"
 
-#include "cll/error.h"
-#include "cll/fnv.h"
-
 #include <ctype.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -38,7 +37,7 @@ char *tok_ks[] = {
 };
 
 /* Initialise a lexer. */
-lex lex_init(u8 *src, usize len) {
+lex lex_init(u8 *src, UINT len) {
 	lex l = { src, src, src + len, 0, 0, 0 }; lex_next(&l); return l;
 }
 
@@ -73,7 +72,7 @@ skip:;
 	if (C == '/') switch (D) {
 		case '/': { for (P += 2; P != Q && C != '\n'; P += 1); } goto skip;
 		case '*': {
-			usize d = 1; for (P += 2, CL += 2; P != Q && d; P += 1) {
+			UINT d = 1; for (P += 2, CL += 2; P != Q && d; P += 1) {
 				if (C == '/' && D == '*') { P += 2; CL += 2; d += 1; continue; }
 				if (C == '*' && D == '/') { P += 2; CL += 2; d -= 1; continue; }
 				if (C == '\n') { LN += 1; CL = 0; } else { CL += 1; }
@@ -90,7 +89,7 @@ skip:;
 
 	/* Handle identifiers and keywords */
 	if (ISIDCHA(C)) {
-		u8 *s = P; usize sl;
+		u8 *s = P; UINT sl;
 
 		for (P += 1; ISIDCHB(C); P += 1);
 		sl = P - s; CL += sl;
@@ -102,7 +101,7 @@ skip:;
 
 	/* Handle number literals */
 	else if (isdigit(C)) {
-		u8 *s = P; usize sl;
+		u8 *s = P; UINT sl;
 
 		for (P += 1; isalnum(C); P += 1);
 		sl = P - s; CL += sl;
diff --git a/src/lex.h b/src/lex.h
index 64393d8..b6f0fc8 100644
--- a/src/lex.h
+++ b/src/lex.h
@@ -28,17 +28,17 @@ typedef enum {
 } tok_k;
 
 typedef struct {
-	tok_k k; usize ln, cl; u64 h;
+	tok_k k; UINT ln, cl; u64 h;
 	union { u64 v_u64; s64 v_s64; f64 v_f64; u8 *v_str; };
 } tok;
 
 typedef struct {
-	u8 *s, *p, *q; usize ln, cl; tok t;
+	u8 *s, *p, *q; UINT ln, cl; tok t;
 } lex;
 
 extern char *tok_ks[];
 
-extern lex lex_init(u8 *src, usize len);
+extern lex lex_init(u8 *src, UINT len);
 extern tok lex_next(lex *l);
 extern tok lex_peek(lex *l);
 extern tok lex_kind(lex *l, tok_k k);
diff --git a/src/llvm/gen.c b/src/llvm/gen.c
index eb63ae7..735a5da 100644
--- a/src/llvm/gen.c
+++ b/src/llvm/gen.c
@@ -7,11 +7,10 @@
 
 #include "../parse.h"
 #include "../type.h"
+#include "../util/error.h"
 #include "../util/util.h"
 #include "llvm.h"
 
-#include "../cll/error.h"
-
 #include <llvm-c/Analysis.h>
 #include <llvm-c/BitWriter.h>
 #include <llvm-c/Core.h>
diff --git a/src/main.c b/src/main.c
index 56d70ed..d9e8507 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,11 +6,10 @@
 

 #include "compile.h"
+#include "util/error.h"
+#include "util/optget.h"
 #include "util/util.h"
 
-#include "cll/error.h"
-#include "cll/optget.h"
-
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
diff --git a/src/map.c b/src/map.c
index 5c6b86c..a3c64dc 100644
--- a/src/map.c
+++ b/src/map.c
@@ -6,11 +6,10 @@
 

 #include "map.h"
+#include "util/error.h"
+#include "util/fnv.h"
 #include "util/util.h"
 
-#include "cll/error.h"
-#include "cll/fnv.h"
-
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/map.h b/src/map.h
index 3233003..99f5c23 100644
--- a/src/map.h
+++ b/src/map.h
@@ -16,7 +16,7 @@ typedef enum { SF_VOID = BIT(0), } sym_f; /* Symbol Flag */
 
 typedef struct sym { sym_k k; sym_f f; type t; } sym;
 typedef struct ent { u8 *k; sym v; struct ent *n, *c; } ent;
-typedef struct { ent **a, *c; usize al, ac; } map;
+typedef struct { ent **a, *c; UINT al, ac; } map;
 
 extern void map_init(map *m);
 extern void map_free(map *m);
diff --git a/src/parse.c b/src/parse.c
index 6213500..1ecfe0b 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -8,12 +8,11 @@
 #include "lex.h"
 #include "parse.h"
 #include "type.h"
+#include "util/error.h"
 #include "util/stack.h"
 #include "util/util.h"
 #include "value.h"
 
-#include "cll/error.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/parse.h b/src/parse.h
index c69ab70..be4ea23 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -23,7 +23,7 @@ typedef enum {
 typedef struct ast_s *ast;
 
 struct ast_s {
-	ast_k k; usize ln, cl;
+	ast_k k; UINT ln, cl;
 	type *t; val v; u8 *s;
 	ast c, lc, rc; stack *cs;
 
diff --git a/src/type.h b/src/type.h
index eca26e0..729075f 100644
--- a/src/type.h
+++ b/src/type.h
@@ -46,7 +46,7 @@ typedef enum {
 } type_f;
 
 typedef struct type {
-	type_k k; type_f f; ssize l;
+	type_k k; type_f f; sint l;
 	u8 *name; struct type *base;
 } type;
 
diff --git a/src/util/alloc.c b/src/util/alloc.c
new file mode 100644
index 0000000..3955e1d
--- /dev/null
+++ b/src/util/alloc.c
@@ -0,0 +1,23 @@
+// util/alloc.h
+// Memory allocation source file for G
+// Copyright (C) 2021, Jakob Wakeling
+// All rights reserved.
+
+
+
+#include "alloc.h"
+#include "error.h"
+
+#include <stdlib.h>
+
+void *xmalloc(UINT l) {
+	void *q = malloc(l); if (!q) { error(1, "%s", SERR); } return q;
+}
+
+void *xcalloc(UINT n, UINT l) {
+	void *q = calloc(n, l); if (!q) { error(1, "%s", SERR); } return q;
+}
+
+void *xrealloc(void *p, UINT l) {
+	void *q = realloc(p, l); if (!q) { error(1, "%s", SERR); } return q;
+}
diff --git a/src/util/alloc.h b/src/util/alloc.h
new file mode 100644
index 0000000..c327782
--- /dev/null
+++ b/src/util/alloc.h
@@ -0,0 +1,17 @@
+// util/alloc.h
+// Memory allocation header file for G
+// Copyright (C) 2021, Jakob Wakeling
+// All rights reserved.
+
+
+
+#ifndef UTIL_ALLOC_H_M0UWQ8LT
+#define UTIL_ALLOC_H_M0UWQ8LT
+
+#include "util.h"
+
+extern void *xmalloc(UINT l);
+extern void *xcalloc(UINT n, UINT l);
+extern void *xrealloc(void *p, UINT l);
+
+#endif // UTIL_ALLOC_H_M0UWQ8LT
diff --git a/src/util/ast.h b/src/util/ast.h
index 732869d..806ea75 100644
--- a/src/util/ast.h
+++ b/src/util/ast.h
@@ -13,14 +13,14 @@
 
 #include <stdio.h>
 
-static void ast_print(ast a, usize i) {
-	for (usize j = 0; j != i; ++j) { printf("    "); }
+static void ast_print(ast a, UINT i) {
+	for (UINT j = 0; j != i; ++j) { printf("    "); }
 	printf("%zu:%zu: %s: %s\n", a->ln, a->cl, ast_ks[a->k], a->s);
 
 	if (a->c) { ast_print(a->c, i + 1); }
 	if (a->lc) { ast_print(a->lc, i + 1); }
 	if (a->rc) { ast_print(a->rc, i + 1); }
-	if (a->cs) for (usize ci = 0; ci != a->cs->al; ++ci) {
+	if (a->cs) for (UINT ci = 0; ci != a->cs->al; ++ci) {
 		ast_print(a->cs->a[ci], i + 1);
 	}
 
diff --git a/src/cll/error.c b/src/util/error.c
similarity index 60%
rename from src/cll/error.c
rename to src/util/error.c
index df1f627..dd43fb0 100644
--- a/src/cll/error.c
+++ b/src/util/error.c
@@ -1,5 +1,5 @@
-// error.c, version 1.0.2
-// Error source file for OMKOV lib
+// util/error.h, version 1.1.1
+// Error source file from libutil
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
 
@@ -18,19 +18,26 @@
 char *A0 = NULL;
 bool warned = false;
 
-/* Print an error message and exit */
+/* Print an error message and exit. */
 noreturn void error(int status, const char *format, ...) {
 	fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); }
 	va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
 	fputc('\n', stderr); exit(status);
 }
 
-/* Print a warning message and set the warned flag */
+/* Print a warning message and set the warned flag. */
 void warn(const char *format, ...) {
 	fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); }
 	va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
 	fputc('\n', stderr); warned = true; return;
 }
 
-/* Shorthand for strerror(errno) */
+/* Print a warning message but do not set the warned flag. */
+void alert(const char *format, ...) {
+	fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); }
+	va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
+	fputc('\n', stderr); return;
+}
+
+/* Shorthand for strerror(errno). DEPRECIATED, use the SERR macro. */
 char *serr(void) { return strerror(errno); }
diff --git a/src/util/error.h b/src/util/error.h
new file mode 100644
index 0000000..5c61fac
--- /dev/null
+++ b/src/util/error.h
@@ -0,0 +1,62 @@
+// util/error.h, version 1.1.1
+// Error header file from libutil
+// Copyright (C) 2020, Jakob Wakeling
+// All rights reserved.
+
+
+
+#ifndef UTIL_ERROR_H_38W06M3W
+#define UTIL_ERROR_H_38W06M3W
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdnoreturn.h>
+#include <string.h>
+
+/* Warn and then return status */
+#define WARN_R(status, format, ...) do { \
+	warn(format, __VA_ARGS__); return status; \
+} while (0)
+
+/* Warn and then reset errno */
+#define WARN_E(format, ...) do { \
+	warn(format, __VA_ARGS__); errno = 0; \
+} while (0)
+
+/* Warn, reset errno, and then return status */
+#define WARN_RE(status, format, ...) do { \
+	warn(format, __VA_ARGS__); errno = 0; return status; \
+} while (0)
+
+/* Alert and then return status */
+#define ALERT_R(status, format, ...) do { \
+	alert(format, __VA_ARGS__); return status; \
+} while (0)
+
+/* Alert and then reset errno */
+#define ALERT_E(format, ...) do { \
+	alert(format, __VA_ARGS__); errno = 0; \
+} while (0)
+
+/* Alert, reset errno, and then return status */
+#define ALERT_RE(status, format, ...) do { \
+	alert(format, __VA_ARGS__); errno = 0; return status; \
+} while (0)
+
+/* Shorthand for strerror(serrno). */
+#define SERR (strerror(errno))
+
+extern char *A0;
+extern bool warned;
+
+/* Print an error message and exit. */
+extern noreturn void error(int status, const char *format, ...);
+/* Print a warning message and set the warned flag. */
+extern void warn(const char *format, ...);
+/* Print a warning message but do not set the warned flag. */
+extern void alert(const char *format, ...);
+
+/* Shorthand for strerror(errno). DEPRECIATED, use the SERR macro. */
+extern char *serr(void);
+
+#endif // UTIL_ERROR_H_38W06M3W
diff --git a/src/cll/fnv.c b/src/util/fnv.c
similarity index 94%
rename from src/cll/fnv.c
rename to src/util/fnv.c
index f2eb831..3221870 100644
--- a/src/cll/fnv.c
+++ b/src/util/fnv.c
@@ -1,5 +1,5 @@
-// fnv.c
-// FNV hash source file for libcll
+// util/fnv.c, version 1.0.0
+// FNV hash source file from libutil
 // Copyright (C) 2021, Jakob Wakeling
 // All rights reserved.
 
diff --git a/src/cll/fnv.h b/src/util/fnv.h
similarity index 73%
rename from src/cll/fnv.h
rename to src/util/fnv.h
index b087071..fec7e00 100644
--- a/src/cll/fnv.h
+++ b/src/util/fnv.h
@@ -1,12 +1,11 @@
-// fnv.h
-// FNV hash header file for libcll
+// util/fnv.h, version 1.0.0
+// FNV hash header file from libutil
 // Copyright (C) 2021, Jakob Wakeling
 // All rights reserved.
 

-
-#ifndef OMKOV_LIBCLL_FNV_H_O4TYU6Q1
-#define OMKOV_LIBCLL_FNV_H_O4TYU6Q1
+#ifndef UTIL_FNV_H_O4TYU6Q1
+#define UTIL_FNV_H_O4TYU6Q1
 
 #include <stddef.h>
 #include <stdint.h>
@@ -20,4 +19,4 @@ extern void fnv1a32_hash(uint32_t *ctx, uint8_t *dat, size_t len);
 extern void fnv1a64_init(uint64_t *ctx);
 extern void fnv1a64_hash(uint64_t *ctx, uint8_t *dat, size_t len);
 
-#endif // OMKOV_LIBCLL_FNV_H_O4TYU6Q1
+#endif // UTIL_FNV_H_O4TYU6Q1
diff --git a/src/cll/optget.c b/src/util/optget.c
similarity index 97%
rename from src/cll/optget.c
rename to src/util/optget.c
index edec18d..e324e73 100644
--- a/src/cll/optget.c
+++ b/src/util/optget.c
@@ -1,5 +1,5 @@
-// optget.h, version 1.6.0
-// optget source file for OMKOV lib
+// util/optget.h, version 1.6.1
+// optget source file from libutil
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
 
diff --git a/src/cll/optget.h b/src/util/optget.h
similarity index 66%
rename from src/cll/optget.h
rename to src/util/optget.h
index d0e23db..79761f9 100644
--- a/src/cll/optget.h
+++ b/src/util/optget.h
@@ -1,12 +1,12 @@
-// optget.h, version 1.6.0
-// optget header file for OMKOV lib
+// util/optget.h, version 1.6.1
+// optget header file from libutil
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
 

 
-#ifndef OMKOV_LIB_OPTGET_H_W3LIZK1S
-#define OMKOV_LIB_OPTGET_H_W3LIZK1S
+#ifndef UTIL_OPTGET_H_W3LIZK1S
+#define UTIL_OPTGET_H_W3LIZK1S
 
 #define ARG_NUL 0
 #define ARG_REQ 1
@@ -27,4 +27,4 @@ extern const struct opt OPTGET_INIT;
 
 extern int optget(struct opt *opt, char *av[], int flags);
 
-#endif // OMKOV_LIB_OPTGET_H_W3LIZK1S
+#endif // UTIL_OPTGET_H_W3LIZK1S
diff --git a/src/util/stack.h b/src/util/stack.h
index 8351804..4d376dd 100644
--- a/src/util/stack.h
+++ b/src/util/stack.h
@@ -10,7 +10,7 @@
 
 #include "../util/util.h"
 
-typedef struct { void **a; usize al, ac; } stack;
+typedef struct { void **a; UINT al, ac; } stack;
 
 extern stack *stack_init(void);
 extern void stack_free(stack *a);
diff --git a/src/util/util.c b/src/util/util.c
deleted file mode 100644
index f49b6ae..0000000
--- a/src/util/util.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// util/util.c
-// Common utility source file for G
-// Copyright (C) 2021, Jakob Wakeling
-// All rights reserved.
-
-
-
-#include "util.h"
-
-
diff --git a/src/util/util.h b/src/util/util.h
index 3d08927..82d2e19 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -1,12 +1,12 @@
-// util/util.h
-// Common utility header file for G
+// util/util.h, version 1.0.0
+// Utility header file from libutil
 // Copyright (C) 2021, Jakob Wakeling
 // All rights reserved.
 

 
-#ifndef G_UTIL_UTIL_H_QPTPGZ3N
-#define G_UTIL_UTIL_H_QPTPGZ3N
+#ifndef UTIL_UTIL_H_KP8NS9DC
+#define UTIL_UTIL_H_KP8NS9DC
 
 #include <assert.h>
 #include <float.h>
@@ -15,58 +15,53 @@
 #include <stdint.h>
 
 /* Type Definitions */
-typedef uint8_t  u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef size_t   usize;
+typedef uint8_t   u8;
+typedef uint16_t  u16;
+typedef uint32_t  u32;
+typedef uint64_t  u64;
+typedef uintptr_t UINT;
 
 typedef int8_t   s8;
 typedef int16_t  s16;
 typedef int32_t  s32;
 typedef int64_t  s64;
-typedef intptr_t ssize;
+typedef intptr_t sint;
 
 typedef float       f32;
 typedef double      f64;
 typedef long double f128;
 
 /* Type Limits */
-#define U8_MIN    UINT8_MIN
-#define U8_MAX    UINT8_MAX
-#define U16_MIN   UINT16_MIN
-#define U16_MAX   UINT16_MAX
-#define U32_MIN   UINT32_MIN
-#define U32_MAX   UINT32_MAX
-#define U64_MIN   UINT64_MIN
-#define U64_MAX   UINT64_MAX
-#define USIZE_MIN SIZE_MIN
-#define USIZE_MAX SIZE_MAX
+#define U8_MIN   UINT8_MIN
+#define U8_MAX   UINT8_MAX
+#define U16_MIN  UINT16_MIN
+#define U16_MAX  UINT16_MAX
+#define U32_MIN  UINT32_MIN
+#define U32_MAX  UINT32_MAX
+#define U64_MIN  UINT64_MIN
+#define U64_MAX  UINT64_MAX
+#define UINT_MIN UINTPTR_MIN
+#define UINT_MAX UINTPTR_MAX
 
-#define S8_MIN    INT8_MIN
-#define S8_MAX    INT8_MAX
-#define S16_MIN   INT16_MIN
-#define S16_MAX   INT16_MAX
-#define S32_MIN   INT32_MIN
-#define S32_MAX   INT32_MAX
-#define S64_MIN   INT64_MIN
-#define S64_MAX   INT64_MAX
-#define SSIZE_MIN INTPTR_MIN
-#define SSIZE_MAX INTPTR_MAX
+#define S8_MIN   INT8_MIN
+#define S8_MAX   INT8_MAX
+#define S16_MIN  INT16_MIN
+#define S16_MAX  INT16_MAX
+#define S32_MIN  INT32_MIN
+#define S32_MAX  INT32_MAX
+#define S64_MIN  INT64_MIN
+#define S64_MAX  INT64_MAX
+#define SINT_MIN INTPTR_MIN
+#define SINT_MAX INTPTR_MAX
 
-#define F32_MIN   FLT_MIN
-#define F32_MAX   FLT_MAX
-#define F64_MIN   DBL_MIN
-#define F64_MAX   DBL_MAX
-#define F128_MIN  LDBL_MIN
-#define F128_MAX  LDBL_MAX
-
-/* Memory Allocation */
-#define assert_malloc(size) (assert(malloc(size)))
-#define assert_calloc(nmemb, size) (assert(calloc(nmemb, size)))
-#define assert_realloc(ptr, size) (assert(realloc(ptr, size)))
+#define F32_MIN  FLT_MIN
+#define F32_MAX  FLT_MAX
+#define F64_MIN  DBL_MIN
+#define F64_MAX  DBL_MAX
+#define F128_MIN LDBL_MIN
+#define F128_MAX LDBL_MAX
 
 /* Miscellaneous */
 #define BIT(x) (1 << (x))
 
-#endif // G_UTIL_UTIL_H_QPTPGZ3N
+#endif // UTIL_UTIL_H_KP8NS9DC
diff --git a/src/value.c b/src/value.c
index d469690..93336fb 100644
--- a/src/value.c
+++ b/src/value.c
@@ -18,7 +18,7 @@ val val_f128(f128 f) { return (val){ VK_FLT,  .v_flt  = f }; }
 
 /* Convert an integer string to a val. */
 val val_strint(u8 *s) {
-	val v = { VK_INT, .v_int = 0 }; u64 c; usize b = 10;
+	val v = { VK_INT, .v_int = 0 }; u64 c; UINT b = 10;
 
 	if (s[0] == '0') switch (s[1]) {
 	case 'b': { s += 2; b = 2; } break;  case 'o': { s += 2; b = 8; } break;