std/reservedmem

Source   Edit  

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.

Types

ReservedMem = object
  
Source   Edit  
ReservedMemSeq[T] = object
  
Source   Edit  

Consts

memExec = 16
Source   Edit  
memExecRead = 32
Source   Edit  
memRead = 2
Source   Edit  
memReadWrite = 4
Source   Edit  

Procs

func `[]`[T](s: ReservedMemSeq[T]; pos: Natural): lent T
Source   Edit  
func `[]`[T](s: ReservedMemSeq[T]; rpos: BackwardsIndex): lent T
Source   Edit  
func `[]`[T](s: var ReservedMemSeq[T]; pos: Natural): var T
Source   Edit  
func `[]`[T](s: var ReservedMemSeq[T]; rpos: BackwardsIndex): var T
Source   Edit  
proc add[T](s: var ReservedMemSeq[T]; val: T)
Source   Edit  
func commitedLen(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
func commitedLen[T](s: ReservedMemSeq[T]): int
Source   Edit  
proc init(SeqType: type ReservedMemSeq; maxLen: Natural; initLen: Natural = 0;
          initCommitLen: Natural = 0; memStart = pointer(nil);
          accessFlags = memReadWrite; maxCommittedAndUnusedPages = 3): SeqType:type
Source   Edit  
proc init(T: type ReservedMem; maxLen: Natural; initLen: Natural = 0;
          initCommitLen = initLen; memStart = pointer(nil);
          accessFlags = memReadWrite; maxCommittedAndUnusedPages = 3): ReservedMem
Source   Edit  
func len(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
func len[T](s: ReservedMemSeq[T]): int
Source   Edit  
func maxLen(m: ReservedMem): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
func maxLen[T](s: ReservedMemSeq[T]): int
Source   Edit  
proc pop[T](s: var ReservedMemSeq[T]): T
Source   Edit  
proc setLen(m: var ReservedMem; newLen: int) {....raises: [OSError], tags: [],
    forbids: [].}
Source   Edit  
proc setLen[T](s: var ReservedMemSeq[T]; newLen: int)
Source   Edit  

Templates

template distance(lhs, rhs: pointer): int
Source   Edit  
template shift(p: pointer; distance: int): pointer
Source   Edit