ENDIAN(3C) Standard C Library Functions ENDIAN(3C)
NAME
endian,
be16toh,
be32toh,
be64toh,
betoh16,
betoh32,
betoh64,
htobe16,
htobe32,
htobe64,
htole16,
htole32,
htole64,
le16toh,
le32toh,
le64toh,
letoh16,
letoh32,
letoh64 - convert between big and little endian byte
order
SYNOPSIS
#include <endian.h> uint16_t be16toh(
uint16_t be16);
uint32_t be32toh(
uint32_t be32);
uint64_t betoh64(
uint64_t be64);
uint16_t betoh16(
uint16_t be16);
uint32_t betoh32(
uint32_t be32);
uint64_t be64toh(
uint64_t be64);
uint16_t htobe16(
uint16_t host16);
uint32_t htobe32(
uint32_t host32);
uint64_t htobe64(
uint64_t host64);
uint16_t htole16(
uint16_t host16);
uint32_t htole32(
uint32_t host32);
uint64_t htole64(
uint64_t host64);
uint16_t le16toh(
uint16_t le16);
uint32_t le32toh(
uint32_t le32);
uint64_t le64toh(
uint64_t le64);
uint16_t letoh16(
uint16_t le16);
uint32_t letoh32(
uint32_t le32);
uint64_t letoh64(
uint64_t le64);
DESCRIPTION
The
endian family of functions convert 16, 32, and 64-bit values
between the host's native byte order and big- or little-endian. All of
the functions in this family simply return their input when the host's
native byte order is the same as the desired order. For more
information on endianness, see
byteorder(7).
The
betoh16(),
betoh32(), and
betoh64() functions take a 16-bit,
32-bit, or 64-bit value and convert it from big-endian to the host's
native endianness, swapping bytes as required.
The
letoh16(),
letoh32(), and
letoh64() functions take a 16-bit,
32-bit, or 64-bit value and convert it from little-endian to the host's
native endianness, swapping bytes as required.
The
htobe16(),
htobe32(), and
htobe64() functions take a 16-bit,
32-bit, or 64-bit value and convert it from the host's native
endianness to big-endian, swapping bytes as required.
The
htole16(),
htole32(), and
htole64() functions take a 16-bit,
32-bit, or 64-bit value and convert it from the host's native
endianness to little-endian, swapping bytes as required.
The functions
be16toh(),
be32toh(),
be64toh(),
le16toh(),
le32toh(),
and
le64toh(), are the same as
betoh16(),
betoh32(),
betoh64(),
letoh16(),
letoh32(), and
letoh64() respectively. Historically,
different platforms have diverged on the naming of these functions. To
better support extant software, both are provided.
While these functions are common across multiple platforms, they have
not been standardized. Portable applications should instead use the
functions defined in
byteorder(3C).
RETURN VALUES
The functions always succeed and return a value that has been properly
converted.
INTERFACE STABILITY
CommittedMT-LEVEL MT-SafeSEE ALSO
byteorder(3C),
endian.h(3HEAD),
attributes(7),
byteorder(7)illumos August 2, 2018 illumos