diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-03-01 12:26:14 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-03-01 12:26:14 +0000 |
commit | 50cbda0d0b1bffa4a7af91b5ff8a65d88191fdbb (patch) | |
tree | fcc97d3b3fbf51bdccae615127ae6c94e4ff6a0c /tools/ocaml | |
parent | 966deb4db61ea44e2487c84daa0939f52416fa83 (diff) | |
download | xen-50cbda0d0b1bffa4a7af91b5ff8a65d88191fdbb.tar.gz xen-50cbda0d0b1bffa4a7af91b5ff8a65d88191fdbb.tar.bz2 xen-50cbda0d0b1bffa4a7af91b5ff8a65d88191fdbb.zip |
libxl: add new "defbool" built in type.
This type is a but like a "boolean" but with a third state "default" (so really
I suppose it's a tristate).
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/ocaml')
-rw-r--r-- | tools/ocaml/libs/xl/genwrap.py | 1 | ||||
-rw-r--r-- | tools/ocaml/libs/xl/xenlight_stubs.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py index 22cca80bcb..384ec5b4ea 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -10,6 +10,7 @@ builtins = { "int": ("int", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), "char *": ("string", "%(c)s = dup_String_val(gc, %(o)s)", "caml_copy_string(%(c)s)"), "libxl_domid": ("domid", "%(c)s = Int_val(%(o)s)", "Val_int(%(c)s)" ), + "libxl_defbool": ("bool option", "%(c)s = Defbool_val(%(o)s)", "Val_defbool(%(c)s)" ), "libxl_uuid": ("int array", "Uuid_val(gc, lg, &%(c)s, %(o)s)", "Val_uuid(&%(c)s)"), "libxl_key_value_list": ("(string * string) list", None, None), "libxl_mac": ("int array", "Mac_val(gc, lg, &%(c)s, %(o)s)", "Val_mac(&%(c)s)"), diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c index f1511d46dd..2ba07fc579 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -195,6 +195,33 @@ static int Uuid_val(caml_gc *gc, struct caml_logger *lg, libxl_uuid *c_val, valu CAMLreturn(0); } +static value Val_defbool(libxl_defbool c_val) +{ + CAMLparam0(); + CAMLlocal1(v); + + if (libxl_defbool_is_default(c_val)) + v = Val_none; + else { + bool b = libxl_defbool_val(c_val); + v = Val_some(b ? Val_bool(true) : Val_bool(false)); + } + CAMLreturn(v); +} + +static libxl_defbool Defbool_val(value v) +{ + CAMLparam1(v); + libxl_defbool db; + if (v == Val_none) + libxl_defbool_unset(&db); + else { + bool b = Bool_val(Some_val(v)); + libxl_defbool_set(&db, b); + } + return db; +} + static value Val_hwcap(libxl_hwcap *c_val) { CAMLparam0(); |