HALFRED  0.4.0
Macros
Endianess conversion routines

Detailed Description

The following macros are used to convert from CPU number format to a little/big endian.

Macros

#define CPU2BE16(x)   ( (((x)>>8) & 0x00ff) | (((x)<<8) & 0xff00) )
 
#define BE2CPU16(x)   CPU2BE16(x)
 
#define CPU2BE32(x)   ( (((x)>>24)&0x000000ff) | (((x)>>8)&0x0000ff00) | (((x)<<8)&0x00ff0000) | (((x)<<24)&0xff000000) )
 
#define BE2CPU32(x)   CPU2BE32(x)
 
#define CPU2BE64(x)   (CPU2BE32(((x) >> 32) & 0xffffffff) | (CPU2BE32((x) & 0xffffffff) << 32))
 
#define BE2CPU64(x)   CPU2BE64(x)
 
#define CPU2LE16(x)   (x)
 
#define LE2CPU16(x)   (x)
 
#define CPU2LE32(x)   (x)
 
#define LE2CPU32(x)   (x)
 
#define CPU2LE64(x)   (x)
 
#define LE2CPU64(x)   (x)
 

Macro Definition Documentation

#define CPU2BE16 (   x)    ( (((x)>>8) & 0x00ff) | (((x)<<8) & 0xff00) )

Converts a 16-bit integer to a big endian format.

#define BE2CPU16 (   x)    CPU2BE16(x)

Converts a 16-bit big endian value to a CPU format.

#define CPU2BE32 (   x)    ( (((x)>>24)&0x000000ff) | (((x)>>8)&0x0000ff00) | (((x)<<8)&0x00ff0000) | (((x)<<24)&0xff000000) )

Converts a 32-bit integer to a big endian format

#define BE2CPU32 (   x)    CPU2BE32(x)

Converts a 32-bit big endian value to a CPU format.

#define CPU2BE64 (   x)    (CPU2BE32(((x) >> 32) & 0xffffffff) | (CPU2BE32((x) & 0xffffffff) << 32))

Converts a 64-bit integer to a big endian format

#define BE2CPU64 (   x)    CPU2BE64(x)

Converts a 64-bit big endian value to a CPU format.

#define CPU2LE16 (   x)    (x)

Converts a 16-bit integer to a little endian format.

#define LE2CPU16 (   x)    (x)

Converts a 16-bit little endian value to a CPU format.

#define CPU2LE32 (   x)    (x)

Converts a 32-bit integer to a little endian format

#define LE2CPU32 (   x)    (x)

Converts a 32-bit little endian value to a CPU format.

#define CPU2LE64 (   x)    (x)

Converts a 64-bit integer to a little endian format

#define LE2CPU64 (   x)    (x)

Converts a 64-bit little endian value to a CPU format.