00001 #ifndef __LIB_ENDIAN_H
00002
00003 #define __LIB_ENDIAN_H
00004
00005
00006 #define endian_swap32(x) ((((x) & 0xff000000) >> 24) | \
00007 (((x) & 0x00ff0000) >> 8) | \
00008 (((x) & 0x0000ff00) << 8) | \
00009 (((x) & 0x000000ff) << 24))
00010 #define endian_swap16(x) ((((x) & 0xff00)>> 8) | (((x) & 0x00ff) << 8))
00011 #define endian_swap24(x) (((x) >> 16) & 0xff) | (((x) & 0xff) << 16) | ((x) & 0xff00)
00012
00013 #define be32_to_machine(x) endian_swap32(x)
00014 #define be16_to_machine(x) endian_swap16(x)
00015 #define be24_to_machine(x) endian_swap24(x)
00016 #define machine_to_be32(x) endian_swap32(x)
00017 #define machine_to_be16(x) endian_swap16(x)
00018 #define machine_to_be24(x) endian_swap24(x)
00019
00020 #endif