FreeBSD Manual Pages
AG_BYTESWAP(3) Library Functions Manual AG_BYTESWAP(3) NAME AG_ByteSwap -- agar byte swapping macros SYNOPSIS #include <agar/core/byteswap.h> DESCRIPTION These macros swap the order of bytes in integers and floating-point types. They are useful when reading or writing data of a specific en- dianness. Uint16 AG_Swap16(Uint16 value) Uint32 AG_Swap32(Uint32 value) Uint64 AG_Swap64(Uint64 value) Uint16 AG_SwapLE16(Uint16 value) Uint32 AG_SwapLE32(Uint32 value) Uint64 AG_SwapLE64(Uint64 value) Uint16 AG_SwapBE16(Uint16 value) Uint32 AG_SwapBE32(Uint32 value) Uint64 AG_SwapBE64(Uint64 value) The AG_Swap16(), AG_Swap32() and AG_Swap64() functions return the para- meter's value with the byte order reversed. AG_SwapLE16(), AG_SwapLE32(), and AG_SwapLE64() return the given value with the byte order reversed if the current architecture is big-endian. On little-endian machines, these functions return the value unchanged. AG_SwapBE16(), AG_SwapBE32() and AG_SwapBE64() return the given value with the byte order reversed if the current architecture is little-en- dian. On big-endian machines, these functions return the value un- changed. If 64-bit types are not supported (!AG_HAVE_64BIT), then AG_Swap64(), AG_SwapLE64() and AG_SwapBE64() are undefined. EXAMPLES The following code reverses the byte order of an array of 32-bit val- ues: void SwapData32(Uint32 *data, int len) { int i; for (i = 0; i < len; i++) data[i] = AG_Swap32(data[i]); } SEE ALSO AG_DataSource(3), AG_Intro(3) HISTORY The AG_ByteSwap macros first appeared in Agar 1.3.4. Agar 1.7 December 21, 2022 AG_BYTESWAP(3)
NAME | SYNOPSIS | DESCRIPTION | EXAMPLES | SEE ALSO | HISTORY
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=AG_ByteSwap&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>
