<<>> <> <> <> <> <> DIRECTORY UnsafeStorage; UnsafeStorageImpl: CEDAR PROGRAM IMPORTS EXPORTS UnsafeStorage ~ BEGIN UZone: TYPE = POINTER TO UZoneRecord; UZoneRecord: TYPE = MACHINE DEPENDENT RECORD [new: NewProc, free: FreeProc]; NewProc: TYPE = UNSAFE PROC[self: UZone, units: CARD32] RETURNS[POINTER]; FreeProc: TYPE = UNSAFE PROC[self: UZone, object: POINTER]; systemUZone: UNCOUNTED ZONE ¬ GetUZone[New, Free]; GetSystemUZone: PUBLIC PROC RETURNS [UNCOUNTED ZONE] = { RETURN[systemUZone]}; GetUZone: PROC [new: NewProc, free: FreeProc] RETURNS [UNCOUNTED ZONE] = TRUSTED { uZone: UZone ¬ new[NIL, UNITS[UZoneRecord]]; uZone­ ¬ [new, free]; RETURN[LOOPHOLE[uZone]]}; overheadBytes: CARD = 8; -- There exist broken clients that use these bytes for there own purposes. New: NewProc = { malloc: PROC[units: CARD32] RETURNS [WORD] ~ TRUSTED MACHINE CODE { "GC_malloc" }; ptr: WORD ¬ malloc[units+overheadBytes]; RETURN [LOOPHOLE[ptr+overheadBytes]]; }; Free: FreeProc = { free: PROC[p: CARDINAL] = TRUSTED MACHINE CODE { "GC_free" }; ptr: CARDINAL ¬ LOOPHOLE[object, CARDINAL]-overheadBytes; free[LOOPHOLE[ptr]]; }; NewUObject: PUBLIC PROC [size: CARDINAL, zone: UNCOUNTED ZONE] RETURNS [LONG POINTER] = TRUSTED { RETURN [New[LOOPHOLE[zone, UZone], size]]; }; <<>> GetTransientPageUZone: PUBLIC PROC RETURNS [UNCOUNTED ZONE] = {ERROR NYI}; <<>> NYI: ERROR ~ CODE ; InvalidPointer: PUBLIC ERROR [ptr: LONG POINTER] ~ CODE; END.