bswap16(9) bswap64

SYNOPSIS

In sys/endian.h Ft uint16_t Fn bswap16 uint16_t int16 Ft uint32_t Fn bswap32 uint32_t int32 Ft uint64_t Fn bswap64 uint64_t int64 Ft uint16_t Fn be16toh uint16_t big16 Ft uint32_t Fn be32toh uint32_t big32 Ft uint64_t Fn be64toh uint64_t big64 Ft uint16_t Fn htobe16 uint16_t host16 Ft uint32_t Fn htobe32 uint32_t host32 Ft uint64_t Fn htobe64 uint64_t host64 Ft uint16_t Fn htole16 uint16_t host16 Ft uint32_t Fn htole32 uint32_t host32 Ft uint64_t Fn htole64 uint64_t host64 Ft uint16_t Fn le16toh uint16_t little16 Ft uint32_t Fn le32toh uint32_t little32 Ft uint64_t Fn le64toh uint64_t little64 Ft uint16_t Fn be16dec const void * Ft uint32_t Fn be32dec const void * Ft uint64_t Fn be64dec const void * Ft uint16_t Fn le16dec const void * Ft uint32_t Fn le32dec const void * Ft uint64_t Fn le64dec const void * Ft void Fn be16enc void * uint16_t Ft void Fn be32enc void * uint32_t Ft void Fn be64enc void * uint64_t Ft void Fn le16enc void * uint16_t Ft void Fn le32enc void * uint32_t Ft void Fn le64enc void * uint64_t

DESCRIPTION

The Fn bswap16 , Fn bswap32 , and Fn 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 Fn be16toh , Fn be32toh , and Fn 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 Fn le16toh , Fn le32toh , and Fn 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 Fn htobe16 , Fn htobe32 , and Fn 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 Fn htole16 , Fn htole32 , and Fn 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 Fn be16enc , Fn be16dec , Fn be32enc , Fn be32dec , Fn be64enc , Fn be64dec , Fn le16enc , Fn le16dec , Fn le32enc , Fn le32dec , Fn le64enc , and Fn le64dec functions encode and decode integers to/from byte strings on any alignment in big/little endian format.

HISTORY

The Fn hto* and Fn *toh functions first appeared in Fx 5.0 , and were originally developed by the Nx project.

The encode/decode functions first appeared in Fx 5.1 .