[PATCH 1/7] tools/ocaml/libs: Don't declare stubs as taking void

Andrew Cooper posted 7 patches 1 year, 9 months ago
[PATCH 1/7] tools/ocaml/libs: Don't declare stubs as taking void
Posted by Andrew Cooper 1 year, 9 months ago
From: Edwin Török <edwin.torok@cloud.com>

There is no such thing as an Ocaml function (C stub or otherwise) taking no
parameters.  In the absence of any other parameters, unit is still passed.

This doesn't explode with any ABI we care about, but would malfunction for an
ABI environment such as stdcall.

Fixes: c3afd398ba7f ("ocaml: Add XS bindings.")
Fixes: 8b7ce06a2d34 ("ocaml: Add XC bindings.")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Christian Lindig <christian.lindig@citrix.com>
CC: David Scott <dave@recoil.org>
CC: Edwin Török <edwin.torok@cloud.com>
CC: Rob Hoes <Rob.Hoes@citrix.com>
---
 tools/ocaml/libs/xb/xenbus_stubs.c  | 5 ++---
 tools/ocaml/libs/xc/xenctrl_stubs.c | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/ocaml/libs/xb/xenbus_stubs.c b/tools/ocaml/libs/xb/xenbus_stubs.c
index 3065181a55e6..97116b07826a 100644
--- a/tools/ocaml/libs/xb/xenbus_stubs.c
+++ b/tools/ocaml/libs/xb/xenbus_stubs.c
@@ -30,10 +30,9 @@
 #include <xenctrl.h>
 #include <xen/io/xs_wire.h>
 
-CAMLprim value stub_header_size(void)
+CAMLprim value stub_header_size(value unit)
 {
-	CAMLparam0();
-	CAMLreturn(Val_int(sizeof(struct xsd_sockmsg)));
+	return Val_int(sizeof(struct xsd_sockmsg));
 }
 
 CAMLprim value stub_header_of_string(value s)
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 2fba9c5e94d6..728818445975 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -86,9 +86,9 @@ static void Noreturn failwith_xc(xc_interface *xch)
 	caml_raise_with_string(*caml_named_value("xc.error"), error_str);
 }
 
-CAMLprim value stub_xc_interface_open(void)
+CAMLprim value stub_xc_interface_open(value unit)
 {
-	CAMLparam0();
+	CAMLparam1(unit);
 	CAMLlocal1(result);
 	xc_interface *xch;
 
-- 
2.11.0