summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--kernel/assert.h1
-rw-r--r--kernel/main.c3
3 files changed, 5 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3039d1d..a68ae43 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ OBJ = ${CSRC:.c=.o} ${FSRC:.asm=.o}
all: providence.img
boot/boot.o: boot/bios.inc boot/page.inc boot/segdesc.inc
-kernel/main.o: kernel/util.h
+kernel/main.o: kernel/assert.h kernel/util.h
providence.img: ${OBJ}
${CC} ${LDFLAGS} $^ ${LDLIBS} -o $@
diff --git a/kernel/assert.h b/kernel/assert.h
new file mode 100644
index 0000000..2519b7f
--- /dev/null
+++ b/kernel/assert.h
@@ -0,0 +1 @@
+#define STATIC_ASSERT(COND,MSG) typedef char static_assert_##MSG[(COND)?1:-1]
diff --git a/kernel/main.c b/kernel/main.c
index 8c120e9..0633254 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include "assert.h"
#include "util.h"
#define VGA_WIDTH 80
@@ -11,6 +12,8 @@ struct e820_entry {
uint32_t ext_attr;
};
+STATIC_ASSERT(sizeof(struct e820_entry) == 24, e820_entry);
+
static uint64_t *
memsetu64(uint64_t *const dst, const uint64_t c, const uint64_t n)
{