On Friday, 14 July 2017 15:39:24 CEST Richard W.M. Jones wrote: > It is sometimes useful to be able to call these from OCaml code. > --- > generator/daemon.ml | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-)
I see in patch #19: external available : unit -> bool = "guestfs_int_daemon_optgroup_lvm2_available" "noalloc" I think it'd be better to generate daemon/optgroups.ml{,i} instead, so there is no need for manual extern declarations. > diff --git a/generator/daemon.ml b/generator/daemon.ml > index fd01e5d8a..1d7461f8c 100644 > --- a/generator/daemon.ml > +++ b/generator/daemon.ml > @@ -976,6 +976,10 @@ let generate_daemon_optgroups_c () = > generate_header CStyle GPLv2plus; > > pr "#include <config.h>\n"; > + pr "#include <stdio.h>\n"; > + pr "#include <stdlib.h>\n"; Not a problem, but are they needed? > @@ -999,7 +1003,24 @@ let generate_daemon_optgroups_c () = > pr " { \"%s\", optgroup_%s_available },\n" group group > ) optgroups_names_all; > pr " { NULL, NULL }\n"; > - pr "};\n" > + pr "};\n"; > + pr "\n"; > + pr "/* Wrappers so these functions can be called from OCaml code. */\n"; > + List.iter ( > + fun group -> > + if not (List.mem group optgroups_retired) then ( > + pr "extern value guestfs_int_daemon_optgroup_%s_available (value);\n" > + group; > + pr "\n"; > + pr "/* NB: This is a \"noalloc\" call. */\n"; > + pr "value\n"; > + pr "guestfs_int_daemon_optgroup_%s_available (value unitv)\n" group; > + pr "{\n"; > + pr " return Val_bool (optgroup_%s_available ());\n" group; > + pr "}\n"; > + pr "\n" > + ) > + ) optgroups_names_all I'd use 'optgroups_names' here, that contains only non-retired optgroups (thus avoiding the check in the iteration). -- Pino Toscano
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs