<> <> <> DIRECTORY Endian USING [bytesPerFWord, bytesPerHWord, FWORD, HWORD], IO USING [EndOfStream, STREAM, UnsafeGetBlock, UnsafePutBlock], IOExtras USING []; IOExtrasImpl: CEDAR PROGRAM IMPORTS IO EXPORTS IOExtras = { <> GetHWord: PUBLIC PROC [self: IO.STREAM] RETURNS [hword: Endian.HWORD] = TRUSTED { bytes: INT; bytes _ IO.UnsafeGetBlock[self, [LOOPHOLE[LONG[@hword]], 0, Endian.bytesPerHWord]]; IF bytes # Endian.bytesPerHWord THEN ERROR IO.EndOfStream[self]; }; PutHWord: PUBLIC PROC [self: IO.STREAM, hword: Endian.HWORD] = TRUSTED { IO.UnsafePutBlock[self, [LOOPHOLE[LONG[@hword]], 0, Endian.bytesPerHWord]]; }; GetFWord: PUBLIC PROC [self: IO.STREAM] RETURNS [fword: Endian.FWORD] = TRUSTED { bytes: INT; bytes _ IO.UnsafeGetBlock[self, [LOOPHOLE[LONG[@fword]], 0, Endian.bytesPerFWord]]; IF bytes # Endian.bytesPerHWord THEN IO.EndOfStream[self]; }; PutFWord: PUBLIC PROC [self: IO.STREAM, fword: Endian.FWORD] = TRUSTED { IO.UnsafePutBlock[self, [LOOPHOLE[LONG[@fword]], 0, Endian.bytesPerFWord]]; }; }.