summaryrefslogtreecommitdiff
path: root/src/memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.h')
-rw-r--r--src/memory.h44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/memory.h b/src/memory.h
index c5b6367..f780034 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -2,36 +2,54 @@
#define __MEMORY_H
#include <stdint.h>
-#include "redacted.h"
#include "multiboot.h"
enum cell_type {
FREE_CELL,
CONS_CELL,
INT_CELL,
+ BIGINT_CELL,
CHAR_CELL,
FLOAT_CELL,
+ VIRTUAL_CELL,
+ SYMBOL_CELL,
ARRAY_CELL,
ARRAY_MEMBER,
+ SYS_ARRAY,
APIOFORM
};
struct cell {
- uint8_t type;
- union {
- struct cell *free;
- struct cell *cons;
- struct {int type : 8; int size : 24;} array_cell;
- uint32_t int_;
- uint32_t char_;
- float float_;
- REDACTED_t apioform;
- } car;
- struct cell *cdr;
-};
+ int car : 29;
+ int cdr : 29;
+ int type : 4;
+ int gc_mark : 1;
+} __attribute((packed));
uint32_t memory_available;
void init_memory(multiboot_info_t *mb);
+struct cell *alloc_cell(enum cell_type t);
+enum cell_type get_cell_type(const struct cell *c);
+void set_cell_type(struct cell *c, enum cell_type t);
+
+static inline uint32_t car(struct cell *c) {
+ return c->car << 3;
+}
+static inline uint32_t cdr(struct cell *c) {
+ return c->cdr << 3;
+}
+static inline struct cell *car_cell(struct cell *c) {
+ return (struct cell *) car(c);
+}
+static inline struct cell *cdr_cell(struct cell *c) {
+ return (struct cell *) cdr(c);
+}
+static inline void set_car(struct cell *c, uint32_t val) {
+ c->car = val >> 3;
+}
+static inline void set_cdr(struct cell *c, uint32_t val) {
+ c->cdr = val >> 3;
+}
#endif