-- ExecStorage.mesa
-- Edited by Levin, September 9, 1980 5:17 PM
-- Edited by Brotz, October 16, 1980 11:10 AM

DIRECTORY
FSPDefs,
LaurelExecImpDefs,
SegmentDefs,
Storage,
SystemDefs;

ExecStorage: PROGRAM
IMPORTS FSPDefs, SegmentDefs, realSystemDefs: SystemDefs
EXPORTS SystemDefs, Storage, LaurelExecImpDefs = PUBLIC

BEGIN

-- Interface for Laurel Executive

clientPages: CARDINAL;
clientWords: CARDINAL;


-- SystemDefs Interface for Laurel Client BCDs

AllocatePages: PROCEDURE [npages: CARDINAL] RETURNS [base: POINTER] =
BEGIN
base ← realSystemDefs.AllocatePages[npages];
clientPages ← clientPages + npages;
END;

AllocateResidentPages, Pages: PROCEDURE [npages: CARDINAL]
RETURNS [base: POINTER] =
BEGIN
base ← realSystemDefs.AllocateResidentPages[npages];
clientPages ← clientPages + npages;
END;

FreePages, FreeSegment, FreeWords: PROCEDURE [base: POINTER] =
BEGIN
clientPages ← clientPages - SegmentDefs.VMtoDataSegment[base].pages;
realSystemDefs.FreePages[base];
END;

AllocateSegment: PROCEDURE [nwords: CARDINAL] RETURNS [base: POINTER] =
BEGIN
base ← realSystemDefs.AllocateSegment[nwords];
clientPages ← clientPages + SegmentDefs.VMtoDataSegment[base].pages;
END;

AllocateResidentSegment, Words: PROCEDURE [nwords: CARDINAL]
RETURNS [base: POINTER] =
BEGIN
base ← realSystemDefs.AllocateResidentSegment[nwords];
clientPages ← clientPages + SegmentDefs.VMtoDataSegment[base].pages;
END;

SegmentSize: PROCEDURE [base: POINTER] RETURNS [nwords: CARDINAL] =
{RETURN[realSystemDefs.SegmentSize[base]]};

AllocateHeapNode, Node: PROCEDURE [nwords: CARDINAL] RETURNS [p: POINTER] =
BEGIN
p ← realSystemDefs.AllocateHeapNode[nwords];
clientWords ← clientWords + FSPDefs.NodeSize[p];
END;

FreeHeapNode, Free: PROCEDURE [p: POINTER] =
BEGIN
clientWords ← clientWords - FSPDefs.NodeSize[p];
realSystemDefs.FreeHeapNode[p];
END;

AllocateHeapString, String: PROCEDURE [nchars: CARDINAL] RETURNS [STRING] =
BEGIN
s: STRING ← realSystemDefs.AllocateHeapString[nchars];
clientWords ← clientWords + FSPDefs.NodeSize[s];
RETURN[s]
END;

FreeHeapString, FreeString: PROCEDURE [s: STRING] =
BEGIN
clientWords ← clientWords - FSPDefs.NodeSize[s];
realSystemDefs.FreeHeapString[s];
END;

CopyString: PROCEDURE [s: STRING, longer: CARDINAL ← 0] RETURNS [STRING] =
BEGIN
newS: STRING ← realSystemDefs.CopyString[s, longer];
IF newS ~= NIL THEN clientWords ← clientWords + FSPDefs.NodeSize[newS];
RETURN[newS]
END;

ExpandString: PROCEDURE [s: POINTER TO STRING, longer: CARDINAL] =
BEGIN
IF s↑ ~= NIL THEN clientWords ← clientWords - FSPDefs.NodeSize[s↑];
realSystemDefs.ExpandString[s, longer];
clientWords ← clientWords + FSPDefs.NodeSize[s↑];
END;

HeapZone: PROCEDURE RETURNS [FSPDefs.ZonePointer] =
{RETURN[realSystemDefs.HeapZone[]]};

PruneHeap, Prune: PROCEDURE RETURNS [BOOLEAN] =
{RETURN[realSystemDefs.PruneHeap[]]};

Even: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED] =
{RETURN[realSystemDefs.Even[u]]};

Quad: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED] =
{RETURN[realSystemDefs.Quad[u]]};

END. -- of ExecStorage --