[v3,06/12] tools/ocaml: abi handling: Provide ocaml->C conversion/check
diff mbox series

Message ID 20190910120207.10358-7-ian.jackson@eu.citrix.com
State New
Headers show
Series
  • ocaml abi fixes
Related show

Commit Message

Ian Jackson Sept. 10, 2019, 12:02 p.m. UTC
From: Andrew Cooper <andrew.cooper3@citrix.com>

No users of this yet so no overall change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/ocaml/libs/xc/abi-check       |  3 ++-
 tools/ocaml/libs/xc/xenctrl_stubs.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Andrew Cooper Sept. 10, 2019, 12:22 p.m. UTC | #1
On 10/09/2019 13:02, Ian Jackson wrote:
> From: Andrew Cooper <andrew.cooper3@citrix.com>
>
> No users of this yet so no overall change.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>

I'm afraid this doesn't bisect.  It needs to be in the same patch as one
of its callers.

~Andrew
Ian Jackson Sept. 10, 2019, 12:50 p.m. UTC | #2
Andrew Cooper writes ("Re: [PATCH v3 06/12] tools/ocaml: abi handling: Provide ocaml->C conversion/check"):
> On 10/09/2019 13:02, Ian Jackson wrote:
> > From: Andrew Cooper <andrew.cooper3@citrix.com>
> >
> > No users of this yet so no overall change.
> >
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> I'm afraid this doesn't bisect.  It needs to be in the same patch as one
> of its callers.

Oops.  I will fix this with a temporary #if 0, since I don't like to
mix up the general with the specific.

While checking for bisectability I discovered my `make clean' target
was not working right.  I have added
   GENERATED_FILES += xenctrl_abi_check.h
to the Makefile patch.  I trust that it's OK to keep everyone's acks.

Ian.

Patch
diff mbox series

diff --git a/tools/ocaml/libs/xc/abi-check b/tools/ocaml/libs/xc/abi-check
index ccc35e79e9..a470c05e0b 100755
--- a/tools/ocaml/libs/xc/abi-check
+++ b/tools/ocaml/libs/xc/abi-check
@@ -22,6 +22,7 @@  our $ei;
 
 # Parse the C file looking for calls to:
 #   c_bitmap_to_ocaml_list()
+#   ocaml_list_to_c_bitmap()
 #
 # followed by anotations of the following form:
 #   /* ! OType OPrefix Mangle */
@@ -30,7 +31,7 @@  our $ei;
 # The function definitions use /* ! */ which simply skips that instance.
 while (<>) {
     if ($cline == -1) {
-        if (m/c_bitmap_to_ocaml_list/) {
+        if (m/c_bitmap_to_ocaml_list|ocaml_list_to_c_bitmap/) {
             $cline = 0;
             $ei = { };
         }
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 352a6bd2d6..c74c2b43a0 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -153,6 +153,21 @@  static value c_bitmap_to_ocaml_list
 	CAMLreturn(list);
 }
 
+static unsigned int ocaml_list_to_c_bitmap(value l)
+             /* ! */
+             /*
+	      * All calls to this function must be in a form suitable
+	      * for xenctrl_abi_check.  The parsing there is ad-hoc.
+	      */
+{
+	unsigned int val;
+
+	for ( ; l != Val_none; l = Field(l, 1) )
+		val |= 1u << Int_val(Field(l, 0));
+
+	return val;
+}
+
 CAMLprim value stub_xc_domain_create(value xch, value config)
 {
 	CAMLparam2(xch, config);