Add reference C code that I can hand compile
This commit is contained in:
28
reference/gc.h
Normal file
28
reference/gc.h
Normal 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*);
|
||||
Reference in New Issue
Block a user