20 #ifdef HAVE_INTTYPES_H
23 #include <sys/types.h>
24 #define uint8_t u_int8_t
25 #define uint16_t u_int16_t
26 #define uint32_t u_int32_t
27 #define uint64_t u_int64_t
41 #ifdef WORDS_BIGENDIAN
49 val = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
61 val = ptr[0] | (ptr[1] << 8);
66 #define LW_LE(x) (lw_le((x)))
68 #define LH_LE(x) (lh_le((x)))
80 val = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
92 val = (ptr[0] << 16) | ptr[1];
98 #define LW_BE(x) (lw_be((x)))
100 #define LH_BE(x) (lh_be((x)))
104 #define LW(x) (LW_LE(x))
105 #define LH(x) (LH_LE(x))
108 #ifdef WORDS_BIGENDIAN
109 inline void sw_le(
u32 *data,
u32 val)
111 u8* ptr = (
u8*) data;
113 ptr[0] = (
u8) (val & 0xFF);
114 ptr[1] = (
u8) ((val >> 8) & 0xFF);
115 ptr[2] = (
u8) ((val >> 16) & 0xFF);
116 ptr[3] = (
u8) ((val >> 24) & 0xFF);
119 inline void sh_le(
u16 *data,
u16 val)
121 u8 *ptr = (
u8*) data;
123 ptr[0] = (
u8) (val & 0xFF);
124 ptr[1] = (
u8) ((val >> 8) & 0xFF);
127 #define SW_LE(x, v) (sw_le((x), (v)))
128 #define SW_BE(x, v) (*(x) = (v))
129 #define SH_LE(x, v) (sh_le((x), (v)))
130 #define SH_BE(x, v) (*(x) = (v))
136 u8 *ptr = (
u8*) data;
138 ptr[0] = (
u8) ((val >> 24) & 0xFF);
139 ptr[1] = (
u8) ((val >> 16) & 0xFF);
140 ptr[2] = (
u8) ((val >> 8) & 0xFF);
141 ptr[3] = (
u8) (val & 0xFF);
146 u8* ptr = (
u8*) data;
148 ptr[0] = (
u8) ((val >> 8) & 0xFF);
149 ptr[1] = (
u8) (val & 0xFF);
152 #define SW_LE(x, v) (*(x) = (v))
153 #define SW_BE(x, v) (sw_be((x), (v)))
154 #define SH_LE(x, v) (*(x) = (v))
155 #define SH_BE(x, v) (sh_be((x), (v)))
159 #define SW(x, v) (SW_LE(x, v))
160 #define SH(x, v) (SH_LE(x, v))