15 (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
16 (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
23 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
24 (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
25 (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
26 (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
33 (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
34 (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
35 (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
36 (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \
37 (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \
38 (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
39 (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
40 (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \
45 #undef WORDS_BIGENDIAN
46 #if __BYTE_ORDER == __BIG_ENDIAN
47 #define WORDS_BIGENDIAN
50 #ifdef WORDS_BIGENDIAN
54 /* XXX: auto autoconf */
56 #define TARGET_LONG_BITS 32
59 #if defined(__alpha__)
60 #define HOST_LONG_BITS 64
62 #define HOST_LONG_BITS 32
65 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
66 #define HOST_LONG_SIZE (TARGET_LONG_BITS / 8)
68 static inline uint16_t bswap16(uint16_t x)
73 static inline uint32_t bswap32(uint32_t x)
78 static inline uint64_t bswap64(uint64_t x)
83 static void inline bswap16s(uint16_t *s)
88 static void inline bswap32s(uint32_t *s)
93 static void inline bswap64s(uint64_t *s)
100 static inline uint16_t tswap16(uint16_t s)
105 static inline uint32_t tswap32(uint32_t s)
110 static inline uint64_t tswap64(uint64_t s)
115 static void inline tswap16s(uint16_t *s)
120 static void inline tswap32s(uint32_t *s)
125 static void inline tswap64s(uint64_t *s)
132 static inline uint16_t tswap16(uint16_t s)
137 static inline uint32_t tswap32(uint32_t s)
142 static inline uint64_t tswap64(uint64_t s)
147 static void inline tswap16s(uint16_t *s)
151 static void inline tswap32s(uint32_t *s)
155 static void inline tswap64s(uint64_t *s)
161 #if TARGET_LONG_SIZE == 4
162 #define tswapl(s) tswap32(s)
163 #define tswapls(s) tswap32s((uint32_t *)(s))
165 #define tswapl(s) tswap64(s)
166 #define tswapls(s) tswap64s((uint64_t *)(s))
169 #if TARGET_LONG_SIZE == 4
170 typedef int32_t target_long;
171 typedef uint32_t target_ulong;
172 #elif TARGET_LONG_SIZE == 8
173 typedef int64_t target_long;
174 typedef uint64_t target_ulong;
176 #error TARGET_LONG_SIZE undefined
179 /* types enums definitions */
181 typedef enum argtype {
188 TYPE_PTRVOID, /* pointer on unknown data */
196 #define MK_PTR(type) TYPE_PTR, type
197 #define MK_ARRAY(type, size) TYPE_ARRAY, size, type
198 #define MK_STRUCT(id) TYPE_STRUCT, id
200 #define THUNK_TARGET 0
204 /* standard struct handling */
205 const argtype *field_types;
207 int *field_offsets[2];
208 /* special handling */
209 void (*convert[2])(void *dst, const void *src);
215 /* Translation table for bitmasks... */
216 typedef struct bitmask_transtbl {
217 unsigned int x86_mask;
218 unsigned int x86_bits;
219 unsigned int alpha_mask;
220 unsigned int alpha_bits;
223 void thunk_register_struct(int id, const char *name, const argtype *types);
224 void thunk_register_struct_direct(int id, const char *name, StructEntry *se1);
225 const argtype *thunk_convert(void *dst, const void *src,
226 const argtype *type_ptr, int to_host);
228 unsigned int target_to_host_bitmask(unsigned int x86_mask,
229 bitmask_transtbl * trans_tbl);
230 unsigned int host_to_target_bitmask(unsigned int alpha_mask,
231 bitmask_transtbl * trans_tbl);