summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/unixsupport.c
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2007-02-07 14:45:46 +0000
committerDamien Doligez <damien.doligez-inria.fr>2007-02-07 14:45:46 +0000
commit5d5094fe30b1f66b53cc468108afd5def3a547ea (patch)
treed540da85a5be5e88ece563f26b9efe77677c6231 /otherlibs/win32unix/unixsupport.c
parent5d2081fc441bb3310dbd934c22d3f87464d317c4 (diff)
PR#4123, PR#4125: export unixsupport.h with unix_error_of_code
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7832 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/unixsupport.c')
-rw-r--r--otherlibs/win32unix/unixsupport.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c
index 90cade2a0..b7d4ad92d 100644
--- a/otherlibs/win32unix/unixsupport.c
+++ b/otherlibs/win32unix/unixsupport.c
@@ -221,6 +221,22 @@ int error_table[] = {
static value * unix_error_exn = NULL;
+value unix_error_of_code (int errcode)
+{
+ int errconstr;
+ value err;
+
+ errconstr =
+ cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1);
+ if (errconstr == Val_int(-1)) {
+ err = alloc_small(1, 0);
+ Field(err, 0) = Val_int(errcode);
+ } else {
+ err = errconstr;
+ }
+ return err;
+}
+
void unix_error(int errcode, char *cmdname, value cmdarg)
{
value res;
@@ -230,14 +246,7 @@ void unix_error(int errcode, char *cmdname, value cmdarg)
Begin_roots3 (name, err, arg);
arg = cmdarg == Nothing ? copy_string("") : cmdarg;
name = copy_string(cmdname);
- errconstr =
- cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1);
- if (errconstr == Val_int(-1)) {
- err = alloc_small(1, 0);
- Field(err, 0) = Val_int(errcode);
- } else {
- err = errconstr;
- }
+ err = unix_error_of_code (errcode);
if (unix_error_exn == NULL) {
unix_error_exn = caml_named_value("Unix.Unix_error");
if (unix_error_exn == NULL)