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. ´ OSPCedarImpl.mesa JKF March 22, 1988 4:26:27 pm PST RealFns; Order of the declarations and their initialization is important. RETURN[RealFns.AlmostEqual[y, x, distance]]; ÊË•NewlineDelimiter ™J™J™!J˜šÏk ˜ J˜J™J˜—JšÏn œœœ œ˜@˜Jšœœœœ˜Jš œœœœœ ˜*šœ œœ˜Jš œœœœœœ˜?Jšœœœœ˜-J˜J˜—Jš œ œœœœ œ˜8Jšœ œœœœœœœœ˜@J˜šžœœ œœ˜#Jš žœ œ œœœ˜5—J˜AJ˜ J˜˜šžœœ œœ˜(š ž œœœœœœ˜D˜ J˜—Jšœœ˜J˜ J˜ J˜ J˜ J˜ Jš œœœœœœ˜1J˜J˜J˜——J™BJ˜š žœœœœ œœ˜8Jšœ˜ J˜J˜—šž œœœœ ˜FJšœœœ˜J˜J˜—šžœœ˜3J˜ J˜J˜—šžœœœœœœœ˜JJ˜ J˜J˜—š žœœœœœ˜/J˜ J˜J˜—J˜HJšœ œœœ˜/J˜šžœœ œœ˜'š ž œ œœœœœ˜4Jšœœœ˜J˜C—J˜J˜J˜—š ž œœ œœ œ ˜HJšœœ˜J™,Jšœ˜J˜J˜—Jšœœ˜%J˜š ž œœ œœœœ˜Fš žœ œœœÏcœ˜GJš œœœœœœ˜0J˜›J˜—JšœœœœŸ5˜NJšœ˜J˜J˜J˜———Jšœ˜—…—¸ 7