IncrementalLoad.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Transliterated from IncrementalLoad.h of Demers September 20, 1989 8:43:06 am PDT on September 21, 1989 by Spreitzer
Last tweaked by Mike Spreitzer on September 19, 1989 9:40:06 am PDT
JKF, February 21, 1990 9:15:26 am PST
Willie-s, March 3, 1992 3:29 pm PST
DIRECTORY CStrings;
IncrementalLoad: CEDAR DEFINITIONS =
BEGIN
CString: TYPE ~ CStrings.CString;
Bool: TYPE ~ INT32;
False: Bool ~ 0; --True is #0
Long: TYPE ~ CARD32; -- transliteration of `long'
ErrorRep: TYPE ~ MACHINE DEPENDENT RECORD [fatal: Bool, code: INT32, msg: CString];
Error: TYPE ~ POINTER TO ErrorRep; -- NIL <=> success
LockIncrementalLoadState: PROC [wait: BOOL] RETURNS [Error];
A successful call must be followed (eventually) by a call to UnlockIncrementalLoadState.
UnlockIncrementalLoadState: PROC RETURNS [Error];
FileEntry: TYPE ~ POINTER TO FileEntryRep;
FileEntryRep: TYPE ~ MACHINE DEPENDENT RECORD [
seqNum: CARD32,
commitPoint: Bool,
fName: CString,
fOffset, fMagic: CARD32,
fSize: INT32,
fMTime: Long,
vMagic, vLen: CARD32,
vStamp: CString,
rdrData, patch, text, data, bss, common: CountedString];
CountedString: TYPE ~ MACHINE DEPENDENT RECORD [s: CString, len: CARD32];
GetPrevFileEntry: PROC [fe: FileEntry] RETURNS [FileEntry];
Return FileEntries in reverse order of loading.
Return most-recently-loaded entry if fe is NIL.
Return NIL at end of sequence.
AddVersionStamp: PROC [fe: FileEntry, vMagic, vLen: CARD32, vStamp: CString];
AddVersionStampUsingPC: PROC [pc: POINTER, vMagic, vLen: CARD32, vStamp: CString] RETURNS [FileEntry];
To be called by an installation proc to record its version stamp.
The vStamp pointer is stored into the FileEntry associated with pc, without being copied; thus, it can't point to a buffer in a local frame.
BEWARE: these procs don't do any locking. Concurrent calls that add version stamps for different files don't interfere with one another.
SymEntry: TYPE ~ POINTER TO SymEntryRep;
SymEntryRep: TYPE ~ MACHINE DEPENDENT RECORD [
name: CString,
type, value, size: CARD32,
fe: FileEntry];
SETypeUNDF: CARD32 ~ 0h;
SETypeEXT: CARD32 ~ 1h;
SETypeABS: CARD32 ~ 2h;
SETypeTEXT: CARD32 ~ 4h;
SETypeDATA: CARD32 ~ 6h;
SETypeBSS: CARD32 ~ 8h;
SETypePATCH: CARD32 ~ 1ch;
SETypeMODULE: CARD32 ~ 1eh;
SETypeMask: CARD32 ~ 1eh;
PCR retains all external or text symbols.
All these symbols are accessible by name.
Only relocatable (not absolute) symbols are accessible by value.
LookupSymEntry: PROC [sym: CString, externOnly: BOOL] RETURNS [SymEntry];
Return SymEntry for (most recent instance of) sym.
Note sym may be undefined (in symbol table because it has been referenced but not yet defined).
Return NIL if no instance of sym exists in load state.
If externOnly is true, symbols that aren't extern are ignored.
LookupSymEntryByValue: PROC [val: CARD32] RETURNS [SymEntry];
Return SymEntry for most recently defined text, data or bss (but not absolute) symbol of maximum value not greater than val.
Note: symbol will not be undefined.
GetPrevSymEntry: PROC [se: SymEntry, externOnly: BOOL] RETURNS [SymEntry];
Return SymEntry for next most recent definition of symbol corresponding to se.
Return NIL if no more definitions.
If externOnly is true, symbols that aren't extern are ignored.
GetPrevSymEntryByValue: PROC [se: SymEntry] RETURNS [SymEntry];
GetNextSymEntryByValue: PROC [se: SymEntry] RETURNS [SymEntry];
Return SymEntry for prev or next symbol def by value.
Return NIL if no more definitions.
ContinueAction: TYPE ~ CString;
ActionContinue: ContinueAction ~ LOOPHOLE[0];
ActionDontBind: ContinueAction ~ LOOPHOLE[1];
SymIsInRecentLoad: PROC [se: SymEntry] RETURNS [Bool];
Return TRUE iff se is a symbol in the most recent load sequence (which may be in progress).
CProc: TYPE = RECORD [CARD32];
NilCProc: CProc ~ [0];
IncrementalLoadFile: PROC
[
fName: CString,
fOffset: Long ¬ 0,
fMagic: CARD32 ¬ 0,
refProc: CProc ¬ NilCProc,
refClientData: POINTER ¬ NIL,
defProc: CProc ¬ NilCProc,
defClientData: POINTER ¬ NIL,
commonProc: CProc ¬ NilCProc,
commonClientData: POINTER ¬ NIL,
patchSizeProc: CProc ¬ NilCProc,
patchSizeClientData: POINTER ¬ NIL
]
RETURNS [Error];
Load the specified module.
Resolve external symbols from current load state.
DO NOT CALL THIS PROC RECURSIVELY FROM undefinedProc OR redefinedProc!
Return NIL on success.
FileEntry for the file just loaded is GetPrevFileEntry[NIL].
RefProc: TYPE ~ PROC [sym: CString, seOld: SymEntry] RETURNS [ContinueAction];
Called for each sym that is undef external in file being loaded.
ilseOld != NIL if sym exists in load state.
DefProc: TYPE ~ PROC [seNew, seOld: SymEntry] RETURNS [ContinueAction];
Called for each symbol definition.
CommonProc: TYPE ~ PROC [sym: CString, size: CARD32, seOld: SymEntry] RETURNS [ContinueAction];
Called for each common reference from current file.
PathProc: TYPE ~ PROC [fe: FileEntry];
Called with fe before allocating space for the segments.
May look at segment sizes, and update patch area size if desired.
EnumerateUndefinedSymbols: PROC [func: CProc, clientData: POINTER];
Enumerate all undefined symbols.
(Note: all such symbols must have been introduced since last commit.)
UndefinedSymbolProc: TYPE ~ PROC [se: SymEntry] RETURNS [BOOL];
return TRUE iff enumeration should continue.
CommitIncrementalLoad: PROC RETURNS [Error];
AbortIncrementalLoad: PROC [se: SymEntry ¬ NIL] RETURNS [Error];
InitializeIncrementalLoader: PROC [fName: CString] RETURNS [Error];
Initialize loadstate symbol tables for PCR itself; fName specifies the PCR object file. fName may be NIL.
Return 0 on success, -XR←GetErrno() on failure.
CALL ONCE FROM FIRST THREAD AT BEGINNING OF WORLD.
END.