shithub: femtolisp

Download patch

ref: e1bc44b385260be39793806042eb66a56d8ec646
parent: f89245a16fc6ef793b0f35781dd397c58cdd66a6
author: mag <[email protected]>
date: Sun May 21 05:07:06 EDT 2023

tidy up

--- a/cvalues.c
+++ b/cvalues.c
@@ -4,6 +4,9 @@
 #include "cvalues.h"
 #include "types.h"
 
+// trigger unconditional GC after this many bytes are allocated
+#define ALLOC_LIMIT_TRIGGER 67108864
+
 value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
 value_t int64sym, uint64sym, mpintsym;
 value_t longsym, ulongsym, bytesym, wcharsym;
@@ -27,16 +30,12 @@
 fltype_t *stringtype, *wcstringtype;
 fltype_t *builtintype;
 
-static void cvalue_init(fltype_t *type, value_t v, void *dest);
-
-// trigger unconditional GC after this many bytes are allocated
-#define ALLOC_LIMIT_TRIGGER 67108864
-
 static size_t malloc_pressure = 0;
-
 static cvalue_t **Finalizers = nil;
 static size_t nfinalizers = 0;
 static size_t maxfinalizers = 0;
+
+static void cvalue_init(fltype_t *type, value_t v, void *dest);
 
 void
 add_finalizer(cvalue_t *cv)
--- a/cvalues.h
+++ b/cvalues.h
@@ -7,6 +7,14 @@
 #define NWORDS(sz) (((sz)+3)>>2)
 #endif
 
+#define CVALUE_NWORDS 4
+#define MAX_INL_SIZE 384
+#define CV_OWNED_BIT  0x1
+#define CV_PARENT_BIT 0x2
+#define owned(cv) ((uintptr_t)(cv)->type & CV_OWNED_BIT)
+#define hasparent(cv) ((uintptr_t)(cv)->type & CV_PARENT_BIT)
+#define isinlined(cv) ((cv)->data == &(cv)->_space[0])
+
 extern value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
 extern value_t int64sym, uint64sym, mpintsym;
 extern value_t longsym, ulongsym, bytesym, wcharsym;
@@ -22,27 +30,46 @@
 extern htable_t reverse_dlsym_lookup_table;
 extern fltype_t *mpinttype;
 
-value_t cvalue(fltype_t *type, size_t sz);
 void add_finalizer(cvalue_t *cv);
+void sweep_finalizers(void);
 void cv_autorelease(cvalue_t *cv);
-void cv_pin(cvalue_t *cv);
-size_t ctype_sizeof(value_t type, int *palign);
-value_t cvalue_copy(value_t v);
+value_t cvalue(fltype_t *type, size_t sz);
 value_t cvalue_from_data(fltype_t *type, void *data, size_t sz);
 value_t cvalue_from_ref(fltype_t *type, void *ptr, size_t sz, value_t parent);
-value_t cbuiltin(char *name, builtin_t f);
-size_t cvalue_arraylen(value_t v);
-value_t size_wrap(size_t sz);
-size_t toulong(value_t n);
-off_t tooffset(value_t n);
 value_t cvalue_string(size_t sz);
 value_t cvalue_static_cstring(const char *str);
-value_t string_from_cstr(char *str);
 value_t string_from_cstrn(char *str, size_t n);
+value_t string_from_cstr(char *str);
 int fl_isstring(value_t v);
+void cv_pin(cvalue_t *cv);
+value_t mk_mpint(mpint *n);
+value_t size_wrap(size_t sz);
+size_t toulong(value_t n);
+off_t tooffset(value_t n);
+int cvalue_enum_init(fltype_t *ft, value_t arg, void *dest);
+int isarray(value_t v);
+int cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
+size_t cvalue_arraylen(value_t v);
+size_t ctype_sizeof(value_t type, int *palign);
+void to_sized_ptr(value_t v, char **pdata, size_t *psz);
+value_t cvalue_relocate(value_t v);
+value_t cvalue_copy(value_t v);
 value_t cvalue_compare(value_t a, value_t b);
