[Pkg-libvirt-commits] [libguestfs] 01/26: ocaml: Add Guestfs.Errno submodule exposing useful raw errno numbers.
Hilko Bengen
bengen at moszumanska.debian.org
Thu Mar 20 23:06:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag upstream/1.25.46
in repository libguestfs.
commit 0563405d2e3f3d81581cccfecdfd41f2bdd08a47
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Mon Mar 17 12:10:15 2014 +0000
ocaml: Add Guestfs.Errno submodule exposing useful raw errno numbers.
For use when calling G.last_errno.
---
generator/ocaml.ml | 15 +++++++++++++++
ocaml/guestfs-c.c | 8 ++++++++
2 files changed, 23 insertions(+)
diff --git a/generator/ocaml.ml b/generator/ocaml.ml
index 78cff89..29a9eb6 100644
--- a/generator/ocaml.ml
+++ b/generator/ocaml.ml
@@ -121,10 +121,20 @@ val last_errno : t -> int
(or [0] if there was no errno). Note that the returned integer is the
raw errno number, and it is {i not} related to the {!Unix.error} type.
+ Some raw errno numbers are exposed by the {!Guestfs.Errno} submodule,
+ and we can add more as required.
+
[last_errno] can be overwritten by subsequent operations on a handle,
so if you want to capture the errno correctly, you must call this
in the {!Error} exception handler, before any other operation on [g]. *)
+(** The [Guestfs.Errno] submodule exposes some raw errno numbers,
+ which you can use to test the return value of {!Guestfs.last_errno}. *)
+
+module Errno : sig
+ val errno_ENOTSUP : int
+end
+
";
generate_ocaml_structure_decls ();
@@ -253,6 +263,11 @@ external event_to_string : event list -> string
external last_errno : t -> int = \"ocaml_guestfs_last_errno\"
+module Errno = struct
+ external enotsup : unit -> int = \"ocaml_guestfs_get_ENOTSUP\" \"noalloc\"
+ let errno_ENOTSUP = enotsup ()
+end
+
(* Give the exceptions names, so they can be raised from the C code. *)
let () =
Callback.register_exception \"ocaml_guestfs_error\" (Error \"\");
diff --git a/ocaml/guestfs-c.c b/ocaml/guestfs-c.c
index 98a9ba0..bd1ffb7 100644
--- a/ocaml/guestfs-c.c
+++ b/ocaml/guestfs-c.c
@@ -63,6 +63,7 @@ value ocaml_guestfs_set_event_callback (value gv, value closure, value events);
value ocaml_guestfs_delete_event_callback (value gv, value eh);
value ocaml_guestfs_event_to_string (value events);
value ocaml_guestfs_last_errno (value gv);
+value ocaml_guestfs_get_ENOTSUP (value unitv);
/* Allocate handles and deal with finalization. */
static void
@@ -438,3 +439,10 @@ ocaml_guestfs_last_errno (value gv)
rv = Val_int (r);
CAMLreturn (rv);
}
+
+/* NB: "noalloc" function. */
+value
+ocaml_guestfs_get_ENOTSUP (value unitv)
+{
+ return Val_int (ENOTSUP);
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list