helpers.h

Go to the documentation of this file.
00001 #ifndef HELPERS_H_
00002 #define HELPERS_H_
00003 
00004 #include <inttypes.h>
00005 
00006 #if defined(__APPLE_CC__)
00007 #define IS_BIG_ENDIAN
00008 #endif
00009 
00010 #if defined WORDS_BIGENDIAN || defined IS_BIG_ENDIAN
00011 // We must ensure that the entity is unsigned
00012 // otherwise, if it is signed/negative, the MSB will be
00013 // propagated when we shift
00014 #define LITTLE_TO_NATIVE16(x) (((((uint16_t) x) & 0xFF) << 8) | \
00015                                (((uint16_t) x) >> 8))
00016 #define LITTLE_TO_NATIVE32(x) (((((uint32_t) x) & 0xFF) << 24) | \
00017                                (((((uint32_t) x) >> 8) & 0xFF) << 16) | \
00018                                (((((uint32_t) x) >> 16) & 0xFF) << 8) | \
00019                                (((uint32_t) x) >> 24))
00020 #else
00021 #define LITTLE_TO_NATIVE16(x) x
00022 #define LITTLE_TO_NATIVE32(x) x
00023 #endif
00024 
00025 
00026 
00027 #endif

Generated on Mon Dec 19 00:13:20 2005 for Visualization by  doxygen 1.4.5