[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] ocaml: add helpers for Some/None option types.
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1328027679 0 # Node ID f12ea2dbd328b1e8e57366a941bf33f0fb6a7fac # Parent 44ee4d37384faf3c7129545a5c4e067f28ec04e5 ocaml: add helpers for Some/None option types. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- diff -r 44ee4d37384f -r f12ea2dbd328 tools/ocaml/libs/xl/xenlight_stubs.c --- a/tools/ocaml/libs/xl/xenlight_stubs.c Tue Jan 31 16:34:39 2012 +0000 +++ b/tools/ocaml/libs/xl/xenlight_stubs.c Tue Jan 31 16:34:39 2012 +0000 @@ -130,6 +130,19 @@ #endif +/* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/ocaml-wrapping-c.php */ +#define Val_none Val_int(0) +#define Some_val(v) Field(v,0) + +static value Val_some(value v) +{ + CAMLparam1(v); + CAMLlocal1(some); + some = caml_alloc(1, 0); + Store_field(some, 0, v); + CAMLreturn(some); +} + static value Val_mac (libxl_mac *c_val) { CAMLparam0(); @@ -205,14 +218,13 @@ topologyinfo = caml_alloc_tuple(c_val->coremap.entries); for (i = 0; i < c_val->coremap.entries; i++) { - v = Val_int(0); /* None */ + v = Val_none; if (c_val->coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY) { topology = caml_alloc_tuple(3); Store_field(topology, 0, Val_int(c_val->coremap.array[i])); Store_field(topology, 1, Val_int(c_val->socketmap.array[i])); Store_field(topology, 2, Val_int(c_val->nodemap.array[i])); - v = caml_alloc(1, 0); /* Some */ - Store_field(v, 0, topology); + v = Val_some(topology); } Store_field(topologyinfo, i, v); } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |