<<>> <> <> DIRECTORY OSOps; <> OSPCedarImpl: PROGRAM <> EXPORTS OSOps = BEGIN Ptr: TYPE = LONG POINTER; UZone: TYPE = LONG POINTER TO UZoneObject; UZoneObject: TYPE = RECORD[ new: PROC[self: UZone, size: CARDINAL] RETURNS[LONG POINTER], free: PROC[self: UZone, object: LONG POINTER] ]; CHARPtr: TYPE ~ RECORD [ptr: POINTER TO RawChars _ NIL]; RawChars: TYPE = RECORD [PACKED SEQUENCE COMPUTED CARD OF CHAR]; PutD: PUBLIC PROCEDURE [i: INT] = { PrintD: PROCEDURE [value: UNSPEC32] = MACHINE CODE { "+#define printd(value) XR_Msg(-3, \" %d \", (value) ).printd" }; PrintD[i]; }; PutChar: PUBLIC PROCEDURE [ch: CHAR] = { CharInner: PROC [buf: CHARPtr, nBytes: INT] = TRUSTED MACHINE CODE { "XR_MsgWrite" }; s: STRING _ [4]; buf: CHARPtr; s[0] _ ch; s[1] _ 0C; s[2] _ 0C; s[3] _ 0C; buf _ LOOPHOLE[LOOPHOLE[s, CARD]+UNITS[TEXT[0]]]; CharInner[buf: buf, nBytes: 1]; }; <> GetSystemUZone: PUBLIC PROC RETURNS [UNCOUNTED ZONE] = { RETURN [zhs]; }; NewHeapObject: PROC [self: UZone, size: CARDINAL] RETURNS [p: Ptr] = { p _ Malloc[size*SIZE[WORD]]; }; FreeHeapObject: PROC [self: UZone, object: Ptr] = { Free[object]; }; Malloc: PROC [size: CARDINAL] RETURNS [ptr: Ptr] = TRUSTED MACHINE CODE { "XR_malloc" }; Free: PROC [ptr: Ptr] = TRUSTED MACHINE CODE { "XR_free" }; rZnHeapSystem: UZoneObject _ [new: NewHeapObject, free: FreeHeapObject]; zhs: UNCOUNTED ZONE _ LOOPHOLE[@rZnHeapSystem]; PutReal: PUBLIC PROCEDURE [r: REAL] = { PutRealInner: PROCEDURE [x: LONG POINTER TO REAL] = TRUSTED MACHINE CODE { "*#define PutReal(x) XR_Msg(-3, \"%4.1f\", *(float *)x).PutReal";}; PutRealInner[@r]; }; AlmostEqual: PUBLIC PROCEDURE [y, x: REAL, distance: INTEGER [-126..0]] RETURNS [BOOLEAN] = { <> RETURN[x = y]; }; milSecondsPerSecond: CARDINAL = 1000; CurrentTime: PUBLIC PROCEDURE RETURNS [currentTime: LONG CARDINAL] = { CurrentTimeInner: PROCEDURE [x: LONG POINTER --TO 10 byte structure--] RETURNS [LONG CARDINAL] = TRUSTED MACHINE CODE { "%\n\n*#define GetMSec(x) (ftime((struct timeb *)x), (((struct timeb *)x)->time * 1000) + ((struct timeb *)x)->millitm).GetMSec"; }; a: ARRAY [0..4] OF CARD; -- just has to be 10 bytes for the unix time function RETURN[CurrentTimeInner[@a]]; }; END.