unix-memory-0.1.2: Unix memory syscalls

Copyright(c) Vincent Hanquez 2014
LicenseBSD-style
MaintainerVincent Hanquez
Stabilityprovisional
Portabilitynon-portable (requires POSIX)
Safe HaskellNone
LanguageHaskell98

System.Posix.Memory

Contents

Description

Functions defined by the POSIX standards for manipulating memory maps

When a function that calls an underlying POSIX function fails, the errno code is converted to an IOError using errnoToIOError. For a list of which errno codes may be generated, consult the POSIX documentation for the underlying function.

Synopsis

Documentation

memoryMap Source

Arguments

:: Maybe (Ptr a)

The address to map to if MapFixed is used.

-> CSize

The length of the mapping

-> [MemoryProtection]

the memory protection associated with the mapping

-> MemoryMapFlag 
-> Maybe Fd 
-> COff 
-> IO (Ptr a) 

Map pages of memory.

If fd is present, this memory will represent the file associated. Otherwise, the memory will be an anonymous mapping.

use mmap

memoryUnmap :: Ptr a -> CSize -> IO () Source

memoryAdvise :: Ptr a -> CSize -> MemoryAdvice -> IO () Source

give advice to the operating system about use of memory

call madvise

memoryLock :: Ptr a -> CSize -> IO () Source

lock a range of process address space

call mlock

memoryUnlock :: Ptr a -> CSize -> IO () Source

unlock a range of process address space

call munlock

memoryProtect :: Ptr a -> CSize -> [MemoryProtection] -> IO () Source

set protection of memory mapping

call mprotect

memorySync :: Ptr a -> CSize -> [MemorySyncFlag] -> IO () Source

memorySync synchronize memory with physical storage.

On an anonymous mapping this function doesn't have any effect. call msync

Flags types

data MemoryMapFlag Source

Mapping flag

Constructors

MemoryMapShared

memory changes are shared between process

MemoryMapPrivate

memory changes are private to process

data MemoryAdvice Source

Advice to put on memory.

only define the posix one.

Constructors

MemoryAdviceNormal

no specific advice, the default.

MemoryAdviceRandom

Expect page references in random order. No readahead should occur.

MemoryAdviceSequential

Expect page references in sequential order. Page should be readahead aggressively.

MemoryAdviceWillNeed

Expect access in the near future. Probably a good idea to readahead early

MemoryAdviceDontNeed

Do not expect access in the near future.

data MemorySyncFlag Source

Memory synchronization flags

Constructors

MemorySyncAsync

perform asynchronous write.

MemorySyncSync

perform synchronous write.

MemorySyncInvalidate

invalidate cache data.

system page size

sysconfPageSize :: Int Source

Return the operating system page size.

call sysconf