summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--byterun/io.c4
-rw-r--r--byterun/sys.c31
-rw-r--r--byterun/sys.h1
3 files changed, 21 insertions, 15 deletions
diff --git a/byterun/io.c b/byterun/io.c
index a261adbc9..f8f186e50 100644
--- a/byterun/io.c
+++ b/byterun/io.c
@@ -163,7 +163,7 @@ again:
n = 1; goto again;
}
}
- if (retcode == -1) caml_sys_error(NO_ARG);
+ if (retcode == -1) caml_sys_io_error(NO_ARG);
return retcode;
}
@@ -266,7 +266,7 @@ CAMLexport int caml_do_read(int fd, char *p, unsigned int n)
retcode = read(fd, p, n);
caml_leave_blocking_section();
} while (retcode == -1 && errno == EINTR);
- if (retcode == -1) caml_sys_error(NO_ARG);
+ if (retcode == -1) caml_sys_io_error(NO_ARG);
return retcode;
}
diff --git a/byterun/sys.c b/byterun/sys.c
index 9d3bedbbb..801b1303b 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -73,23 +73,28 @@ CAMLexport void caml_sys_error(value arg)
char * err;
CAMLlocal1 (str);
+ err = error_message();
+ if (arg == NO_ARG) {
+ str = caml_copy_string(err);
+ } else {
+ int err_len = strlen(err);
+ int arg_len = caml_string_length(arg);
+ str = caml_alloc_string(arg_len + 2 + err_len);
+ memmove(&Byte(str, 0), String_val(arg), arg_len);
+ memmove(&Byte(str, arg_len), ": ", 2);
+ memmove(&Byte(str, arg_len + 2), err, err_len);
+ }
+ caml_raise_sys_error(str);
+ CAMLnoreturn;
+}
+
+CAMLexport void caml_sys_io_error(value arg)
+{
if (errno == EAGAIN || errno == EWOULDBLOCK) {
caml_raise_sys_blocked_io();
} else {
- err = error_message();
- if (arg == NO_ARG) {
- str = caml_copy_string(err);
- } else {
- int err_len = strlen(err);
- int arg_len = caml_string_length(arg);
- str = caml_alloc_string(arg_len + 2 + err_len);
- memmove(&Byte(str, 0), String_val(arg), arg_len);
- memmove(&Byte(str, arg_len), ": ", 2);
- memmove(&Byte(str, arg_len + 2), err, err_len);
- }
- caml_raise_sys_error(str);
+ caml_sys_error(arg);
}
- CAMLnoreturn;
}
CAMLprim value caml_sys_exit(value retcode)
diff --git a/byterun/sys.h b/byterun/sys.h
index ef2354275..4ad8011d9 100644
--- a/byterun/sys.h
+++ b/byterun/sys.h
@@ -21,6 +21,7 @@
#define NO_ARG Val_int(0)
CAMLextern void caml_sys_error (value);
+CAMLextern void caml_sys_io_error (value);
extern void caml_sys_init (char * exe_name, char ** argv);
CAMLextern value caml_sys_exit (value);