From a15ac425c2579d482f82d54e8f8ce21f62642bbd Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 19 Aug 2015 22:37:21 -0400 Subject: [PATCH] Cleanup --- include/cyclone/runtime-main.h | 5 +--- include/cyclone/types.h | 45 ++++++++++++++-------------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/include/cyclone/runtime-main.h b/include/cyclone/runtime-main.h index 78a45169..22808d77 100644 --- a/include/cyclone/runtime-main.h +++ b/include/cyclone/runtime-main.h @@ -4,7 +4,6 @@ * All rights reserved. * * This file contains the C runtime code used only by the main program module. - * May want to consider migrating this into another runtime module. */ #ifndef CYCLONE_RUNTIME_MAIN_H @@ -43,7 +42,6 @@ static void main_main (stack_size,heap_size,stack_base) #if DEBUG_SHOW_DIAG printf("main: stack_size=%ld stack_base=%p stack_limit1=%p\n", stack_size,(void *)stack_base,(void *)stack_limit1); - printf("main: Try different stack sizes from 4 K to 1 Meg.\n"); #endif /* Initialize stack trace table */ @@ -88,8 +86,7 @@ static void main_main (stack_size,heap_size,stack_base) do_dispatch(gc_num_ans, ((closure)gc_cont)->fn, gc_cont, gc_ans); } - /* */ - printf("main: your setjmp and/or longjmp are broken.\n"); exit(0);}} + printf("Internal error: should never have reached this line\n"); exit(0);}} static long long_arg(argc,argv,name,dval) int argc; char **argv; char *name; long dval; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index def678e9..333e7cf0 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -26,20 +26,16 @@ /* Maximum number of args that GC will accept */ #define NUM_GC_ANS 128 -/* STACK_GROWS_DOWNWARD is a machine-specific preprocessor switch. */ -/* It is true for the Macintosh 680X0 and the Intel 80860. */ +/* Which way does the CPU grow its stack? */ #define STACK_GROWS_DOWNWARD 1 -/* STACK_SIZE is the size of the stack buffer, in bytes. */ -/* Some machines like a smallish stack--i.e., 4k-16k, while others */ -/* like a biggish stack--i.e., 100k-500k. */ +/* Size of the stack buffer, in bytes. */ #define STACK_SIZE 100000 -/* HEAP_SIZE is the size of the 2nd generation, in bytes. */ -/* HEAP_SIZE should be at LEAST 225000*sizeof(cons_type). */ +/* Size of the 2nd generation, in bytes. */ #define HEAP_SIZE 6000000 -/* Define size of Lisp tags. Options are "short" or "long". */ +/* Define size of object tags. Options are "short" or "long". */ typedef long tag_type; #ifndef CLOCKS_PER_SEC @@ -49,13 +45,14 @@ typedef long tag_type; #define longjmp _longjmp #endif +/* Determine if stack has overflowed */ #if STACK_GROWS_DOWNWARD #define check_overflow(x,y) ((x) < (y)) #else #define check_overflow(x,y) ((x) > (y)) #endif -/* Define tag values. Could be an enum... +/* Define object tag values. Could be an enum... Remember to update tag_names in runtime.c when adding new tags */ #define cons_tag 0 #define symbol_tag 1 @@ -80,8 +77,6 @@ typedef long tag_type; #define nil NULL #define eq(x,y) (x == y) #define nullp(x) (x == NULL) -#define or(x,y) (x || y) -#define and(x,y) (x && y) /* Define general object type. */ @@ -179,18 +174,18 @@ typedef cons_type *list; #define car(x) (((list) x)->cons_car) #define cdr(x) (((list) x)->cons_cdr) -#define caar(x) (car(car(x))) -#define cadr(x) (car(cdr(x))) -#define cdar(x) (cdr(car(x))) -#define cddr(x) (cdr(cdr(x))) -#define caaar(x) (car(car(car(x)))) -#define caadr(x) (car(car(cdr(x)))) -#define cadar(x) (car(cdr(car(x)))) -#define caddr(x) (car(cdr(cdr(x)))) -#define cdaar(x) (cdr(car(car(x)))) -#define cdadr(x) (cdr(car(cdr(x)))) -#define cddar(x) (cdr(cdr(car(x)))) -#define cdddr(x) (cdr(cdr(cdr(x)))) +#define caar(x) (car(car(x))) +#define cadr(x) (car(cdr(x))) +#define cdar(x) (cdr(car(x))) +#define cddr(x) (cdr(cdr(x))) +#define caaar(x) (car(car(car(x)))) +#define caadr(x) (car(car(cdr(x)))) +#define cadar(x) (car(cdr(car(x)))) +#define caddr(x) (car(cdr(cdr(x)))) +#define cdaar(x) (cdr(car(car(x)))) +#define cdadr(x) (cdr(car(cdr(x)))) +#define cddar(x) (cdr(cdr(car(x)))) +#define cdddr(x) (cdr(cdr(cdr(x)))) #define caaaar(x) (car(car(car(car(x))))) #define caaadr(x) (car(car(car(cdr(x))))) #define caadar(x) (car(car(cdr(car(x))))) @@ -240,7 +235,6 @@ typedef closure0_type *macro; c.fn = f; c.num_args = -1; c.elt1 = a1; c.elt2 = a2; c.elt3 = a3; #define mclosure4(c,f,a1,a2,a3,a4) closure4_type c; c.tag = closure4_tag; \ c.fn = f; c.num_args = -1; c.elt1 = a1; c.elt2 = a2; c.elt3 = a3; c.elt4 = a4; -// #define setq(x,e) x = e #define mlist1(e1) (mcons(e1,nil)) #define mlist2(e2,e1) (mcons(e2,mlist1(e1))) @@ -250,12 +244,9 @@ typedef closure0_type *macro; #define mlist6(e6,e5,e4,e3,e2,e1) (mcons(e6,mlist5(e5,e4,e3,e2,e1))) #define mlist7(e7,e6,e5,e4,e3,e2,e1) (mcons(e7,mlist6(e6,e5,e4,e3,e2,e1))) -// #define rule(lhs,rhs) (mlist3(quote_equal,lhs,rhs)) - #define make_cell(n,a) make_cons(n,a,nil); /* Primitive types */ -//typedef void (*prim_function_type)(); typedef struct {tag_type tag; const char *pname; function_type fn;} primitive_type; typedef primitive_type *primitive;