OSMiscOps.mesa
Copyright Ó 1985, 1986, 1987, 1988, 1991 by Xerox Corporation. All rights reserved.
Satterthwaite, November 4, 1985 9:40:23 am PST
Russ Atkinson (RRA) December 8, 1988 4:13:05 pm PST
Willie-s, September 24, 1991 1:52 pm PDT
DIRECTORY
Basics USING [BITAND, BITNOT, BITOR, BITRSHIFT, BITXOR],
Basics16 USING [BITAND, BITNOT, BITOR, BITXOR],
MobDefs USING [MobFormat, VersionStamp];
OSMiscOps: DEFINITIONS
IMPORTS Basics, Basics16 = {
Bit utilities based on words
WordAnd: PROC [w1, w2: WORD] RETURNS [WORD] = INLINE {
IF BITS[WORD] = 16
THEN RETURN [Basics16.BITAND[w1, w2]]
ELSE RETURN [Basics.BITAND[w1, w2]];
};
WordOr: PROC [w1, w2: WORD] RETURNS [WORD] = INLINE {
IF BITS[WORD] = 16
THEN RETURN [Basics16.BITOR[w1, w2]]
ELSE RETURN [Basics.BITOR[w1, w2]];
};
WordXor: PROC [w1, w2: WORD] RETURNS [WORD] = INLINE {
IF BITS[WORD] = 16
THEN RETURN [Basics16.BITXOR[w1, w2]]
ELSE RETURN [Basics.BITXOR[w1, w2]];
};
WordNot: PROC [w: WORD] RETURNS [WORD] = INLINE {
IF BITS[WORD] = 16
THEN RETURN [Basics16.BITNOT[w]]
ELSE RETURN [Basics.BITNOT[w]];
};
utilities
Address: TYPE = LONG POINTER;
Pages: PROC [n: CARD] RETURNS [Address];
FreePages: PROC [base: Address];
Units: PROC [nUnits: CARD] RETURNS [base: Address];
FreeUnits: PROC [base: Address];
UnitsToBytes: PROC [units: INT] RETURNS [INT] = INLINE {
SELECT bytesPerUnit FROM
1 => RETURN [units];
2 => RETURN [units+units];
4 => RETURN [units+units+units+units];
ENDCASE => ERROR;
};
BytesToUnits: PROC [bytes: CARD] RETURNS [INT] = INLINE {
SELECT bytesPerUnit FROM
1 => RETURN [bytes];
2 => RETURN [Basics.BITRSHIFT[bytes, 1]];
4 => RETURN [Basics.BITRSHIFT[bytes, 2]];
ENDCASE => ERROR;
};
bytesPerUnit: NAT = BYTES[UNIT];
bytesPerFilePage: NAT;
mobFormat: MobDefs.MobFormat = [];
For PrincOps machines
copying & clearing
Copy: PROC [from: LONG POINTER, nwords: CARD, to: LONG POINTER];
Fill: PROC [where: LONG POINTER, nWords: CARD, value: WORD];
functional version stamps
Stamp: TYPE[SIZE[MobDefs.VersionStamp]];
MergeStamps: PROC [sum, item: Stamp] RETURNS [Stamp];
TimeToStamp: PROC [time: MobDefs.VersionStamp] RETURNS [Stamp];
StampToTime: PROC [s: Stamp] RETURNS [MobDefs.VersionStamp];
unique ids
GenerateUniqueId: PROC RETURNS [MobDefs.VersionStamp];
}.