From 133a60a91eec2dddc44dd38f31874133dcb50b3d Mon Sep 17 00:00:00 2001 From: joe9 Date: Thu, 11 Jan 2018 20:22:15 -0700 Subject: [PATCH] fixes for 9front port --- include/chibi/features.h | 1 + include/chibi/sexp.h | 18 ++++++++++++++---- main.c | 1 - sexp.c | 1 + 4 files changed, 16 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..48e5f5ca 100644 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -35,6 +35,13 @@ extern "C" { #ifndef PLAN9 #include #include +#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 @@ -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,12 @@ extern "C" { #include #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)) +#define fabsl fabs +#define M_LN10 2.30258509299404568402 /* log_e 10 */ #else #include #include @@ -252,7 +262,7 @@ typedef uint32_t sexp_uint32_t; typedef int32_t sexp_int32_t; # endif #else -# include +# include # 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..f387f8eb 100644 --- a/sexp.c +++ b/sexp.c @@ -2491,6 +2491,7 @@ sexp sexp_read_float_tail (sexp ctx, sexp in, double whole, int negp) { } #endif } + if (e != 0.0) val = fabsl(e) > 320 ? exp(log(val) + e*M_LN10) : val * pow(10, e); #if SEXP_USE_FLONUMS -- 2.13.6