Alien endian-aware types


The alien.endian vocabulary defines c-types that are endian-aware for use in structs. These types will cause the bytes in a byte-array to be interpreted as little or big-endian transparently when reading or writing. There are both signed and unsigned types defined; signed is the default while unsigned are prefixed with a u. The intended use-case is for network protocols in network-byte-order (big-endian).

Byte-reversal of integers:
byte-reverse ( n signed? -- quot )


The big-endian c-types are:
be8

be16

be32

be64

ube8

ube16

ube32

ube64


The little-endian c-types are:
le8

le16

le32

le64

ule8

ule16

ule32

ule64


Syntax for making endian-aware structs out of native types:
LE-STRUCT:

BE-STRUCT:

LE-PACKED-STRUCT:

BE-PACKED-STRUCT: