6 struct unaligned_64 { uint64_t l; } __attribute__((packed));
7 struct unaligned_32 { uint32_t l; } __attribute__((packed));
8 struct unaligned_16 { uint16_t l; } __attribute__((packed));
10 #define LD16(a) (((const struct unaligned_16 *) (a))->l)
11 #define LD32(a) (((const struct unaligned_32 *) (a))->l)
12 #define LD64(a) (((const struct unaligned_64 *) (a))->l)
14 #define ST16(a, b) (((struct unaligned_16 *) (a))->l) = (b)
15 #define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
19 #define LD16(a) (*((uint16_t*)(a)))
20 #define LD32(a) (*((uint32_t*)(a)))
21 #define LD64(a) (*((uint64_t*)(a)))
23 #define ST16(a, b) *((uint16_t*)(a)) = (b)
24 #define ST32(a, b) *((uint32_t*)(a)) = (b)
26 #endif /* !__GNUC__ */
29 #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
30 #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
31 #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
32 (((uint8_t*)(x))[1] << 16) | \
33 (((uint8_t*)(x))[2] << 8) | \
35 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
36 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
37 (((uint8_t*)(x))[2] << 16) | \
38 (((uint8_t*)(x))[1] << 8) | \
42 #endif /* INTREADWRITE_H */