Endian.h

Go to the documentation of this file.
00001 #ifndef __ENDIAN_H__
00002 #define __ENDIAN_H__
00003 
00004 /*
00005 
00006 $Header$
00007 
00008 */
00009 
00010 #include <endian.h>
00011 
00012 #if __BYTE_ORDER==__LITTLE_ENDIAN
00013 
00014 #define SWAP16_IF_LE(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
00015 #define SWAP16_IF_BE(s) (s)
00016 
00017 #define SWAP32_IF_LE(l) \
00018     ((((l) & 0xff000000) >> 24) | \
00019     (((l) & 0x00ff0000) >> 8)  | \
00020     (((l) & 0x0000ff00) << 8)  | \
00021     (((l) & 0x000000ff) << 24))
00022 #define SWAP32_IF_BE(l) (l)
00023 
00024 #else
00025 
00026 #define SWAP16_IF_LE(s) (s)
00027 #define SWAP16_IF_BE(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
00028 
00029 #define SWAP32_IF_LE(l) (l)
00030 #define SWAP32_IF_BE(l) \
00031     ((((l) & 0xff000000) >> 24) | \
00032     (((l) & 0x00ff0000) >> 8)  | \
00033     (((l) & 0x0000ff00) << 8)  | \
00034     (((l) & 0x000000ff) << 24))
00035 
00036 #endif
00037 
00038 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1