From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Wed, 6 Aug 2008 17:02:32 +0000 (+0100) Subject: Added typed_addr type. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=07a7cdbdb7c9d2c066ae9fc81bfbf10c942f9ead;p=virt-mem.git Added typed_addr type. --- 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