Authors: | Zahary Karadjov |
---|
This module provides utilities for reserving portions of the address space of a program without consuming physical memory. It can be used to implement a dynamically resizable buffer that is guaranteed to remain in the same memory location. The buffer will be able to grow up to the size of the initially reserved portion of the address space.
Unstable API.
Imports
oserrors, winlean, win_getsysteminfo
Types
MemAccessFlags = int
ReservedMem = object
ReservedMemSeq[T] = object
Consts
memExec = 16
memExecRead = 32
memExecReadWrite = 64
memRead = 2
memReadWrite = 4
Procs
func `[]`[T](s: ReservedMemSeq[T]; pos: Natural): lent T
func `[]`[T](s: ReservedMemSeq[T]; rpos: BackwardsIndex): lent T
func `[]`[T](s: var ReservedMemSeq[T]; pos: Natural): var T
func `[]`[T](s: var ReservedMemSeq[T]; rpos: BackwardsIndex): var T
proc add[T](s: var ReservedMemSeq[T]; val: T)
func commitedLen(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
func commitedLen[T](s: ReservedMemSeq[T]): int
proc init(SeqType: type ReservedMemSeq; maxLen: Natural; initLen: Natural = 0;
initCommitLen: Natural = 0; memStart = pointer(nil);
accessFlags = memReadWrite; maxCommittedAndUnusedPages = 3): SeqType:type
proc init(T: type ReservedMem; maxLen: Natural; initLen: Natural = 0;
initCommitLen = initLen; memStart = pointer(nil);
accessFlags = memReadWrite; maxCommittedAndUnusedPages = 3): ReservedMem
func len(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
func len[T](s: ReservedMemSeq[T]): int
func maxLen(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
func maxLen[T](s: ReservedMemSeq[T]): int
proc pop[T](s: var ReservedMemSeq[T]): T
proc setLen(m: var ReservedMem; newLen: int) {....raises: [OSError], tags: [],
forbids: [].}
proc setLen[T](s: var ReservedMemSeq[T]; newLen: int)
Templates
template distance(lhs, rhs: pointer): int
template shift(p: pointer; distance: int): pointer