mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/ocaml/xb,mmap: Use Data_abstract_val wrapper
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>
(cherry picked from commit d2ccc63711)
This commit is contained in:
1 parent
8c66a2d88a
commit
049d16c8ce
3 files changed
+6
-2
No files matched your search
@@ -30,4 +30,8 @@ struct mmap_interface
|
||||
int len;
|
||||
};
|
||||
|
||||
#ifndef Data_abstract_val
|
||||
#define Data_abstract_val(x) ((void *)Op_val(x))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||