carta
le16toh(9)

le16toh9

Byte order operations

Part of be16dec(9).

Usage

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

uint16_t

uint32_t

uint64_t

void

void

void

void

void

void

Overview

The bswap16(), bswap32(), and bswap64() functions return a byte order swapped integer. On big endian systems, the number is converted to little endian byte order. On little endian systems, the number is converted to big endian byte order.

The be16toh(), be32toh(), and be64toh() functions return a big endian byte ordered integer converted to the system's native byte order. The return value will be the same as the argument on big endian systems.

The le16toh(), le32toh(), and le64toh() functions return a little endian byte ordered integer converted to the system's native byte order. The return value will be the same as the argument on little endian systems.

The htobe16(), htobe32(), and htobe64() functions return an integer in the system's native byte order converted to big endian byte order. The return value will be the same as the argument on big endian systems.

The htole16(), htole32(), and htole64() functions return a integer in the system's native byte order converted to little endian byte order. The return value will be the same as the argument on little endian systems.

The be16enc(), be16dec(), be32enc(), be32dec(), be64enc(), be64dec(), le16enc(), le16dec(), le32enc(), le32dec(), le64enc(), and le64dec() functions encode and decode integers to/from byte strings on any alignment in big/little endian format.

History

  • FreeBSD 16.0-CURRENT (2026-10-27) to FreeBSD 13.3-RELEASE: the text shown here
  • FreeBSD 13.2-RELEASE to FreeBSD 13.0-RELEASE
  • FreeBSD 12.4-RELEASE
  • FreeBSD 12.3-RELEASE
  • FreeBSD 12.2-RELEASE
  • FreeBSD 12.1-RELEASE
  • FreeBSD 12.0-RELEASE
  • FreeBSD 11.4-RELEASE
  • FreeBSD 11.3-RELEASE
  • FreeBSD 11.2-RELEASE
  • FreeBSD 11.1-RELEASE
  • FreeBSD 11.0-RELEASE
  • FreeBSD 10.4-RELEASE
  • FreeBSD 10.3-RELEASE
  • FreeBSD 10.2-RELEASE
  • FreeBSD 10.1-RELEASE
  • FreeBSD 10.0-RELEASE
  • FreeBSD 9.3-RELEASE
  • FreeBSD 9.2-RELEASE
  • FreeBSD 9.1-RELEASE
  • FreeBSD 9.0-RELEASE
  • FreeBSD 8.4-RELEASE
  • FreeBSD 8.3-RELEASE
  • FreeBSD 8.2-RELEASE
  • FreeBSD 8.1-RELEASE
  • FreeBSD 8.0-RELEASE
  • FreeBSD 7.4-RELEASE
  • FreeBSD 7.3-RELEASE
  • FreeBSD 7.2-RELEASE
  • FreeBSD 7.1-RELEASE
  • FreeBSD 7.0-RELEASE
  • FreeBSD 6.4-RELEASE
  • FreeBSD 6.3-RELEASE to FreeBSD 5.1-RELEASE
  • FreeBSD 5.0-RELEASE

History

The hto*() and *toh() functions first appeared in FreeBSD 5.0, and were originally developed by the NetBSD project.

The encode/decode functions first appeared in FreeBSD 5.1.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.