LupineRuntime.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
BZM on 11-May-82 16:17:07.
Birrell, September 12, 1983 2:02 pm
Swinehart, February 8, 1985 8:13:38 am PST
Bob Hagmann February 11, 1985 9:40:39 am PST
Russ Atkinson (RRA) February 20, 1985 7:16:49 pm PST
DIRECTORY
Basics USING [charsPerWord],
PrincOpsUtils USING [LongCopy],
RPC USING [Zones],
Rope USING [ ROPE ],
RPCLupine USING [DataLength, maxDataLength, --PktLength,-- RPCPkt, StubPkt];
NilHeader: TYPE = BOOL ← 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[]];
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:
PROC [long:
LONG
CARDINAL]
RETURNS [
CARDINAL] =
INLINE {
IF long <= LAST[CARDINAL] THEN RETURN[long] ELSE RETURN[UnmarshalingExprError[]];
};
Words: TYPE = --LONG-- CARDINAL ← NULL;
WordsForChars:
PROC [chars:
CARDINAL]
RETURNS [
--words:-- Words] =
INLINE {
RETURN[(chars+Basics.charsPerWord-1)/Basics.charsPerWord];
};
CheckPktLength:
PROC [ pkt: RpcPrivate.RPCPkt, lastPkt:
BOOL ←
TRUE, pktLength: RpcPrivate.DataLength ] =
INLINE {
IF RpcPrivate.PktLength[pkt: pkt] # [lastPkt: lastPkt, pktLength: pktLength]
THEN UnmarshalingError;
};
FinishThisPkt,
StartNextPkt:
PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength ]
RETURNS [zeroPktLength: RpcPrivate.DataLength];
CopyToPkt:
PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr:
LONG
POINTER, dataLength: Words, alwaysOnePkt:
BOOL ←
FALSE ]
RETURNS [
--newPktLength:-- RpcPrivate.DataLength] =
INLINE {
IF alwaysOnePkt
OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN {
PrincOpsUtils.LongCopy[to: @pkt.data[pktLength], from: dataAdr, nwords: dataLength];
RETURN[pktLength+dataLength];
}
ELSE RETURN[ CopyToMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
};
CopyFromPkt:
PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr:
LONG
POINTER, dataLength: Words, alwaysOnePkt:
BOOL ←
FALSE ]
RETURNS [
--newPktLength:-- RpcPrivate.DataLength] =
INLINE {
IF alwaysOnePkt
OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN {
PrincOpsUtils.LongCopy[to: dataAdr, from: @pkt.data[pktLength], nwords: dataLength];
RETURN[pktLength+dataLength];
}
ELSE RETURN[ CopyFromMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
};
CopyToMultiplePkts, CopyFromMultiplePkts: PRIVATE PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr: LONG POINTER, dataLength: Words ] RETURNS [--newPktLength:-- RpcPrivate.DataLength];
MarshalRope:
PROC [ rope: Rope.
ROPE, pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, assertShortRope:
BOOL]
RETURNS [newLength: RpcPrivate.DataLength];
UnmarshalRope:
PROC [pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, assertShortRope:
BOOL]
RETURNS [rope: Rope.
ROPE, newLength: RpcPrivate.DataLength];
MarshalAtom:
PROC [ atom:
ATOM, pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength]
RETURNS [newLength: RpcPrivate.DataLength];
UnmarshalAtom: PROC [pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength] RETURNS [atom: ATOM, newLength: RpcPrivate.DataLength];
}. -- LupineRuntime.