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 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
34 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
35 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
36 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
37 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
38 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
39 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
40 (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
45 #ifdef WORDS_BIGENDIAN
51 #define TARGET_LONG_BITS 32
54 #if defined(__alpha__)
55 #define HOST_LONG_BITS 64
57 #define HOST_LONG_BITS 32
60 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
61 #define HOST_LONG_SIZE (TARGET_LONG_BITS / 8)
63 static inline uint16_t bswap16(uint16_t x
)
68 static inline uint32_t bswap32(uint32_t x
)
73 static inline uint64_t bswap64(uint64_t x
)
78 static void inline bswap16s(uint16_t *s
)
83 static void inline bswap32s(uint32_t *s
)
88 static void inline bswap64s(uint64_t *s
)
95 static inline uint16_t tswap16(uint16_t s
)
100 static inline uint32_t tswap32(uint32_t s
)
105 static inline uint64_t tswap64(uint64_t s
)
110 static void inline tswap16s(uint16_t *s
)
115 static void inline tswap32s(uint32_t *s
)
120 static void inline tswap64s(uint64_t *s
)
127 static inline uint16_t tswap16(uint16_t s
)
132 static inline uint32_t tswap32(uint32_t s
)
137 static inline uint64_t tswap64(uint64_t s
)
142 static void inline tswap16s(uint16_t *s
)
146 static void inline tswap32s(uint32_t *s
)
150 static void inline tswap64s(uint64_t *s
)
156 #if TARGET_LONG_SIZE == 4
157 #define tswapl(s) tswap32(s)
158 #define tswapls(s) tswap32s((uint32_t *)(s))
160 #define tswapl(s) tswap64(s)
161 #define tswapls(s) tswap64s((uint64_t *)(s))
164 #if TARGET_LONG_SIZE == 4
165 typedef int32_t target_long
;
166 typedef uint32_t target_ulong
;
167 #elif TARGET_LONG_SIZE == 8
168 typedef int64_t target_long
;
169 typedef uint64_t target_ulong
;
171 #error TARGET_LONG_SIZE undefined
174 /* types enums definitions */
176 typedef enum argtype
{
183 TYPE_PTRVOID
, /* pointer on unknown data */
191 #define MK_PTR(type) TYPE_PTR, type
192 #define MK_ARRAY(type, size) TYPE_ARRAY, size, type
193 #define MK_STRUCT(id) TYPE_STRUCT, id
195 #define THUNK_TARGET 0
199 /* standard struct handling */
200 const argtype
*field_types
;
202 int *field_offsets
[2];
203 /* special handling */
204 void (*convert
[2])(void *dst
, const void *src
);
210 /* Translation table for bitmasks... */
211 typedef struct bitmask_transtbl
{
212 unsigned int x86_mask
;
213 unsigned int x86_bits
;
214 unsigned int alpha_mask
;
215 unsigned int alpha_bits
;
218 void thunk_register_struct(int id
, const char *name
, const argtype
*types
);
219 void thunk_register_struct_direct(int id
, const char *name
, StructEntry
*se1
);
220 const argtype
*thunk_convert(void *dst
, const void *src
,
221 const argtype
*type_ptr
, int to_host
);
223 unsigned int target_to_host_bitmask(unsigned int x86_mask
,
224 bitmask_transtbl
* trans_tbl
);
225 unsigned int host_to_target_bitmask(unsigned int alpha_mask
,
226 bitmask_transtbl
* trans_tbl
);