32 #define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG) 45 ptr = &(arg->elements[0]);
47 while ((*ptr) !=
NULL)
49 if (((*ptr)->size == 0)
51 return FFI_BAD_TYPEDEF;
55 arg->size += (*ptr)->size;
57 arg->alignment = (arg->alignment > (*ptr)->alignment) ?
58 arg->alignment : (*ptr)->alignment;
64 return FFI_BAD_TYPEDEF;
73 unsigned int struct_count = 0;
82 for (i = ecif->
cif->nargs, p_arg = ecif->
cif->arg_types;
83 (i != 0); i--, p_arg++)
87 switch ((*p_arg)->type)
104 unsigned int uiLocOnStack;
106 uiLocOnStack = 4 * ecif->
cif->nargs + struct_count;
107 struct_count = struct_count + (*p_arg)->size;
108 *(
unsigned int *) argp =
109 (
unsigned int) (UINT32 *) (stack + uiLocOnStack);
110 memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size);
116 if (z <
sizeof (
int))
118 switch ((*p_arg)->type)
121 *(
signed int *) argp = (
signed int) *(SINT8 *) (*p_argv);
125 *(
unsigned int *) argp =
126 (
unsigned int) *(UINT8 *) (*p_argv);
129 case FFI_TYPE_SINT16:
130 *(
signed int *) argp = (
signed int) *(SINT16 *) (*p_argv);
133 case FFI_TYPE_UINT16:
134 *(
unsigned int *) argp =
135 (
unsigned int) *(UINT16 *) (*p_argv);
143 else if (z ==
sizeof (
int))
144 *(
unsigned int *) argp = (
unsigned int) *(UINT32 *) (*p_argv);
146 memcpy (argp, *p_argv, z);
153 return (struct_count);
158 ffi_abi abi,
unsigned int isvariadic,
159 unsigned int nfixedargs,
unsigned int ntotalargs,
160 ffi_type * rtype, ffi_type ** atypes)
167 FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
172 cif->arg_types = atypes;
173 cif->nargs = ntotalargs;
178 if ((cif->rtype->size == 0)
180 return FFI_BAD_TYPEDEF;
184 for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
186 if (((*ptr)->size == 0)
188 return FFI_BAD_TYPEDEF;
192 if (((*ptr)->alignment - 1) & bytes)
193 bytes =
ALIGN (bytes, (*ptr)->alignment);
194 if ((*ptr)->type == FFI_TYPE_STRUCT)
196 if ((*ptr)->size > 8)
198 bytes += (*ptr)->size;
199 bytes +=
sizeof (
void *);
203 if ((*ptr)->size > 4)
221 switch (cif->rtype->type)
224 case FFI_TYPE_STRUCT:
226 case FFI_TYPE_DOUBLE:
227 case FFI_TYPE_SINT64:
228 case FFI_TYPE_UINT64:
229 cif->flags = (unsigned) cif->rtype->type;
233 cif->flags = FFI_TYPE_INT;
242 unsigned,
unsigned,
unsigned *,
void (*fn) ())
246 ffi_call (ffi_cif * cif,
void (*fn) (),
void *rvalue,
void **avalue)
253 if ((rvalue ==
NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
264 cif->flags, ecif.
rvalue, fn);
276 extern const char ffi_cris_trampoline_template[]
281 extern const int ffi_cris_trampoline_fn_offset
286 extern const int ffi_cris_trampoline_closure_offset
296 static unsigned long long 299 char *register_args = (
char *) params;
300 void *struct_ret = params[5];
301 char *stack_args = params[6];
302 char *ptr = register_args;
303 ffi_cif *cif = closure->cif;
304 ffi_type **arg_types = cif->arg_types;
307 void **avalue =
alloca (closure->cif->nargs *
sizeof(
void *));
313 for (i = 0, doing_regs = 1; i < cif->nargs; i++)
316 if (arg_types[i]->
size <= 4)
321 else if (arg_types[i]->
size <= 8)
328 FFI_ASSERT (arg_types[i]->type == FFI_TYPE_STRUCT);
331 avalue[i] = *(
void **) ptr;
338 if (doing_regs && ptr >= register_args + 4*4)
340 ptr = stack_args + ((ptr > register_args + 4*4) ? 4 : 0);
348 cif->rtype->type == FFI_TYPE_STRUCT
359 avalue, closure->user_data);
369 void (*fun)(ffi_cif *,
void *,
void **,
void*),
376 closure->user_data = user_data;
378 memcpy (closure->tramp, ffi_cris_trampoline_template,
380 memcpy (closure->tramp + ffi_cris_trampoline_fn_offset,
381 &innerfn, sizeof (
void *));
382 memcpy (closure->tramp + ffi_cris_trampoline_closure_offset,
383 &codeloc, sizeof (
void *));
void *PTR64 __attribute__((mode(DI)))
void ffi_call_SYSV(unsigned(*)(struct call_context *context, unsigned char *, extended_cif *), struct call_context *context, extended_cif *, size_t, void(*fn)(void))
#define FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE
ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void(*fun)(ffi_cif *, void *, void **, void *), void *user_data, void *codeloc)
void ffi_type_test(ffi_type *a, char *file, int line)
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
const UINT64 ffi_template_tramp_tile [] FFI_HIDDEN
#define FFI_ASSERT_VALID_TYPE(x)
ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, unsigned int isvariadic, unsigned int nfixedargs, unsigned int ntotalargs, ffi_type *rtype, ffi_type **atypes)
static unsigned long long ffi_prep_closure_inner(void **params, ffi_closure *closure)
static ffi_status initialize_aggregate_packed_struct(ffi_type *arg)
void ffi_prep_args(char *stack, extended_cif *ecif)
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
#define STACK_ARG_SIZE(x)