move the hardfloat specific argument copying code to the helper function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index c670465..1fb7199 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -71,8 +71,8 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
register size_t z = (*p_arg)->size;
if (z < sizeof(int))
{
- z = sizeof(int);
- switch ((*p_arg)->type)
+ z = sizeof(int);
+ switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
@@ -100,14 +100,20 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
}
else if (z == sizeof(int))
{
- *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ *(float *) argp = *(float *)(* p_argv);
+ else
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
}
+ else if (z == sizeof(double) && (*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ *(double *) argp = *(double *)(* p_argv);
+ }
else
{
memcpy(argp, *p_argv, z);
}
return z;
-
}
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments
@@ -136,19 +142,13 @@ int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
(i != 0);
i--, p_arg++)
{
- size_t z;
/* Allocated in VFP registers. */
if (ecif->cif->abi == FFI_VFP
&& vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
{
- float* vfp_slot = vfp_space + ecif->cif->vfp_args[vi++];
- if ((*p_arg)->type == FFI_TYPE_FLOAT)
- *((float*)vfp_slot) = *((float*)*p_argv);
- else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
- *((double*)vfp_slot) = *((double*)*p_argv);
- else
- memcpy(vfp_slot, *p_argv, (*p_arg)->size);
+ char *vfp_slot = (char *)(vfp_space + ecif->cif->vfp_args[vi++]);
+ ffi_put_arg(p_arg, p_argv, vfp_slot);
p_argv++;
continue;
}