This commit is contained in:
Justin Ethier 2015-08-19 22:37:21 -04:00
parent 7a6c6a6727
commit a15ac425c2
2 changed files with 19 additions and 31 deletions

View file

@ -4,7 +4,6 @@
* All rights reserved. * All rights reserved.
* *
* This file contains the C runtime code used only by the main program module. * 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 #ifndef CYCLONE_RUNTIME_MAIN_H
@ -43,7 +42,6 @@ static void main_main (stack_size,heap_size,stack_base)
#if DEBUG_SHOW_DIAG #if DEBUG_SHOW_DIAG
printf("main: stack_size=%ld stack_base=%p stack_limit1=%p\n", printf("main: stack_size=%ld stack_base=%p stack_limit1=%p\n",
stack_size,(void *)stack_base,(void *)stack_limit1); stack_size,(void *)stack_base,(void *)stack_limit1);
printf("main: Try different stack sizes from 4 K to 1 Meg.\n");
#endif #endif
/* Initialize stack trace table */ /* 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); do_dispatch(gc_num_ans, ((closure)gc_cont)->fn, gc_cont, gc_ans);
} }
/* */ printf("Internal error: should never have reached this line\n"); exit(0);}}
printf("main: your setjmp and/or longjmp are broken.\n"); exit(0);}}
static long long_arg(argc,argv,name,dval) static long long_arg(argc,argv,name,dval)
int argc; char **argv; char *name; long dval; int argc; char **argv; char *name; long dval;

View file

@ -26,20 +26,16 @@
/* Maximum number of args that GC will accept */ /* Maximum number of args that GC will accept */
#define NUM_GC_ANS 128 #define NUM_GC_ANS 128
/* STACK_GROWS_DOWNWARD is a machine-specific preprocessor switch. */ /* Which way does the CPU grow its stack? */
/* It is true for the Macintosh 680X0 and the Intel 80860. */
#define STACK_GROWS_DOWNWARD 1 #define STACK_GROWS_DOWNWARD 1
/* STACK_SIZE is the size of the stack buffer, in bytes. */ /* 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. */
#define STACK_SIZE 100000 #define STACK_SIZE 100000
/* HEAP_SIZE is the size of the 2nd generation, in bytes. */ /* Size of the 2nd generation, in bytes. */
/* HEAP_SIZE should be at LEAST 225000*sizeof(cons_type). */
#define HEAP_SIZE 6000000 #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; typedef long tag_type;
#ifndef CLOCKS_PER_SEC #ifndef CLOCKS_PER_SEC
@ -49,13 +45,14 @@ typedef long tag_type;
#define longjmp _longjmp #define longjmp _longjmp
#endif #endif
/* Determine if stack has overflowed */
#if STACK_GROWS_DOWNWARD #if STACK_GROWS_DOWNWARD
#define check_overflow(x,y) ((x) < (y)) #define check_overflow(x,y) ((x) < (y))
#else #else
#define check_overflow(x,y) ((x) > (y)) #define check_overflow(x,y) ((x) > (y))
#endif #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 */ Remember to update tag_names in runtime.c when adding new tags */
#define cons_tag 0 #define cons_tag 0
#define symbol_tag 1 #define symbol_tag 1
@ -80,8 +77,6 @@ typedef long tag_type;
#define nil NULL #define nil NULL
#define eq(x,y) (x == y) #define eq(x,y) (x == y)
#define nullp(x) (x == NULL) #define nullp(x) (x == NULL)
#define or(x,y) (x || y)
#define and(x,y) (x && y)
/* Define general object type. */ /* Define general object type. */
@ -179,18 +174,18 @@ typedef cons_type *list;
#define car(x) (((list) x)->cons_car) #define car(x) (((list) x)->cons_car)
#define cdr(x) (((list) x)->cons_cdr) #define cdr(x) (((list) x)->cons_cdr)
#define caar(x) (car(car(x))) #define caar(x) (car(car(x)))
#define cadr(x) (car(cdr(x))) #define cadr(x) (car(cdr(x)))
#define cdar(x) (cdr(car(x))) #define cdar(x) (cdr(car(x)))
#define cddr(x) (cdr(cdr(x))) #define cddr(x) (cdr(cdr(x)))
#define caaar(x) (car(car(car(x)))) #define caaar(x) (car(car(car(x))))
#define caadr(x) (car(car(cdr(x)))) #define caadr(x) (car(car(cdr(x))))
#define cadar(x) (car(cdr(car(x)))) #define cadar(x) (car(cdr(car(x))))
#define caddr(x) (car(cdr(cdr(x)))) #define caddr(x) (car(cdr(cdr(x))))
#define cdaar(x) (cdr(car(car(x)))) #define cdaar(x) (cdr(car(car(x))))
#define cdadr(x) (cdr(car(cdr(x)))) #define cdadr(x) (cdr(car(cdr(x))))
#define cddar(x) (cdr(cdr(car(x)))) #define cddar(x) (cdr(cdr(car(x))))
#define cdddr(x) (cdr(cdr(cdr(x)))) #define cdddr(x) (cdr(cdr(cdr(x))))
#define caaaar(x) (car(car(car(car(x))))) #define caaaar(x) (car(car(car(car(x)))))
#define caaadr(x) (car(car(car(cdr(x))))) #define caaadr(x) (car(car(car(cdr(x)))))
#define caadar(x) (car(car(cdr(car(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; 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; \ #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; 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 mlist1(e1) (mcons(e1,nil))
#define mlist2(e2,e1) (mcons(e2,mlist1(e1))) #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 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 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); #define make_cell(n,a) make_cons(n,a,nil);
/* Primitive types */ /* Primitive types */
//typedef void (*prim_function_type)();
typedef struct {tag_type tag; const char *pname; function_type fn;} primitive_type; typedef struct {tag_type tag; const char *pname; function_type fn;} primitive_type;
typedef primitive_type *primitive; typedef primitive_type *primitive;