
    <<OSMiscOps.mesa>>
        <<Copyright © 1985 by Xerox Corporation.  All rights reserved.>>
        <<Satterthwaite, November 4, 1985 9:40:23 am PST>>
        <<Maxwell, August 2, 1983 10:18 am>>
        <<Paul Rovner, November 21, 1983 9:36 am>>
        <<Russ Atkinson (RRA) March 6, 1985 10:04:54 pm PST>>

    DIRECTORY
        BcdDefs: TYPE USING [VersionStamp],
        VM: TYPE USING [wordsPerPage];

    OSMiscOps: DEFINITIONS = {

        <<utilities>>

            Address: TYPE = LONG POINTER;
            pageSize: CARDINAL = VM.wordsPerPage;

            Pages: PROC[n: CARDINAL] RETURNS[Address];
            FreePages: PROC[base: Address];

            Words: PROC[nWords: CARDINAL] RETURNS[base: Address] = INLINE {
                RETURN[Pages[(nWords + (pageSize-1)) / pageSize]]};
            FreeWords: PROC[base: Address] = INLINE {FreePages[base]};

        <<functional version stamps>>

            Stamp: TYPE [3];

            MergeStamps: PROC[sum, item: Stamp] RETURNS[Stamp];
            <<>>
            TimeToStamp: PROC[time: BcdDefs.VersionStamp] RETURNS[Stamp] = INLINE {
                RETURN[LOOPHOLE[time]]};
            StampToTime: PROC[s: Stamp] RETURNS[BcdDefs.VersionStamp] = INLINE {
                RETURN[LOOPHOLE[s]]};


        <<unique ids>>

            GenerateUniqueId: PROC RETURNS[BcdDefs.VersionStamp];

        }.

