diff --git a/Makefile b/Makefile index 68aeb29575..4ed97ccb12 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CC = gcc34 -CFLAGS = -Os -ffast-math -march=pentium4 -Wall -fomit-frame-pointer +CC = gcc +CFLAGS = -g -Wall LIBS = -lm STRIP = strip @@ -18,7 +18,7 @@ OBJS = native/arithmetic.o native/array.o native/bignum.o \ f: $(OBJS) $(CC) $(LIBS) -o $@ $(OBJS) - $(STRIP) $@ +# $(STRIP) $@ clean: rm -f $(OBJS) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 3b2515ca93..6508c2527c 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -69,6 +69,8 @@ + native: +- fix error postoning -- not all errors thrown by i/o code are + postponed - sbuf-hashcode - vector-hashcode - irc: stack underflow? diff --git a/library/cross-compiler.factor b/library/cross-compiler.factor index 573f20eb70..2d115962bc 100644 --- a/library/cross-compiler.factor +++ b/library/cross-compiler.factor @@ -79,6 +79,7 @@ DEFER: can-write? DEFER: add-write-io-task DEFER: write-fd-8 DEFER: add-copy-io-task +DEFER: pending-io-error DEFER: next-io-task IN: math @@ -247,6 +248,7 @@ IN: cross-compiler add-write-io-task write-fd-8 add-copy-io-task + pending-io-error next-io-task room os-env diff --git a/library/platform/native/io-internals.factor b/library/platform/native/io-internals.factor index b3ce88c243..47302832a9 100644 --- a/library/platform/native/io-internals.factor +++ b/library/platform/native/io-internals.factor @@ -73,4 +73,5 @@ USE: threads dup wait-to-accept accept-fd ; : blocking-copy ( in out -- ) - [ add-copy-io-task (yield) ] callcc0 2drop ; + [ add-copy-io-task (yield) ] callcc0 + pending-io-error pending-io-error ; diff --git a/native/port.c b/native/port.c index 25e5d876ec..88c468dc4e 100644 --- a/native/port.c +++ b/native/port.c @@ -100,3 +100,8 @@ void pending_io_error(PORT* port) general_error(ERROR_IO,io_error); } } + +void primitive_pending_io_error(void) +{ + pending_io_error(untag_port(dpop())); +} diff --git a/native/port.h b/native/port.h index 3553a037aa..fa2d0d9df9 100644 --- a/native/port.h +++ b/native/port.h @@ -42,3 +42,4 @@ void collect_port(PORT* port); void postpone_io_error(PORT* port, const char* func); void io_error(const char* func); void pending_io_error(PORT* port); +void primitive_pending_io_error(void); diff --git a/native/primitives.c b/native/primitives.c index e845e32604..b2607d68f1 100644 --- a/native/primitives.c +++ b/native/primitives.c @@ -133,6 +133,7 @@ XT primitives[] = { primitive_add_write_io_task, primitive_write_8, primitive_add_copy_io_task, + primitive_pending_io_error, primitive_next_io_task, primitive_room, primitive_os_env, diff --git a/native/primitives.h b/native/primitives.h index 66097546ab..95ef45ac2f 100644 --- a/native/primitives.h +++ b/native/primitives.h @@ -1,4 +1,4 @@ extern XT primitives[]; -#define PRIMITIVE_COUNT 147 +#define PRIMITIVE_COUNT 148 CELL primitive_to_xt(CELL primitive); diff --git a/native/write.c b/native/write.c index 917d335524..c918a9adc0 100644 --- a/native/write.c +++ b/native/write.c @@ -21,8 +21,6 @@ bool can_write(PORT* port, FIXNUM len) { CELL buf_capacity; - pending_io_error(port); - if(port->type != PORT_WRITE) general_error(ERROR_INCOMPATIBLE_PORT,tag_object(port)); @@ -42,6 +40,7 @@ void primitive_can_write(void) { PORT* port = untag_port(dpop()); FIXNUM len = to_fixnum(dpop()); + pending_io_error(port); dpush(tag_boolean(can_write(port,len))); } @@ -73,6 +72,8 @@ void write_char_8(PORT* port, FIXNUM ch) { char c = (char)ch; + pending_io_error(port); + if(!can_write(port,1)) io_error(__FUNCTION__); @@ -94,6 +95,8 @@ void write_string_8(PORT* port, STRING* str) { char* c_str; + pending_io_error(port); + /* Note this ensures the buffer is large enough to fit the string */ if(!can_write(port,str->capacity)) io_error(__FUNCTION__);