On 18 Jun 2021, at 11:45, Edwin Török 
<edvin.to...@citrix.com<mailto:edvin.to...@citrix.com>> wrote:

Introduces following functions in Xenctrl and associated types:
get_system_cpu_policy
cpu_policy_to_featureset,
string_of_xen_cpu_policy_index

These are wrappers around the existing C functions in xenctrl.h,
that will be used by xenopsd initially.

-Wno-declaration-after-statement is disabled to allow mixing
declarations and code to simplify writing the stubs
by using variable length arrays on the stack instead of
allocating/freeing memory
(which would require additional error-handling logic).

Signed-off-by: Edwin Török 
<edvin.to...@citrix.com<mailto:edvin.to...@citrix.com>>
---
tools/ocaml/libs/xc/Makefile        |   2 +-
tools/ocaml/libs/xc/xenctrl.ml      |  37 ++++++
tools/ocaml/libs/xc/xenctrl.mli     |  71 ++++++++++
tools/ocaml/libs/xc/xenctrl_stubs.c | 195 ++++++++++++++++++++++++++++
4 files changed, 304 insertions(+), 1 deletion(-)

Acked-by: Christian Lindig 
<christian.lin...@citrix.com<mailto:christian.lin...@citrix.com>>


+static CAMLprim value Val_leaves(const xen_cpuid_leaf_t *leaves, uint32_t 
nr_leaves)
+{
+    CAMLparam0();
+    CAMLlocal1(result);
+    uint32_t i;
+
+    result = caml_alloc(nr_leaves, 0);
+    for (i=0;i<nr_leaves;i++)
+        Store_field(result, i, Val_cpuid_leaf(&leaves[i]));
+
+    CAMLreturn(result);
+}

Is  caml_alloc(nr_leaves, 0) the right allocation? The 0 is the tag. There is 
another instance of this below. What is the type of the returned value from an 
OCaml perspective?

— C

Reply via email to