primitive-0.5.0.1: Primitive memory-related operations

Portabilitynon-portable
MaintainerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Safe HaskellNone

Data.Primitive.Addr

Contents

Description

Primitive operations on machine addresses

Synopsis

Types

data Addr Source

A machine address

Constructors

Addr Addr# 

Instances

Eq Addr 
Data Addr 
Ord Addr 
Typeable Addr 
Prim Addr 

Address arithmetic

nullAddr :: AddrSource

The null address

plusAddr :: Addr -> Int -> AddrSource

Offset an address by the given number of bytes

minusAddr :: Addr -> Addr -> IntSource

Distance in bytes between two addresses. The result is only valid if the difference fits in an Int.

remAddr :: Addr -> Int -> IntSource

The remainder of the address and the integer.

Element access

indexOffAddr :: Prim a => Addr -> Int -> aSource

Read a value from a memory position given by an address and an offset. The memory block the address refers to must be immutable. The offset is in elements of type a rather than in bytes.

readOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> m aSource

Read a value from a memory position given by an address and an offset. The offset is in elements of type a rather than in bytes.

writeOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m ()Source

Write a value to a memory position given by an address and an offset. The offset is in elements of type a rather than in bytes.

Block operations

copyAddrSource

Arguments

:: PrimMonad m 
=> Addr

destination address

-> Addr

source address

-> Int

number of bytes

-> m () 

Copy the given number of bytes from the second Addr to the first. The areas may not overlap.

moveAddrSource

Arguments

:: PrimMonad m 
=> Addr

destination address

-> Addr

source address

-> Int

number of bytes

-> m () 

Copy the given number of bytes from the second Addr to the first. The areas may overlap.

setAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m ()Source

Fill a memory block of with the given value. The length is in elements of type a rather than in bytes.