GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
AG_BYTESWAP(3) FreeBSD Library Functions Manual AG_BYTESWAP(3)

AG_ByteSwapagar byte swapping macros

#include <agar/core/byteswap.h>

These macros swap the order of bytes in integers and floating-point types. They are useful when reading or writing data of a specific endianness.


Uint16
(Uint16 value);


Uint32
(Uint32 value);


Uint64
(Uint64 value);


Uint16
(Uint16 value);


Uint32
(Uint32 value);


Uint64
(Uint64 value);


Uint16
(Uint16 value);


Uint32
(Uint32 value);


Uint64
(Uint64 value);

The (), AG_Swap32() and AG_Swap64() functions return the parameter's value with the byte order reversed.

(), 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_SwapBE32() and AG_SwapBE64() return the given value with the byte order reversed if the current architecture is little-endian. On big-endian machines, these functions return the value unchanged.

If 64-bit types are not supported (!AG_HAVE_64BIT), then (), AG_SwapLE64() and AG_SwapBE64() are undefined.

The following code reverses the byte order of an array of 32-bit values:

void
SwapData32(Uint32 *data, int len)
{
	int i;

	for (i = 0; i < len; i++)
		data[i] = AG_Swap32(data[i]);
}

AG_DataSource(3), AG_Intro(3)

The AG_ByteSwap macros first appeared in Agar 1.3.4.

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.