These are allowed even in core code.
- stdarg.h: for va_list va_start and va_end
+
+## Vendoring
+
+All 3rd party libraries should be forked and included as a submodule.
+Linking should be static.
TEST_NAME=test$(NAME)
DBGCFLAGS=-g
DBGLDFLAGS=
-CFLAGS=-Wall -pedantic $(DBGCFLAGS) -std=c89
+CFLAGS=-Wall -Wextra -Werror -pedantic $(DBGCFLAGS) -std=c89
LIBS=-lSDL3
LDFLAGS=$(DBGLDFLAGS) $(LIBS)
}
void lrts_help(int argc, char **argv) {
+ LRTS_UNUSED(argc);
+
u_fprintf(u_stderr, "%s\n", argv[0]);
u_fprintf(u_stderr, "Usage: %s [-%s] [-c=command] [demo file]\n\n",
argv[0], LRTS_OPTS);
#include "u_math.c"
#include "t_tile.c"
#include "u_log.c"
+#include "u_arena.c"
#endif
--- /dev/null
+#include "u_arena.h"
+
--- /dev/null
+#ifndef U_ARENA_H__
+#define U_ARENA_H__
+
+#include "u_defs.h"
+#include "u_errno.h"
+
+/**
+ * This module contains a simple arena allocator
+ * This is the most common type of allocator that should
+ * be used in the program.
+ */
+
+struct u_arena {
+ enum u_errno_code err;
+ u32 o_size;
+ u32 o_max;
+
+ /* The current object index */
+ u32 o_index;
+
+ void *data;
+};
+
+/**
+ * Creates a new arena
+ * suitable for o_max objects of o_size size
+ * returns a new arena. sets err to 0 if no error occured
+ */
+struct u_arena u_arena_init(u32 o_size, u32 o_max);
+
+/**
+ * Allocates n objects from an arena
+ * sets err if allocation is not possible
+ */
+void *u_arena_alloc(struct u_arena *a, u32 n);
+
+/* Clears the arena resetting the current o_index */
+void u_arena_clear(struct u_arena *a);
+
+/* Releases an arena buffer */
+void u_arena_free(struct u_arena *a);
+
+#endif
#define U_RENDER_W 640
#define U_RENDER_H 640
+#define LRTS_UNUSED(x) (void)(x)
+
#endif
--- /dev/null
+#ifndef U_ERRNO_H__
+#define U_ERRNO_H__
+
+#define U_ERRNO_MESSAGE_MAX 512
+
+/**
+ * This message may be written to whenever a function fails
+ */
+extern char u_errno_message[U_ERRNO_MESSAGE_MAX];
+
+/**
+ * This error code usually gets returned by
+ * functions that may fail.
+ * usually the pattenr is as follows
+ * return_type my_fun(enum u_errno_code *err);
+ * or
+ * struct my_struct {
+ * enum u_errno_code err;
+ * }
+ */
+enum u_errno_code {
+ U_ERRNO_OK = 0,
+ U_ERRNO_FAIL
+};
+
+#endif
#include <stdarg.h>
lrts_bool u_log_should_log(enum u_log_levels level) {
+ LRTS_UNUSED(level);
/* TODO: implement log levels */
return LRTS_TRUE;
}
struct u_fp u_fp_add(struct u_fp a, struct u_fp b) {
struct u_fp c = U_FP(0, 0);
+
+ LRTS_UNUSED(a);
+ LRTS_UNUSED(b);
lrts_todo("");
return c;
}
struct u_fp u_fp_sub(struct u_fp a, struct u_fp b) {
struct u_fp c = U_FP(0, 0);
+
+ LRTS_UNUSED(a);
+ LRTS_UNUSED(b);
lrts_todo("");
return c;
}
struct u_fp u_fp_mul(struct u_fp a, struct u_fp b) {
struct u_fp c = U_FP(0, 0);
+
+ LRTS_UNUSED(a);
+ LRTS_UNUSED(b);
lrts_todo("");
return c;
}
struct u_fp u_fp_div(struct u_fp a, struct u_fp b) {
struct u_fp c = U_FP(0, 0);
+
+ LRTS_UNUSED(a);
+ LRTS_UNUSED(b);
lrts_todo("");
return c;
}
struct u_fp u_fp_mod(struct u_fp a, struct u_fp b) {
struct u_fp c = U_FP(0, 0);
+
+ LRTS_UNUSED(a);
+ LRTS_UNUSED(b);
lrts_todo("");
return c;
}
#include "u_assert.h"
void u_srand(u32 s) {
+ LRTS_UNUSED(s);
lrts_todo("Not yet implemented");
}