14.3 Endian Interface

ORIGIN '~beta/basiclib/betaenv';
LIB_DEF 'sysutilsendian' '../lib';
(* Operations for testing whether or not the host system uses
 * big endian or little endian data representation.
 * In addition there are operations for converting a long (4bytes)
 * and a short (2 bytes) memory location from big/little to
 * little/big endian.
 *)
MDBODY linux   'private/endian_littleBody'
       nti     'private/endian_littleBody'
       x86sol  'private/endian_littleBody'
       default 'private/endian_bigBody';

---lib:attributes---

(* Predicates indicating the endian-type of the host system. *)

isBigEndian:
  (# b: @boolean
    ...
  exit b
  #);
isLittleEndian:
  (# b: @boolean
    ...
  exit b
  #);

(* BSD like conversion routines. These operations are safe. *)

ntohl:
  (# i: @Integer;
  enter i
  ...
  exit i
  #);
htonl:
  (# i: @Integer;
  enter i
  ...
  exit i
  #);

ntohs:
  (# i: @Integer;
  enter i
  ...
  exit i
  #);
htons:
  (# i: @Integer;
  enter i
  ...
  exit i
  #)


14.3 Endian Interface
© 1994-2004 Mjølner Informatics
[Modified: Tuesday June 11th 2002 at 15:51]