File [Ivy]<Nelson>Lupine>LupineRuntime.mesa.
Last edited by BZM on 11-May-82 16:17:07.
Last Edited by: Birrell, September 12, 1983 2:02 pm
This interface is used at runtime for marshaling and other common functions.
DIRECTORY
Basics USING [charsPerWord],
PrincOpsUtils USING [LongCOPY],
RPC USING [Zones],
RPCLupine USING [DataLength, maxDataLength, --PktLength,-- RPCPkt, StubPkt];
LupineRuntime:
DEFINITIONS
IMPORTS PrincOpsUtils =
BEGIN OPEN RpcPrivate: RPCLupine;
Lupine's no-nonsense errors.
TranslationError: ERROR;
BindingError: ERROR;
RuntimeError: ERROR;
These procedures map into ERRORs (for now).
MarshalingError: PROCEDURE;
MarshalingExprError: PROCEDURE RETURNS [never: UNSPECIFIED];
These procedures map into RpcRuntime ERRORs.
UnmarshalingError: PROCEDURE;
UnmarshalingExprError: PROCEDURE RETURNS [never: UNSPECIFIED];
DispatchingError: PROCEDURE RETURNS [never: UNSPECIFIED];
Default parameter storage zones.
Parameter protocol headers.
NilHeader: TYPE = BOOLEAN ← NULL;
RopeHeader: TYPE = CARDINAL ← NULL;
ListHeader, SequenceHeader: TYPE = LONG CARDINAL ← NULL;
StringHeader:
TYPE =
MACHINE
DEPENDENT
RECORD [
header (0):
SELECT
OVERLAID *
FROM
Lengths => [maxLength (0), length (1): CARDINAL←NULL],
All => [all (0): LONG CARDINAL],
ENDCASE] ← [Lengths[]];
Parameter marshaling routines.
DoubleWord: TYPE = LONG CARDINAL; -- LONG UNSPECIFIED doesn't work well
StubPktDoubleWord:
PROC [pkt: RpcPrivate.StubPkt, index: RpcPrivate.DataLength]
RETURNS [--ptrToDoubleWord:-- POINTER TO DoubleWord] =
INLINE {RETURN[LOOPHOLE[@pkt.data[index]]]};
RpcPktDoubleWord:
PROC [pkt: RpcPrivate.RPCPkt, index: RpcPrivate.DataLength]
RETURNS [--ptrToDoubleWord:-- LONG POINTER TO DoubleWord] =
INLINE {RETURN[LOOPHOLE[@pkt.data[index]]]};
SHORT:
PROCEDURE [long:
LONG
CARDINAL]
RETURNS [
CARDINAL] =
INLINE BEGIN
IF long <= LAST[CARDINAL] THEN RETURN[long] ELSE RETURN[UnmarshalingExprError[]];
END;
Words: TYPE = --LONG-- CARDINAL ← NULL;
WordsForChars:
PROCEDURE [chars:
CARDINAL]
RETURNS [
--words:-- Words] =
INLINE BEGIN
RETURN[(chars+Basics.charsPerWord-1)/Basics.charsPerWord];
END;
CheckPktLength:
PROCEDURE [
pkt: RpcPrivate.RPCPkt,
lastPkt: BOOLEAN ← TRUE,
pktLength: RpcPrivate.DataLength ] =
INLINE BEGIN
IF RpcPrivate.PktLength[pkt: pkt] # [lastPkt: lastPkt, pktLength: pktLength]
THEN UnmarshalingError;
END;
FinishThisPkt,
StartNextPkt:
PROCEDURE [
pkt: RpcPrivate.RPCPkt,
pktLength: RpcPrivate.DataLength ]
RETURNS [zeroPktLength: RpcPrivate.DataLength];
CopyToPkt:
PROCEDURE [
pkt: RpcPrivate.RPCPkt,
pktLength: RpcPrivate.DataLength,
dataAdr: LONG POINTER,
dataLength: Words,
alwaysOnePkt: BOOLEAN←FALSE ]
RETURNS [--newPktLength:-- RpcPrivate.DataLength] =
INLINE BEGIN
IF alwaysOnePkt
OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN
BEGIN
PrincOpsUtils.LongCOPY[to: @pkt.data[pktLength], from: dataAdr, nwords: dataLength];
RETURN[pktLength+dataLength];
END
ELSE RETURN[ CopyToMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
END;
CopyFromPkt:
PROCEDURE [
pkt: RpcPrivate.RPCPkt,
pktLength: RpcPrivate.DataLength,
dataAdr: LONG POINTER,
dataLength: Words,
alwaysOnePkt: BOOLEAN←FALSE ]
RETURNS [--newPktLength:-- RpcPrivate.DataLength] =
INLINE BEGIN
IF alwaysOnePkt
OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN
BEGIN
PrincOpsUtils.LongCOPY[to: dataAdr, from: @pkt.data[pktLength], nwords: dataLength];
RETURN[pktLength+dataLength];
END
ELSE RETURN[ CopyFromMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
END;
CopyToMultiplePkts,
CopyFromMultiplePkts:
PRIVATE
PROCEDURE [
pkt: RpcPrivate.RPCPkt,
pktLength: RpcPrivate.DataLength,
dataAdr: LONG POINTER,
dataLength: Words ]
RETURNS [--newPktLength:-- RpcPrivate.DataLength];
END. -- LupineRuntime.