8 #if __BYTE_ORDER == __BIG_ENDIAN
9 #define WORDS_BIGENDIAN
16 /* XXX: auto autoconf */
18 #define TARGET_LONG_BITS 32
21 #if defined(__alpha__)
22 #define HOST_LONG_BITS 64
24 #define HOST_LONG_BITS 32
27 #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
28 #define HOST_LONG_SIZE (TARGET_LONG_BITS / 8)
30 static inline uint16_t bswap16(uint16_t x)
35 static inline uint32_t bswap32(uint32_t x)
40 static inline uint64_t bswap64(uint64_t x)
45 static void inline bswap16s(uint16_t *s)
50 static void inline bswap32s(uint32_t *s)
55 static void inline bswap64s(uint64_t *s)
62 static inline uint16_t tswap16(uint16_t s)
67 static inline uint32_t tswap32(uint32_t s)
72 static inline uint64_t tswap64(uint64_t s)
77 static void inline tswap16s(uint16_t *s)
82 static void inline tswap32s(uint32_t *s)
87 static void inline tswap64s(uint64_t *s)
94 static inline uint16_t tswap16(uint16_t s)
99 static inline uint32_t tswap32(uint32_t s)
104 static inline uint64_t tswap64(uint64_t s)
109 static void inline tswap16s(uint16_t *s)
113 static void inline tswap32s(uint32_t *s)
117 static void inline tswap64s(uint64_t *s)
123 #if TARGET_LONG_SIZE == 4
124 #define tswapl(s) tswap32(s)
125 #define tswapls(s) tswap32s((uint32_t *)(s))
127 #define tswapl(s) tswap64(s)
128 #define tswapls(s) tswap64s((uint64_t *)(s))
131 #if TARGET_LONG_SIZE == 4
132 typedef int32_t target_long;
133 typedef uint32_t target_ulong;
134 #elif TARGET_LONG_SIZE == 8
135 typedef int64_t target_long;
136 typedef uint64_t target_ulong;
138 #error TARGET_LONG_SIZE undefined
141 /* types enums definitions */
143 typedef enum argtype {
150 TYPE_PTRVOID, /* pointer on unknown data */
158 #define MK_PTR(type) TYPE_PTR, type
159 #define MK_ARRAY(type, size) TYPE_ARRAY, size, type
160 #define MK_STRUCT(id) TYPE_STRUCT, id
162 #define THUNK_TARGET 0
166 /* standard struct handling */
167 const argtype *field_types;
169 int *field_offsets[2];
170 /* special handling */
171 void (*convert[2])(void *dst, const void *src);
177 /* Translation table for bitmasks... */
178 typedef struct bitmask_transtbl {
179 unsigned int x86_mask;
180 unsigned int x86_bits;
181 unsigned int alpha_mask;
182 unsigned int alpha_bits;
185 void thunk_register_struct(int id, const char *name, const argtype *types);
186 void thunk_register_struct_direct(int id, const char *name, StructEntry *se1);
187 const argtype *thunk_convert(void *dst, const void *src,
188 const argtype *type_ptr, int to_host);
190 unsigned int target_to_host_bitmask(unsigned int x86_mask,
191 bitmask_transtbl * trans_tbl);
192 unsigned int host_to_target_bitmask(unsigned int alpha_mask,
193 bitmask_transtbl * trans_tbl);