| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Capnp.Address
Description
This module provides facilities for manipulating raw addresses within Cap'N Proto messages.
This is a low level module that very few users will need to use directly.
Synopsis
- data WordAddr = WordAt {}
- newtype CapAddr = Cap Word32
- data Addr
- data OffsetError
- computeOffset :: WordAddr -> WordAddr -> Either OffsetError WordCount
- pointerFrom :: WordAddr -> WordAddr -> Ptr -> Either OffsetError Ptr
- resolveOffset :: WordAddr -> Int32 -> WordAddr
Documentation
The address of a word within a message
Constructors
| WordAt | |
The "address" of a capability
An address, i.e. a location that a pointer may point at.
data OffsetError Source #
An error returned by computeOffset; this describes the reason why a
 value cannot be directly addressed from a given location.
Constructors
| DifferentSegments | The pointer and the value are in different segments. | 
| OutOfRange | The pointer is in the correct segment, but too far away to encode the offset. (more than 30 bits would be required). This can only happen with segments that are > 8 GiB, which this library refuses to either decode or generate, so this should not come up in practice. | 
computeOffset :: WordAddr -> WordAddr -> Either OffsetError WordCount Source #
computeOffset ptrAddr valueAddrptrAddr, in order to point
 at a value located at valueAddr. If the value cannot be directly addressed
 by a pointer at ptrAddr, then this returns Left, with the OffsetError
 describing the problem.
pointerFrom :: WordAddr -> WordAddr -> Ptr -> Either OffsetError Ptr Source #
pointerFrom ptrAddr targetAddr ptrptr, such that it is
 correct to target a value located at targetAddr given that the pointer
 itself is located at ptrAddr. Returns Left if this is not possible.
It is illegal to call this on a capability pointer.
For far pointers, targetAddr is taken to be the address of the landing pad,
 rather than the final value.