XlEndianPrivate-Big32.mesa
Copyright Ó 1989..1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, February 1, 1989 2:52:14 pm PST
Christian Jacobi, February 12, 1992 6:56 pm PST
DIRECTORY Xl, Basics, IO;
XlEndianPrivate--Big32--: CEDAR DEFINITIONS
IMPORTS IO
SHARES Xl ~
BEGIN OPEN Xl;
Endian specific private types for Xl
Endian: TYPE = {lsbFirst, msbFirst};
Types consider byte order of host [here big endian]
FourBytes: TYPE = MACHINE DEPENDENT RECORD [
hh, hl, lh, ll: BYTE
];
--byte order of host
TwoBytes: TYPE = MACHINE DEPENDENT RECORD [
hi, lo: BYTE
];
--byte order of host
Procs consider byte order used for X protocol [here big endian]
communicationByteOrder: Endian = msbFirst;
bitmapBitInByteOrder: Endian = msbFirst;
hhOff:  INT = 0;
hlOff:  INT = 1;
lHOff:  INT = 2;
llOff:  INT = 3;
highOff:  INT = 0;
lowOff:  INT = 1;
Byte0: PROC [n: CARD32] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, FourBytes].hh] };
Byte1: PROC [n: CARD32] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, FourBytes].hl] };
Byte2: PROC [n: CARD32] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, FourBytes].lh] };
Byte3: PROC [n: CARD32] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, FourBytes].ll] };
Byte0Of16: PROC [n: CARD16] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, TwoBytes].hi] };
Byte1Of16: PROC [n: CARD16] RETURNS [BYTE]
= INLINE { RETURN[LOOPHOLE[n, TwoBytes].lo] };
InlineGet8: PROC [c: Connection] RETURNS [BYTE] ~ INLINE {
byte: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
RETURN [byte]
};
InlineGet16: PROC [c: Connection] RETURNS [CARD16] ~ INLINE {
byte0: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
byte1: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
RETURN [byte0*256 + byte1]
};
InlineGet32: PROC [c: Connection] RETURNS [CARD32] ~ INLINE {
byte0: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
byte1: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
byte2: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
byte3: BYTE ~ ORD[IO.InlineGetChar[c.recv]];
ln: FourBytes ~ [hh: byte0, hl: byte1, lh: byte2, ll: byte3];
RETURN [LOOPHOLE[ln]]
};
InlineRawGet8: UNSAFE PROC [b: POINTER TO Basics.RawBytes, startPos: INT] RETURNS [BYTE] = TRUSTED INLINE {
RETURN [b[startPos]]
};
InlineRawGet16: UNSAFE PROC [b: POINTER TO Basics.RawBytes, startPos: INT] RETURNS [CARD16] = TRUSTED INLINE {
byte0: BYTE ~ b[startPos];
byte1: BYTE ~ b[startPos+1];
RETURN [byte0*256 + byte1]
};
InlineRawGet32: UNSAFE PROC [b: POINTER TO Basics.RawBytes, startPos: INT] RETURNS [CARD32] = TRUSTED INLINE {
ln: FourBytes ~ [hh: b[startPos], hl: b[startPos+1], lh: b[startPos+2], ll: b[startPos+3]];
RETURN [LOOPHOLE[ln]]
};
InlineTextGet8: PROC [text: REF TEXT, startPos: INT] RETURNS [BYTE] = INLINE {
RETURN [ORD[text[startPos]]]
};
InlineTextGet16: PROC [text: REF TEXT, startPos: INT] RETURNS [CARD16] = INLINE {
byte0: BYTE ~ ORD[text[startPos]];
byte1: BYTE ~ ORD[text[startPos+1]];
RETURN [byte0*256 + byte1]
};
InlineTextGet32: PROC [text: REF TEXT, startPos: INT] RETURNS [CARD32] = INLINE {
ln: FourBytes ~ [hh: ORD[text[startPos]], hl: ORD[text[startPos+1]], lh: ORD[text[startPos+2]], ll: ORD[text[startPos+3]]];
RETURN [LOOPHOLE[ln]]
};
InlineExtensionGet8: PROC [e: ExtensionEvent, startPos: INT] RETURNS [BYTE] = INLINE {
RETURN [e.bytes[startPos]]
};
InlineExtensionGet16: PROC [e: ExtensionEvent, startPos: INT] RETURNS [CARD16] = INLINE {
RETURN [e.bytes[startPos]*256 + e.bytes[startPos+1]]
};
InlineExtensionGet32: PROC [e: ExtensionEvent, startPos: INT] RETURNS [CARD32] = INLINE {
ln: FourBytes ~ [hh: e.bytes[startPos], hl: e.bytes[startPos+1], lh: e.bytes[startPos+2], ll: e.bytes[startPos+3]];
RETURN [LOOPHOLE[ln]]
};
InlinePut8: PROC [c: Connection, val: BYTE] ~ INLINE {
IO.InlinePutChar[c.xmit, VAL[val]];
c.bufSkipped ¬ c.bufSkipped+1
};
InlinePut16: PROC [c: Connection, val: CARD16] ~ INLINE {
IO.InlinePutChar[c.xmit, VAL[Byte0Of16[val]]];
IO.InlinePutChar[c.xmit, VAL[Byte1Of16[val]]];
c.bufSkipped ¬ c.bufSkipped+2
};
InlinePut32: PROC [c: Connection, val: CARD32] ~ INLINE {
l: FourBytes ~ LOOPHOLE[val];
IO.InlinePutChar[c.xmit, VAL[l.hh]];
IO.InlinePutChar[c.xmit, VAL[l.hl]];
IO.InlinePutChar[c.xmit, VAL[l.lh]];
IO.InlinePutChar[c.xmit, VAL[l.ll]];
c.bufSkipped ¬ c.bufSkipped+4
};
END.