+value_t cvalue_array_aref(value_t *args);
+value_t cvalue_array_aset(value_t *args);
+value_t cbuiltin(char *name, builtin_t f);
+value_t return_from_uint64(uint64_t Uaccum);
+value_t return_from_int64(int64_t Saccum);
+value_t fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn);
+value_t fl_neg(value_t n);
+value_t fl_mul_any(value_t *args, uint32_t nargs, int64_t Saccum);
+int num_to_ptr(value_t a, fixnum_t *pi, numerictype_t *pt, void **pp);
 int numeric_compare(value_t a, value_t b, int eq, int eqnans, int typeerr);
-void to_sized_ptr(value_t v, char **pdata, size_t *psz);
+_Noreturn void DivideByZeroError(void);
+value_t fl_div2(value_t a, value_t b);
+value_t fl_idiv2(value_t a, value_t b);
+void cvalues_init(void);
+
 value_t mk_double(double n);
 value_t mk_float(float n);
 value_t mk_int32(int32_t n);
@@ -50,23 +77,9 @@
 value_t mk_int64(int64_t n);
 value_t mk_uint64(uint64_t n);
 value_t mk_wchar(int32_t n);
-value_t return_from_uint64(uint64_t Uaccum);
-value_t return_from_int64(int64_t Saccum);
-void cvalues_init(void);
-value_t fl_idiv2(value_t a, value_t b);
-value_t fl_div2(value_t a, value_t b);
-value_t fl_mul_any(value_t *args, uint32_t nargs, int64_t Saccum);
-value_t fl_neg(value_t n);
-value_t fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn);
-value_t cvalue_array_aset(value_t *args);
-value_t cvalue_array_aref(value_t *args);
-value_t cvalue_relocate(value_t v);
-void sweep_finalizers(void);
-int cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
-int cvalue_enum_init(fltype_t *ft, value_t arg, void *dest);
-value_t mk_mpint(mpint *n);
-int isarray(value_t v);
-_Noreturn void DivideByZeroError(void);
+
+/* builtins.c */
+size_t llength(value_t v);
 
 #endif
 
--- a/equal.c
+++ b/equal.c
@@ -3,6 +3,7 @@
 #include "operators.h"
 #include "opcodes.h"
 #include "cvalues.h"
+#include "equal.h"
 
 #define BOUNDED_COMPARE_BOUND 128
 #define BOUNDED_HASH_BOUND 16384
--- a/equal.h
+++ b/equal.h
@@ -1,6 +1,10 @@
 #ifndef EQUAL_H
 #define EQUAL_H
 
+// comparable with ==
+#define eq_comparable(a, b) (!(((a)|(b))&1))
+#define eq_comparablep(a) (!((a)&1)) /* mag: UNUSED? */
+
 value_t fl_compare(value_t a, value_t b);
 value_t fl_equal(value_t a, value_t b);
 int equal_lispvalue(value_t a, value_t b);
--- a/flisp.c
+++ b/flisp.c
@@ -15,13 +15,15 @@
 #include "read.h"
 #include "equal.h"
 
-int
-isbuiltin(value_t x)
-{
-	int i = uintval(x);
-	return tag(x) == TAG_FUNCTION && i < nelem(builtins) && builtins[i].name != nil;
-}
+typedef struct {
+        char *name;
+        builtin_t fptr;
+}builtinspec_t;
 
+#define N_GC_HANDLES 1024
+static value_t *GCHandleStack[N_GC_HANDLES];
+static uint32_t N_GCHND = 0;
+
 uint32_t N_STACK;
 value_t *Stack;
 uint32_t SP = 0;
@@ -28,20 +30,12 @@
 uint32_t curr_frame = 0;
 char *curr_fname = nil;
 
-#define N_GC_HANDLES 1024
-static value_t *GCHandleStack[N_GC_HANDLES];
-static uint32_t N_GCHND = 0;
-
 value_t FL_NIL, FL_T, FL_F, FL_EOF, QUOTE;
