From 07a7cdbdb7c9d2c066ae9fc81bfbf10c942f9ead Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Added typed_addr type. --- lib/virt_mem_mmap.ml | 6 ++++++ lib/virt_mem_mmap.mli | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/virt_mem_mmap.ml b/lib/virt_mem_mmap.ml index c323c1a..e5f0101 100644 --- a/lib/virt_mem_mmap.ml +++ b/lib/virt_mem_mmap.ml @@ -618,3 +618,9 @@ let align t addr = let ws = get_wordsize t in let mask = Int64.of_int (bytes_of_wordsize ws - 1) in (addr +^ mask) &^ (Int64.lognot mask) + +(* Typed addresses. *) +type 'a typed_addr + +external unsafe_addr_of_typed_addr : 'a typed_addr -> addr = "%identity" +external unsafe_typed_addr_of_addr : addr -> 'a typed_addr = "%identity" diff --git a/lib/virt_mem_mmap.mli b/lib/virt_mem_mmap.mli index 0294efd..78f9b8c 100644 --- a/lib/virt_mem_mmap.mli +++ b/lib/virt_mem_mmap.mli @@ -99,6 +99,13 @@ type ('ws,'e,'hm) t type addr = int64 (** Virtual memory addresses (even on 32 bit machines). *) +type 'a typed_addr +(** Virtual memory addresses with an implicit type, one which we know + or believe is pointing at a struct of some known type. *) + +external unsafe_addr_of_typed_addr : 'a typed_addr -> addr = "%identity" +external unsafe_typed_addr_of_addr : addr -> 'a typed_addr = "%identity" + (** {2 Create a memory map, add mappings} *) val create : unit -> ([`NoWordsize], [`NoEndian], [`NoMappings]) t -- 1.8.3.1