ref: 7f24708ec6677e1de14ff4b892ff9482d253bda5
dir: /flmain.c/
#include "llt.h" #include "flisp.h" #include "cvalues.h" #include "print.h" #include "iostream.h" #include "ieee754.h" #include "random.h" double D_PNAN, D_NNAN, D_PINF, D_NINF; float F_PNAN, F_NNAN, F_PINF, F_NINF; static value_t argv_list(int argc, char *argv[]) { int i; value_t lst = FL_NIL, temp; fl_gc_handle(&lst); fl_gc_handle(&temp); for(i = argc-1; i >= 0; i--){ temp = cvalue_static_cstring(argv[i]); lst = fl_cons(temp, lst); } fl_free_gc_handles(2); return lst; } int flmain(const char *boot, int bootsz, int argc, char **argv) { D_PNAN = D_NNAN = strtod("+NaN", nil); D_PINF = D_NINF = strtod("+Inf", nil); union ieee754_double *d; d = (union ieee754_double *)&D_NNAN; d->ieee.negative = 1; d = (union ieee754_double *)&D_NINF; d->ieee.negative = 1; randomize(); ios_init_stdstreams(); fl_init(512*1024); value_t f = cvalue(iostreamtype, sizeof(ios_t)); ios_t *s = value2c(ios_t*, f); ios_static_buffer(s, boot, bootsz); int r = 1; FL_TRY_EXTERN{ if(fl_load_system_image(f) == 0){ fl_applyn(1, symbol_value(symbol("__start")), argv_list(argc, argv)); r = 0; } } FL_CATCH_EXTERN_NO_RESTORE{ ios_puts("fatal error:\n", ios_stderr); fl_print(ios_stderr, fl_lasterror); ios_putc('\n', ios_stderr); break; } return r; }