-value_t IOError, ParseError, TypeError, ArgError, MemoryError;
-value_t DivideError, BoundsError, Error, KeyError, EnumerationError;
-static value_t UnboundError;
-value_t printwidthsym, printreadablysym, printprettysym, printlengthsym;
-value_t printlevelsym, builtins_table_sym;
-
 value_t NIL, LAMBDA, IF, TRYCATCH;
 value_t BACKQUOTE, COMMA, COMMAAT, COMMADOT, FUNCTION;
 
+value_t printwidthsym, printreadablysym, printprettysym, printlengthsym;
+value_t printlevelsym, builtins_table_sym;
 value_t pairsym, symbolsym, fixnumsym, vectorsym, builtinsym, vu8sym;
 value_t definesym, defmacrosym, forsym, setqsym;
 value_t tsym, Tsym, fsym, Fsym, booleansym, nullsym, evalsym, fnsym;
@@ -49,10 +43,10 @@
 value_t nulsym, alarmsym, backspacesym, tabsym, linefeedsym, newlinesym;
 value_t vtabsym, pagesym, returnsym, escsym, spacesym, deletesym;
 
-static value_t apply_cl(uint32_t nargs);
+value_t IOError, ParseError, TypeError, ArgError, MemoryError;
+value_t DivideError, BoundsError, Error, KeyError, EnumerationError;
+static value_t UnboundError;
 
-fl_readstate_t *readstate = nil;
-
 uint8_t *fromspace;
 uint8_t *tospace;
 uint8_t *curheap;
@@ -60,6 +54,19 @@
 uint32_t heapsize;//bytes
 uint32_t *consflags;
 
+int
+isbuiltin(value_t x)
+{
+        int i = uintval(x);
+        return tag(x) == TAG_FUNCTION && i < nelem(builtins) && builtins[i].name != nil;
+}
+
+static value_t apply_cl(uint32_t nargs);
+
+// error utilities ------------------------------------------------------------
+
+fl_readstate_t *readstate = nil;
+
 void
 free_readstate(fl_readstate_t *rs)
 {
@@ -66,9 +73,6 @@
 	htable_free(&rs->backrefs);
 	htable_free(&rs->gensyms);
 }
-
-// error utilities ------------------------------------------------------------
-
 // saved execution state for an unwind target
 fl_exception_context_t *fl_ctx = nil;
 uint32_t fl_throwing_frame = 0;  // active frame when exception was thrown
@@ -337,17 +341,6 @@
 	return v;
 }
 
-// cvalues --------------------------------------------------------------------
-
-//#include "cvalues.c"
-//#include "types.c"
-
-// print ----------------------------------------------------------------------
-
-//static int isnumtok(char *tok, value_t *pval);
-
-//#include "print.c"
-
 // collector ------------------------------------------------------------------
 
 void
@@ -729,14 +722,6 @@
 	return 0;
 }
 
-// read -----------------------------------------------------------------------
-
-//#include "read.c"
-
-// equal ----------------------------------------------------------------------
-
-//#include "equal.c"
-
 // eval -----------------------------------------------------------------------
 
 static value_t
@@ -2065,7 +2050,6 @@
 #define BUILTIN_FN(l, c){l, fn_builtin_##c},
 #include "builtin_fns.h"
 #undef BUILTIN_FN
-
 };
 
 // initialization -------------------------------------------------------------
--- a/flisp.h
+++ b/flisp.h
@@ -1,7 +1,22 @@
 #ifndef FLISP_H
 #define FLISP_H
 
-/* functions needed to implement the value interface (cvtable_t) */
+enum {
+	TAG_NUM,
+	TAG_CPRIM,
+	TAG_FUNCTION,
+	TAG_VECTOR,
+	TAG_NUM1,
+	TAG_CVALUE,
+	TAG_SYM,
+	TAG_CONS,
+};
+
+enum {
+	FLAG_CONST = 1<<0,
+	FLAG_KEYWORD = 1<<1,
+};
+
 typedef enum {
 	T_INT8, T_UINT8,
 	T_INT16, T_UINT16,
@@ -12,22 +27,9 @@
 	T_DOUBLE,
 }numerictype_t;
 
