From 8ee3699095af5a075271aeea9a33b7bbd2fd8c21 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 15 Apr 2012 15:52:51 +0900 Subject: [PATCH] fixing non-threaded (and plan9) build --- include/chibi/sexp.h | 6 +++--- sexp.c | 6 ++++++ vm.c | 2 -- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index cba48fce..b05b1ee6 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -1200,9 +1200,9 @@ enum sexp_context_globals { #define sexp_read_char(x, p) (sexp_port_buf(p) ? ((sexp_port_offset(p) < sexp_port_size(p)) ? sexp_port_buf(p)[sexp_port_offset(p)++] : sexp_buffered_read_char(x, p)) : getc(sexp_port_stream(p))) #define sexp_push_char(x, c, p) ((c!=EOF) && (sexp_port_buf(p) ? (sexp_port_buf(p)[--sexp_port_offset(p)] = ((char)(c))) : ungetc(c, sexp_port_stream(p)))) -#define sexp_write_char(x, c, p) (sexp_port_buf(p) ? ((sexp_port_offset(p) < sexp_port_size(p)) ? ((((sexp_port_buf(p))[sexp_port_offset(p)++]) = (char)(c)), SEXP_VOID) : sexp_buffered_write_char(x, c, p)) : (putc(c, sexp_port_stream(p)), SEXP_VOID)) -#define sexp_write_string(x, s, p) (sexp_port_buf(p) ? sexp_buffered_write_string(x, s, p) : (fputs(s, sexp_port_stream(p)), SEXP_VOID)) -#define sexp_flush(x, p) (sexp_port_buf(p) ? sexp_buffered_flush(x, p) : (fflush(sexp_port_stream(p)), SEXP_VOID)) +#define sexp_write_char(x, c, p) (sexp_port_buf(p) ? ((sexp_port_offset(p) < sexp_port_size(p)) ? ((((sexp_port_buf(p))[sexp_port_offset(p)++]) = (char)(c)), 0) : sexp_buffered_write_char(x, c, p)) : putc(c, sexp_port_stream(p))) +#define sexp_write_string(x, s, p) (sexp_port_buf(p) ? sexp_buffered_write_string(x, s, p) : fputs(s, sexp_port_stream(p))) +#define sexp_flush(x, p) (sexp_port_buf(p) ? sexp_buffered_flush(x, p) : fflush(sexp_port_stream(p))) SEXP_API int sexp_buffered_read_char (sexp ctx, sexp p); SEXP_API int sexp_buffered_write_char (sexp ctx, int c, sexp p); diff --git a/sexp.c b/sexp.c index 9b40310c..0244d66f 100644 --- a/sexp.c +++ b/sexp.c @@ -1825,9 +1825,13 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) { sexp sexp_write_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out) { sexp res; sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); +#if SEXP_USE_GREEN_THREADS sexp_maybe_block_output_port(ctx, out); +#endif res = sexp_write_one(ctx, obj, out); +#if SEXP_USE_GREEN_THREADS sexp_maybe_unblock_port(ctx, out); +#endif return res; } @@ -1849,8 +1853,10 @@ sexp sexp_flush_output_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) { sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); res = sexp_flush(ctx, out); if (res == EOF) { +#if SEXP_USE_GREEN_THREADS if (sexp_port_stream(out) && ferror(sexp_port_stream(out)) && (errno == EAGAIN)) return sexp_global(ctx, SEXP_G_IO_BLOCK_ERROR); +#endif return SEXP_FALSE; } return SEXP_TRUE; diff --git a/vm.c b/vm.c index 402143f6..9eff3545 100644 --- a/vm.c +++ b/vm.c @@ -840,8 +840,6 @@ static sexp sexp_print_vm_profile (sexp ctx, sexp self, sexp_sint_t n) { #define sexp_ensure_stack(n) #endif -#include - sexp sexp_apply (sexp ctx, sexp proc, sexp args) { unsigned char *ip; sexp bc, cp, *stack = sexp_stack_data(sexp_context_stack(ctx));