diff options
author | David Scott <dave.scott@eu.citrix.com> | 2013-03-20 20:24:42 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2013-04-11 12:03:11 +0100 |
commit | dfb9738cdc8cdbdf38747edfcdcf1bae46f074f2 (patch) | |
tree | f5da47fb42c7b8c359623ec98e803eb8a43ad678 /tools/ocaml/libs | |
parent | 0b1161e03753114ee149c7d65c1912fcbc3cf5df (diff) | |
download | xen-dfb9738cdc8cdbdf38747edfcdcf1bae46f074f2.tar.gz xen-dfb9738cdc8cdbdf38747edfcdcf1bae46f074f2.tar.bz2 xen-dfb9738cdc8cdbdf38747edfcdcf1bae46f074f2.zip |
ocaml: eventchn: add a 'type t' to represent an event channel
It's a common OCaml convention to add a 'type t' in a module to
represent the main "thing" that the module is about. We add an
opaque type t and to_int/of_int functions for those who really
need it, in particular:
1. to_int is needed for debug logging; and
2. both to_int and of_int are needed for anyone who communicates
a port number through xenstore.
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/ocaml/libs')
-rw-r--r-- | tools/ocaml/libs/eventchn/xeneventchn.ml | 6 | ||||
-rw-r--r-- | tools/ocaml/libs/eventchn/xeneventchn.mli | 17 |
2 files changed, 17 insertions, 6 deletions
diff --git a/tools/ocaml/libs/eventchn/xeneventchn.ml b/tools/ocaml/libs/eventchn/xeneventchn.ml index 79ad9b1e95..acebe10c6f 100644 --- a/tools/ocaml/libs/eventchn/xeneventchn.ml +++ b/tools/ocaml/libs/eventchn/xeneventchn.ml @@ -20,6 +20,9 @@ type handle external init: unit -> handle = "stub_eventchn_init" external fd: handle -> Unix.file_descr = "stub_eventchn_fd" + +type t = int + external notify: handle -> int -> unit = "stub_eventchn_notify" external bind_interdomain: handle -> int -> int -> int = "stub_eventchn_bind_interdomain" external bind_dom_exc_virq: handle -> int = "stub_eventchn_bind_dom_exc_virq" @@ -27,4 +30,7 @@ external unbind: handle -> int -> unit = "stub_eventchn_unbind" external pending: handle -> int = "stub_eventchn_pending" external unmask: handle -> int -> unit = "stub_eventchn_unmask" +let to_int x = x +let of_int x = x + let _ = Callback.register_exception "eventchn.error" (Error "register_callback") diff --git a/tools/ocaml/libs/eventchn/xeneventchn.mli b/tools/ocaml/libs/eventchn/xeneventchn.mli index 394acc2821..2b582cdaaf 100644 --- a/tools/ocaml/libs/eventchn/xeneventchn.mli +++ b/tools/ocaml/libs/eventchn/xeneventchn.mli @@ -18,14 +18,19 @@ exception Error of string type handle +type t + +val to_int: t -> int +val of_int: int -> t + external init : unit -> handle = "stub_eventchn_init" external fd: handle -> Unix.file_descr = "stub_eventchn_fd" -external notify : handle -> int -> unit = "stub_eventchn_notify" -external bind_interdomain : handle -> int -> int -> int +external notify : handle -> t -> unit = "stub_eventchn_notify" +external bind_interdomain : handle -> int -> int -> t = "stub_eventchn_bind_interdomain" -external bind_dom_exc_virq : handle -> int = "stub_eventchn_bind_dom_exc_virq" -external unbind : handle -> int -> unit = "stub_eventchn_unbind" -external pending : handle -> int = "stub_eventchn_pending" -external unmask : handle -> int -> unit +external bind_dom_exc_virq : handle -> t = "stub_eventchn_bind_dom_exc_virq" +external unbind : handle -> t -> unit = "stub_eventchn_unbind" +external pending : handle -> t = "stub_eventchn_pending" +external unmask : handle -> t -> unit = "stub_eventchn_unmask" |