DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

UDI_ENDIAN_SWAP_16, UDI_ENDIAN_SWAP_32


Byte-swap 16 or 32-bit integers

SYNOPSIS

#include <udi.h>
#define UDI_ENDIAN_SWAP_16(data16) \

		( (((data16) & 0x00ff) << 8) | \

		  (((data16) >> 8) & 0x00ff) )
 
#define UDI_ENDIAN_SWAP_32(data32) \

		( (((data32) & 0x000000ff) << 24) | \

		  (((data32) & 0x0000ff00) << 8)  | \

		  (((data32) >> 8) & 0x0000ff00)  | \

		  (((data32) >> 24) & 0x000000ff) )
 

ARGUMENTS data16 is a 16-bit data value.

data32 is a 32-bit data value.

DESCRIPTION UDI_ENDIAN_SWAP_16 byte-swaps a single 16-bit data value; UDI_ENDIAN_SWAP_32 byte-swaps a single 32-bit data value. These two macros provide basic endian translation of an individual data item. See udi_endian_swap for information on an endian utility that provides for larger than 32-bit endian translation and that allows for multiple byte-swaps in a single call.

These macros must be called as if they, respectively, had the following functional interface:

udi_ubit16_t UDI_ENDIAN_SWAP_16 (

	udi_ubit16_t data16 );
 
udi_ubit32_t UDI_ENDIAN_SWAP_32 (

	udi_ubit32_t data32 );
 

REFERENCES udi_endian_swap


UDI Core Specification Contents