[Hide Content]--- ocaml-3.11.0.orig/otherlibs/unix/unixsupport.h
+++ ocaml-3.11.0/otherlibs/unix/unixsupport.h
@@ -20,6 +20,7 @@
#define Nothing ((value) 0)
extern value unix_error_of_code (int errcode);
+extern int code_of_unix_error (value error);
extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
extern void uerror (char * cmdname, value arg) Noreturn;
--- ocaml-3.11.0.orig/otherlibs/unix/unixsupport.c
+++ ocaml-3.11.0/otherlibs/unix/unixsupport.c
@@ -263,6 +263,15 @@
return err;
}
+extern int code_of_unix_error (value error)
+{
+ if (Is_block(error)) {
+ return Int_val(Field(error, 0));
+ } else {
+ return error_table[Int_val(error)];
+ }
+}
+
void unix_error(int errcode, char *cmdname, value cmdarg)
{
value res;