Revision 5fafdf24 thunk.c
b/thunk.c | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Generic thunking code to convert data between host and target CPU |
3 |
*
|
|
3 |
* |
|
4 | 4 |
* Copyright (c) 2003 Fabrice Bellard |
5 | 5 |
* |
6 | 6 |
* This library is free software; you can redistribute it and/or |
... | ... | |
64 | 64 |
int nb_fields, offset, max_align, align, size, i, j; |
65 | 65 |
|
66 | 66 |
se = struct_entries + id; |
67 |
|
|
67 |
|
|
68 | 68 |
/* first we count the number of fields */ |
69 | 69 |
type_ptr = types; |
70 | 70 |
nb_fields = 0; |
... | ... | |
76 | 76 |
se->nb_fields = nb_fields; |
77 | 77 |
se->name = name; |
78 | 78 |
#ifdef DEBUG |
79 |
printf("struct %s: id=%d nb_fields=%d\n",
|
|
79 |
printf("struct %s: id=%d nb_fields=%d\n", |
|
80 | 80 |
se->name, id, se->nb_fields); |
81 | 81 |
#endif |
82 | 82 |
/* now we can alloc the data */ |
... | ... | |
100 | 100 |
se->size[i] = offset; |
101 | 101 |
se->align[i] = max_align; |
102 | 102 |
#ifdef DEBUG |
103 |
printf("%s: size=%d align=%d\n",
|
|
103 |
printf("%s: size=%d align=%d\n", |
|
104 | 104 |
i == THUNK_HOST ? "host" : "target", offset, max_align); |
105 | 105 |
#endif |
106 | 106 |
} |
... | ... | |
116 | 116 |
|
117 | 117 |
|
118 | 118 |
/* now we can define the main conversion functions */ |
119 |
const argtype *thunk_convert(void *dst, const void *src,
|
|
119 |
const argtype *thunk_convert(void *dst, const void *src, |
|
120 | 120 |
const argtype *type_ptr, int to_host) |
121 | 121 |
{ |
122 | 122 |
int type; |
... | ... | |
182 | 182 |
uint8_t *d; |
183 | 183 |
const argtype *field_types; |
184 | 184 |
const int *dst_offsets, *src_offsets; |
185 |
|
|
185 |
|
|
186 | 186 |
se = struct_entries + *type_ptr++; |
187 | 187 |
if (se->convert[0] != NULL) { |
188 | 188 |
/* specific conversion is needed */ |
... | ... | |
195 | 195 |
d = dst; |
196 | 196 |
s = src; |
197 | 197 |
for(i = 0;i < se->nb_fields; i++) { |
198 |
field_types = thunk_convert(d + dst_offsets[i],
|
|
199 |
s + src_offsets[i],
|
|
198 |
field_types = thunk_convert(d + dst_offsets[i], |
|
199 |
s + src_offsets[i], |
|
200 | 200 |
field_types, to_host); |
201 | 201 |
} |
202 | 202 |
} |
... | ... | |
214 | 214 |
/* Utility function: Table-driven functions to translate bitmasks |
215 | 215 |
* between X86 and Alpha formats... |
216 | 216 |
*/ |
217 |
unsigned int target_to_host_bitmask(unsigned int x86_mask,
|
|
217 |
unsigned int target_to_host_bitmask(unsigned int x86_mask, |
|
218 | 218 |
bitmask_transtbl * trans_tbl) |
219 | 219 |
{ |
220 | 220 |
bitmask_transtbl * btp; |
... | ... | |
228 | 228 |
return(alpha_mask); |
229 | 229 |
} |
230 | 230 |
|
231 |
unsigned int host_to_target_bitmask(unsigned int alpha_mask,
|
|
231 |
unsigned int host_to_target_bitmask(unsigned int alpha_mask, |
|
232 | 232 |
bitmask_transtbl * trans_tbl) |
233 | 233 |
{ |
234 | 234 |
bitmask_transtbl * btp; |
Also available in: Unified diff