23 #ifndef _LV_ENDIANESS_H
24 #define _LV_ENDIANESS_H
26 #include <libvisual/lvconfig.h>
27 #include <libvisual/lv_defines.h>
35 #define VISUAL_ENDIAN_LE_BE_I16(w) (\
36 (((w) & 0xff00) >> 8) |\
37 (((w) & 0x00ff) << 8) )
39 #define VISUAL_ENDIAN_LE_BE_I32(w) (\
40 (((w) & 0x000000ff) << 24) | \
41 (((w) & 0x0000ff00) << 8) | \
42 (((w) & 0x00ff0000) >> 8) | \
43 (((w) & 0xff000000) >> 24) )
46 #if ! ((VISUAL_BIG_ENDIAN) | (VISUAL_LITTLE_ENDIAN))
47 # error determining system endianess. (none set)
50 #if ((VISUAL_BIG_ENDIAN == 1) & (VISUAL_LITTLE_ENDIAN == 1))
51 # error determing system endianess (both set?)
58 #if VISUAL_BIG_ENDIAN == 1
59 # define VISUAL_ENDIAN_BEI16(x) (x)
60 # define VISUAL_ENDIAN_BEI32(x) (x)
61 # define VISUAL_ENDIAN_LEI16(x) VISUAL_ENDIAN_LE_BE_I16(x)
62 # define VISUAL_ENDIAN_LEI32(x) VISUAL_ENDIAN_LE_BE_I32(x)
64 # define VISUAL_ENDIAN_LEI16(x) (x)
65 # define VISUAL_ENDIAN_LEI32(x) (x)
66 # define VISUAL_ENDIAN_BEI16(x) VISUAL_ENDIAN_LE_BE_I16(x)
67 # define VISUAL_ENDIAN_BEI32(x) VISUAL_ENDIAN_LE_BE_I32(x)
74 #define VISUAL_ALIGNED(x, y) (!(((intptr_t) x) & (y - 1)))