shithub: femtolisp

Download patch

ref: 1649e64ad399a68e3ba72012b88795154c2ec251
parent: 219ffb7e63b31dc7f739c35a78574d3f6949db30
author: JeffBezanson <jeff.bezanson@gmail.com>
date: Wed Jan 6 15:27:04 EST 2010

putting llt_init in a separate file


--- a/femtolisp/flisp.c
+++ b/femtolisp/flisp.c
@@ -2255,8 +2255,6 @@
     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 @@
     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 @@
     }
     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);
--- a/llt/Makefile
+++ b/llt/Makefile
@@ -3,7 +3,7 @@
 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
--- a/llt/hashing.c
+++ b/llt/hashing.c
@@ -76,28 +76,3 @@
     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);
-}
--- /dev/null
+++ b/llt/lltinit.c
@@ -1,0 +1,40 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <math.h>
+#include <locale.h>
+#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);
+}
--- a/llt/utf8.h
+++ b/llt/utf8.h
@@ -14,6 +14,8 @@
 #endif
 #endif
 
+extern int locale_is_utf8;
+
 /* is c the start of a utf8 sequence? */
 #define isutf(c) (((c)&0xC0)!=0x80)