-#define NONNUMERIC (0xff)
-#define valid_numtype(v) ((v) <= T_DOUBLE)
-
 typedef uintptr_t value_t;
 typedef lltint_t fixnum_t;
 
-#ifdef BITS64
-#define T_FIXNUM T_INT64
-#define fits_fixnum(x) (((x)>>61) == 0 || (~((x)>>61)) == 0)
-#define mk_xlong mk_int64
-#else
-#define T_FIXNUM T_INT32
-#define fits_fixnum(x) (((x)>>29) == 0 || (~((x)>>29)) == 0)
-#define mk_xlong mk_long
-#endif
-
 typedef struct {
 	value_t car;
 	value_t cdr;
@@ -58,22 +60,28 @@
 	uint32_t id;
 }gensym_t;
 
-enum {
-	TAG_NUM,
-	TAG_CPRIM,
-	TAG_FUNCTION,
-	TAG_VECTOR,
-	TAG_NUM1,
-	TAG_CVALUE,
-	TAG_SYM,
-	TAG_CONS,
-};
+typedef struct Builtin Builtin;
 
-enum {
-	FLAG_CONST = 1<<0,
-	FLAG_KEYWORD = 1<<1,
+struct Builtin {
+        char *name;
+        int  nargs;
 };
 
+typedef value_t (*builtin_t)(value_t*, int);
+
+#ifdef BITS64
+#define T_FIXNUM T_INT64
+#define fits_fixnum(x) (((x)>>61) == 0 || (~((x)>>61)) == 0)
+#define mk_xlong mk_int64
+#else
+#define T_FIXNUM T_INT32
+#define fits_fixnum(x) (((x)>>29) == 0 || (~((x)>>29)) == 0)
+#define mk_xlong mk_long
+#endif
+
+#define ANYARGS -10000
+#define NONNUMERIC (0xff)
+#define valid_numtype(v) ((v) <= T_DOUBLE)
 #define UNBOUND ((value_t)0x1) // an invalid value
 #define TAG_FWD UNBOUND
 #define tag(x) ((x) & 0x7)
@@ -81,7 +89,7 @@
 #define tagptr(p, t) (((value_t)(p)) | (t))
 #define fixnum(x) ((value_t)((fixnum_t)(x))<<2)
 #define numval(x)  (((fixnum_t)(x))>>2)
-#define fits_bits(x, b) (((x)>>(b-1)) == 0 || (~((x)>>(b-1))) == 0)
+#define fits_bits(x, b) (((x)>>(b-1)) == 0 || (~((x)>>(b-1))) == 0) /* mag: UNUSED? */
 #define uintval(x) (((unsigned int)(x))>>3)
 #define builtin(n) tagptr((((int)n)<<3), TAG_FUNCTION)
 #define iscons(x) (tag(x) == TAG_CONS)
@@ -88,17 +96,20 @@
 #define issymbol(x) (tag(x) == TAG_SYM)
 #define isfixnum(x) (((x)&3) == TAG_NUM)
 #define bothfixnums(x, y) ((((x)|(y)) & 3) == TAG_NUM)
-int isbuiltin(value_t x);
 #define isvector(x) (tag(x) == TAG_VECTOR)
 #define iscvalue(x) (tag(x) == TAG_CVALUE)
 #define iscprim(x)  (tag(x) == TAG_CPRIM)
-#define selfevaluating(x) (tag(x) < 6)
-// comparable with ==
-#define eq_comparable(a, b) (!(((a)|(b))&1))
-#define eq_comparablep(a) (!((a)&1))
+#define selfevaluating(x) (tag(x) < 6) /* mag: UNUSED? */
 // doesn't lead to other values
 #define leafp(a) (((a)&3) != 3)
 
+// allocate n consecutive conses
+#define cons_reserve(n) tagptr(alloc_words((n)*2), TAG_CONS)
+#define cons_index(c)  (((cons_t*)ptr(c))-((cons_t*)fromspace))
+#define ismarked(c)     bitvector_get(consflags, cons_index(c))
+#define mark_cons(c)   bitvector_set(consflags, cons_index(c), 1)
+#define unmark_cons(c) bitvector_set(consflags, cons_index(c), 0)
+
 #define isforwarded(v) (((value_t*)ptr(v))[0] == TAG_FWD)
 #define forwardloc(v) (((value_t*)ptr(v))[1])
 #define forward(v, to) \
@@ -120,7 +131,6 @@
 #define fn_vals(f) (((value_t*)ptr(f))[1])
 #define fn_env(f) (((value_t*)ptr(f))[2])
 #define fn_name(f) (((value_t*)ptr(f))[3])
-
 #define set(s, v)  (((symbol_t*)ptr(s))->binding = (v))
 #define setc(s, v) \
 	do{ \
@@ -133,34 +143,70 @@
 #define sym_to_numtype(s) (((symbol_t*)ptr(s))->numtype)
 #define ismanaged(v) ((((uint8_t*)ptr(v)) >= fromspace) && (((uint8_t*)ptr(v)) < fromspace+heapsize))
 #define isgensym(x)  (issymbol(x) && ismanaged(x))
-value_t gensym(void);
-
 #define isfunction(x) (tag(x) == TAG_FUNCTION && (x) > (N_BUILTINS<<3))
 #define isclosure(x) isfunction(x)
 #define iscbuiltin(x) (iscvalue(x) && cv_class(ptr(x)) == builtintype)
-
-
 // utility for iterating over all arguments in a builtin
 // i=index, i0=start index, arg = var for each arg, args = arg array
 // assumes "nargs" is the argument count
-#define FOR_ARGS(i, i0, arg, args)	 \
-	for(i=i0; i<nargs && ((arg=args[i]) || 1); i++)
-
+#define FOR_ARGS(i, i0, arg, args) for(i=i0; i<nargs && ((arg=args[i]) || 1); i++)
 #define N_BUILTINS ((int)N_OPCODES)
+#define FL_UNSPECIFIED FL_T
 
+#define PUSH(v) \
+        do{ \
+                Stack[SP++] = (v); \
+        }while(0)
+#define POP()   (Stack[--SP])
+#define POPN(n) \
+        do{ \
+                SP -= (n); \
+        }while(0)
+
+extern value_t *Stack;
+extern uint32_t SP;
+extern uint32_t N_STACK;
+extern uint32_t curr_frame;
+extern char *curr_fname;
+
+extern value_t FL_NIL, FL_T, FL_F, FL_EOF, QUOTE;
+extern value_t NIL, LAMBDA, IF, TRYCATCH;
+extern value_t BACKQUOTE, COMMA, COMMAAT, COMMADOT, FUNCTION;
+
 extern value_t printprettysym, printreadablysym, printwidthsym, printlengthsym;
 extern value_t printlevelsym, builtins_table_sym;
-extern value_t QUOTE;
-extern value_t FL_NIL, FL_T, FL_F, FL_EOF;
-#define FL_UNSPECIFIED FL_T
+extern value_t pairsym, symbolsym, fixnumsym, vectorsym, builtinsym, vu8sym;
+extern value_t definesym, defmacrosym, forsym, setqsym;
+extern value_t tsym, Tsym, fsym, Fsym, booleansym, nullsym, evalsym, fnsym;
+extern value_t nulsym, alarmsym, backspacesym, tabsym, linefeedsym, newlinesym;
+extern value_t vtabsym, pagesym, returnsym, escsym, spacesym, deletesym;
 
-int num_to_ptr(value_t a, fixnum_t *pi, numerictype_t *pt, void **pp);
-void fl_gc_handle(value_t *pv);
-void fl_free_gc_handles(uint32_t n);
-int fl_isnumber(value_t v);
+extern value_t IOError, ParseError, TypeError, ArgError, MemoryError;
+extern value_t DivideError, BoundsError, Error, KeyError, EnumerationError;
+extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError;
+
+extern uint8_t *fromspace;
+extern uint32_t heapsize;//bytes
+extern uint8_t *tospace;
+extern uint8_t *curheap;
+extern uint8_t *lim;
+extern uint32_t *consflags;
+
+int isbuiltin(value_t x);
 void fl_init(size_t initial_heapsize);
 int fl_load_system_image(value_t ios);
 
+/* collector */
+value_t relocate(value_t v);
+void gc(int mustgrow);
+void fl_gc_handle(value_t *pv);
+void fl_free_gc_handles(uint32_t n);
+
+/* symbol table */
+value_t gensym(void);
+value_t symbol(char *str);
+char *symbol_name(value_t v);
+
 /* read, eval, print main entry points */
 value_t fl_toplevel_eval(value_t expr);
 value_t fl_apply(value_t f, value_t l);
@@ -170,8 +216,7 @@
 value_t fl_cons(value_t a, value_t b);
 value_t fl_list2(value_t a, value_t b);
 value_t fl_listn(size_t n, ...);
-value_t symbol(char *str);
-char *symbol_name(value_t v);
+int fl_isnumber(value_t v);
 int fl_is_keyword_name(char *str, size_t len);
 value_t alloc_vector(size_t n, int init);
 
@@ -181,6 +226,11 @@
 fixnum_t tofixnum(value_t v);
 char *tostring(value_t v);
 
+/* conses */
+extern value_t the_empty_vector;
+value_t mk_cons(void);
+void *alloc_words(int n);
+
 /* error handling */
 typedef struct _fl_readstate_t {
 	htable_t backrefs;
@@ -198,10 +248,13 @@
 	struct _ectx_t *prev;
 }fl_exception_context_t;
 
+extern fl_readstate_t *readstate;
 extern fl_exception_context_t *fl_ctx;
 extern uint32_t fl_throwing_frame;
 extern value_t fl_lasterror;
 
+void free_readstate(fl_readstate_t *rs);
+
 #define FL_TRY_EXTERN \
 	fl_exception_context_t _ctx; int l__tr, l__ca; \
 	fl_savestate(&_ctx); fl_ctx = &_ctx; \
@@ -223,7 +276,7 @@
 _Noreturn void type_error(char *expected, value_t got);
 _Noreturn void bounds_error(value_t arr, value_t ind);
 _Noreturn void unbound_error(value_t sym);
-extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError;
+
 #define argcount(nargs, c) \
 	do{ \
 		if(__unlikely(nargs != c)) \
@@ -263,8 +316,6 @@
 	};
 }cvalue_t;
 
-#define CVALUE_NWORDS 4
-
 typedef struct {
 	fltype_t *type;
 	char _space[1];
@@ -278,13 +329,6 @@
 }function_t;
 
 #define CPRIM_NWORDS 2
-#define MAX_INL_SIZE 384
-
-#define CV_OWNED_BIT  0x1
-#define CV_PARENT_BIT 0x2
-#define owned(cv) ((uintptr_t)(cv)->type & CV_OWNED_BIT)
-#define hasparent(cv) ((uintptr_t)(cv)->type & CV_PARENT_BIT)
-#define isinlined(cv) ((cv)->data == &(cv)->_space[0])
 #define cv_class(cv) ((fltype_t*)(((uintptr_t)((cvalue_t*)cv)->type)&~3))
 #define cv_len(cv) (((cvalue_t*)(cv))->len)
 #define cv_type(cv) (cv_class(cv)->type)
@@ -291,101 +335,18 @@
 #define cv_data(cv) (((cvalue_t*)(cv))->data)
 #define cv_isstr(cv) (cv_class(cv)->eltype == bytetype)
 #define cv_isPOD(cv) (cv_class(cv)->init != nil)
-
 #define cvalue_data(v) cv_data((cvalue_t*)ptr(v))
 #define cvalue_len(v) cv_len((cvalue_t*)ptr(v))
 #define value2c(type, v) ((type)cv_data((cvalue_t*)ptr(v)))
-
 #define cp_class(cp) (((cprim_t*)(cp))->type)
 #define cp_type(cp)	(cp_class(cp)->type)
 #define cp_numtype(cp) (cp_class(cp)->numtype)
 #define cp_data(cp)	(&((cprim_t*)(cp))->_space[0])
-
 // WARNING: multiple evaluation!
 #define cptr(v) (iscprim(v) ? cp_data(ptr(v)) : cv_data(ptr(v)))
 
 #define BUILTIN(lname, cname) \
 	value_t fn_builtin_##cname(value_t *args, int nargs)
-
-typedef value_t (*builtin_t)(value_t*, int);
-
-typedef struct {
-        char *name;
-        builtin_t fptr;
-}builtinspec_t;
-
-//--------------------------------------------------builtins.c
-size_t llength(value_t v);
-//--------------------------------------------------builtins.c
-
-//--------------------------------------------------iostream.c
-int fl_isiostream(value_t v);
-ios_t *fl_toiostream(value_t v);
-//--------------------------------------------------iostream.c
-
-//--------------------------------------------------------------------------------
-// New declarations here.. needed to permit files splitting
-//--------------------------------------------------------------------------------
-extern value_t *Stack;
-extern uint32_t SP;
-extern uint32_t N_STACK;
-extern uint32_t curr_frame;
-extern char *curr_fname;
-
-#define PUSH(v) \
-        do{ \
-                Stack[SP++] = (v); \
-        }while(0)
-#define POP()   (Stack[--SP])
-#define POPN(n) \
-        do{ \
-                SP -= (n); \
-        }while(0)
-
-extern value_t NIL, LAMBDA, IF, TRYCATCH;
-extern value_t BACKQUOTE, COMMA, COMMAAT, COMMADOT, FUNCTION;
-extern value_t pairsym, symbolsym, fixnumsym, vectorsym, builtinsym, vu8sym;
-extern value_t definesym, defmacrosym, forsym, setqsym;
-extern value_t tsym, Tsym, fsym, Fsym, booleansym, nullsym, evalsym, fnsym;
-extern value_t nulsym, alarmsym, backspacesym, tabsym, linefeedsym, newlinesym;
-extern value_t vtabsym, pagesym, returnsym, escsym, spacesym, deletesym;
-
-void *alloc_words(int n);
-value_t relocate(value_t v);
-
-extern fl_readstate_t *readstate;
-void free_readstate(fl_readstate_t *rs);
-
-extern uint8_t *fromspace;
-extern uint32_t heapsize;//bytes
-extern uint8_t *tospace;
-extern uint8_t *curheap;
-extern uint8_t *lim;
-extern uint32_t *consflags;
-
-void gc(int mustgrow);
-
-extern value_t IOError, ParseError, TypeError, ArgError, MemoryError;
-extern value_t DivideError, BoundsError, Error, KeyError, EnumerationError;
-
-// allocate n consecutive conses
-#define cons_reserve(n) tagptr(alloc_words((n)*2), TAG_CONS)
-#define cons_index(c)  (((cons_t*)ptr(c))-((cons_t*)fromspace))
-#define ismarked(c)     bitvector_get(consflags, cons_index(c))
-#define mark_cons(c)   bitvector_set(consflags, cons_index(c), 1)
-#define unmark_cons(c) bitvector_set(consflags, cons_index(c), 0)
-
-typedef struct Builtin Builtin;
-
-struct Builtin {
-        char *name;
-        int  nargs;
-};
-
-#define ANYARGS -10000
-
-extern value_t the_empty_vector;
-value_t mk_cons(void);
 
 #define BUILTIN_FN(l, c) extern BUILTIN(l, c);
 #include "builtin_fns.h"