Add reference C code that I can hand compile

This commit is contained in:
2025-08-19 13:30:51 -05:00
parent c916cc8dbf
commit 6ae13b1c86
3 changed files with 122 additions and 0 deletions

28
reference/gc.h Normal file
View File

@@ -0,0 +1,28 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define SIZE 8
#define BROKEN_HEART 1
#define CONS 2
#define INTEGER 3
typedef struct box_t {
char type;
union {
int integer;
struct cons_t* cons;
};
} box_t;
typedef struct cons_t {
box_t car;
box_t cdr;
} cons_t;
void init();
cons_t *alloc();
void gc_run();
void gc_loop();
void relocate(cons_t*);