diff --git a/femtolisp/flisp.c b/femtolisp/flisp.c index 5055cea..83ef151 100644 --- a/femtolisp/flisp.c +++ b/femtolisp/flisp.c @@ -2255,8 +2255,6 @@ static value_t argv_list(int argc, char *argv[]) return POP(); } -int locale_is_utf8; - extern value_t fl_file(value_t *args, uint32_t nargs); int main(int argc, char *argv[]) @@ -2266,8 +2264,6 @@ int main(int argc, char *argv[]) symbol_t *sym; char fname_buf[1024]; - locale_is_utf8 = u8_is_locale_utf8(setlocale(LC_ALL, "")); - lisp_init(); fname_buf[0] = '\0'; @@ -2277,8 +2273,7 @@ int main(int argc, char *argv[]) } strcat(fname_buf, "flisp.boot"); - FL_TRY { - // install toplevel exception handler + FL_TRY { // toplevel exception handler PUSH(cvalue_static_cstring(fname_buf)); PUSH(symbol(":read")); value_t f = fl_file(&Stack[SP-2], 2); diff --git a/llt/Makefile b/llt/Makefile index d58396a..a8efc38 100644 --- a/llt/Makefile +++ b/llt/Makefile @@ -3,7 +3,7 @@ CC = gcc SRCS = bitvector.c hashing.c socket.c timefuncs.c dblprint.c ptrhash.c \ utf8.c ios.c operators.c cplxprint.c dirpath.c htable.c \ bitvector-ops.c fp.c int2str.c dump.c random.c bswap.c memalign.c \ - swapreverse.c + swapreverse.c lltinit.c OBJS = $(SRCS:%.c=%.o) DOBJS = $(SRCS:%.c=%.do) TARGET = libllt.a diff --git a/llt/hashing.c b/llt/hashing.c index 21c69f3..28ea97a 100644 --- a/llt/hashing.c +++ b/llt/hashing.c @@ -76,28 +76,3 @@ u_int32_t memhash32(char* buf, size_t n) hashlittle2(buf, n, &c, &b); return c; } - -double D_PNAN; -double D_NNAN; -double D_PINF; -double D_NINF; -float F_PNAN; -float F_NNAN; -float F_PINF; -float F_NINF; - -void llt_init() -{ - randomize(); - - ios_init_stdstreams(); - - D_PNAN = strtod("+NaN",NULL); - D_NNAN = -strtod("+NaN",NULL); - D_PINF = strtod("+Inf",NULL); - D_NINF = strtod("-Inf",NULL); - F_PNAN = strtof("+NaN",NULL); - F_NNAN = -strtof("+NaN",NULL); - F_PINF = strtof("+Inf",NULL); - F_NINF = strtof("-Inf",NULL); -} diff --git a/llt/lltinit.c b/llt/lltinit.c new file mode 100644 index 0000000..12fcf69 --- /dev/null +++ b/llt/lltinit.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include "ieee754.h" +#include "dtypes.h" +#include "timefuncs.h" +#include "ios.h" +#include "random.h" +#include "utf8.h" + +double D_PNAN; +double D_NNAN; +double D_PINF; +double D_NINF; +float F_PNAN; +float F_NNAN; +float F_PINF; +float F_NINF; + +int locale_is_utf8; + +void llt_init() +{ + locale_is_utf8 = u8_is_locale_utf8(setlocale(LC_ALL, "")); + + randomize(); + + ios_init_stdstreams(); + + D_PNAN = strtod("+NaN",NULL); + D_NNAN = -strtod("+NaN",NULL); + D_PINF = strtod("+Inf",NULL); + D_NINF = strtod("-Inf",NULL); + F_PNAN = strtof("+NaN",NULL); + F_NNAN = -strtof("+NaN",NULL); + F_PINF = strtof("+Inf",NULL); + F_NINF = strtof("-Inf",NULL); +} diff --git a/llt/utf8.h b/llt/utf8.h index 41505e6..28b71e3 100644 --- a/llt/utf8.h +++ b/llt/utf8.h @@ -14,6 +14,8 @@ typedef unsigned long long u_int64_t; #endif #endif +extern int locale_is_utf8; + /* is c the start of a utf8 sequence? */ #define isutf(c) (((c)&0xC0)!=0x80)