]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
tools/ocaml/xb,mmap: Use Data_abstract_val wrapper
authorEdwin Török <edvin.torok@citrix.com>
Fri, 16 Dec 2022 18:25:10 +0000 (18:25 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 19 Dec 2022 19:31:26 +0000 (19:31 +0000)
This is not strictly necessary since it is essentially a no-op currently: a
cast to void * and value *, even in OCaml 5.0.

However it does make it clearer that what we have here is not a regular OCaml
value, but one allocated with Abstract_tag or Custom_tag, and follows the
example from the manual more closely:
https://v2.ocaml.org/manual/intfc.html#ss:c-outside-head

It also makes it clearer that these modules have been reviewed for
compat with OCaml 5.0.

We cannot use OCaml finalizers here, because we want exact control over when
to unmap these pages from remote domains.

No functional change.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/mmap/mmap_stubs.h
tools/ocaml/libs/mmap/xenmmap_stubs.c
tools/ocaml/libs/xb/xs_ring_stubs.c

index 65e4239890489e95ca07e1501bfde580306bf57d..f4784e4715306ce8ce42dcfaa6b0cca13defd783 100644 (file)
@@ -30,4 +30,8 @@ struct mmap_interface
        int len;
 };
 
+#ifndef Data_abstract_val
+#define Data_abstract_val(x) ((void *)Op_val(x))
+#endif
+
 #endif
index e2ce088e2588747d40b71478987af20a9bc65cc3..e03951d781bbe28d8584053bb0c74ef59a8014ff 100644 (file)
@@ -28,7 +28,7 @@
 #include <caml/fail.h>
 #include <caml/callback.h>
 
-#define Intf_val(a) ((struct mmap_interface *) a)
+#define Intf_val(a) ((struct mmap_interface *)Data_abstract_val(a))
 
 static int mmap_interface_init(struct mmap_interface *intf,
                                int fd, int pflag, int mflag,
index 7a91fdee7548dbe7745690faf8cab385c22e9f6a..1f585245351eb84af3cc9d98061f8025bbb18161 100644 (file)
@@ -35,7 +35,7 @@
 #include <sys/mman.h>
 #include "mmap_stubs.h"
 
-#define GET_C_STRUCT(a) ((struct mmap_interface *) a)
+#define GET_C_STRUCT(a) ((struct mmap_interface *)Data_abstract_val(a))
 
 /*
  * Bytes_val has been introduced by Ocaml 4.06.1. So define our own version