OK, turing.

<- leave blank

Thu Jan 11 22:37:48 EST 2018

From c681ed295780bb37c515013b6ea42944bca216be Mon Sep 17 00:00:00 2001
From: joe9 <joe9mail@gmail.com>
Date: Thu, 11 Jan 2018 20:22:15 -0700
Subject: [PATCH] fixes for 9front port

---
 include/chibi/features.h | 1 +
 include/chibi/sexp.h | 16 ++++++++++++----
 main.c | 1 -
 sexp.c | 5 +++++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/include/chibi/features.h b/include/chibi/features.h
index 994c7eca..af077b20 100644
--- a/include/chibi/features.h
+++ b/include/chibi/features.h
@@ -709,6 +709,7 @@

 #ifndef SEXP_POLL_SLEEP_TIME
 #define SEXP_POLL_SLEEP_TIME 5000
+#define SEXP_POLL_SLEEP_TIME_MS 5
 #endif

 #ifndef SEXP_USE_IMAGE_LOADING
diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h
index f82f2225..4662a7cd 100644
--- a/include/chibi/sexp.h
+++ b/include/chibi/sexp.h
@@ -35,6 +35,13 @@ extern "C" {
 #ifndef PLAN9
 #include <errno.h>
 #include <unistd.h>
+#define SEXP_USE_POLL_PORT 1
+#define sexp_poll_input(ctx, port) sexp_poll_port(ctx, port, 1)
+#define sexp_poll_output(ctx, port) sexp_poll_port(ctx, port, 0)
+#else
+#define SEXP_USE_POLL_PORT 0
+#define sexp_poll_input(ctx, port) sleep(SEXP_POLL_SLEEP_TIME_MS)
+#define sexp_poll_output(ctx, port) sleep(SEXP_POLL_SLEEP_TIME_MS)
 #endif
 #if SEXP_USE_GREEN_THREADS
 #include <sys/time.h>
@@ -47,9 +54,6 @@ extern "C" {
 #define sexp_isdigit(x) (isdigit(x))
 #define sexp_tolower(x) (tolower(x))
 #define sexp_toupper(x) (toupper(x))
-#define SEXP_USE_POLL_PORT 1
-#define sexp_poll_input(ctx, port) sexp_poll_port(ctx, port, 1)
-#define sexp_poll_output(ctx, port) sexp_poll_port(ctx, port, 0)
 #endif

 #if SEXP_USE_GC_FILE_DESCRIPTORS
@@ -71,6 +75,10 @@ extern "C" {
 #include <thread.h>
 #include <9p.h>
 typedef unsigned long size_t;
+typedef long long off_t;
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define exit(x) exits(TOSTRING(x))
 #else
 #include <stddef.h>
 #include <stdlib.h>
@@ -252,7 +260,7 @@ typedef uint32_t sexp_uint32_t;
 typedef int32_t sexp_int32_t;
 # endif
 #else
-# include <limits.h>
+# include <ape/limits.h>
 # if UCHAR_MAX == 255
 # define SEXP_UINT8_DEFINED 1
 typedef unsigned char sexp_uint8_t;
diff --git a/main.c b/main.c
index a02ed780..4550b5dc 100644
--- a/main.c
+++ b/main.c
@@ -24,7 +24,6 @@

 #ifdef PLAN9
 #define exit_failure() exits("ERROR")
-#define exit exits
 #else
 #define exit_failure() exit(70)
 #endif
diff --git a/sexp.c b/sexp.c
index 1503e5b2..ed98ad94 100644
--- a/sexp.c
+++ b/sexp.c
@@ -2491,8 +2491,13 @@ sexp sexp_read_float_tail (sexp ctx, sexp in, double whole,
int negp) {
     }
 #endif
   }
+
+#ifdef PLAN9
+ if (e != 0.0) val *= pow(10, e);
+#else
   if (e != 0.0)
     val = fabsl(e) > 320 ? exp(log(val) + e*M_LN10) : val * pow(10, e);
+#endif
 #if SEXP_USE_FLONUMS
   res = sexp_make_flonum(ctx, val);
 #else
--
2.13.6