#include <ffi.h>
#include <ffi_common.h>
-
#include <stdlib.h>
+/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
+ all further uses in this file will refer to the 128-bit type. */
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+# if FFI_TYPE_LONGDOUBLE != 4
+# error FFI_TYPE_LONGDOUBLE out of date
+# endif
+#else
+# undef FFI_TYPE_LONGDOUBLE
+# define FFI_TYPE_LONGDOUBLE 4
+#endif
+
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
size_t z;
if ((*p_arg)->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
- || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
-#endif
- )
+ || (*p_arg)->type == FFI_TYPE_LONGDOUBLE)
{
*(unsigned int *) argp = (unsigned long)(* p_argv);
z = sizeof(int);
/* FALLTHROUGH */
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
ret = 1; /* We should promote into FP regs as well as integer. */
break;
}
case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
cif->flags = cif->rtype->type;
break;
break;
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
-#endif
memmove(ret + off, flt + off, (*ptr)->size);
off += (*ptr)->size;
break;
FFI_ASSERT(0);
#else
if (rvalue && (cif->rtype->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
- || cif->flags == FFI_TYPE_LONGDOUBLE
-#endif
- ))
+ || cif->flags == FFI_TYPE_LONGDOUBLE))
{
/* For v8, we need an "unimp" with size of returning struct */
/* behind "call", so we alloc some executable space for it. */
/* Copy the caller's structure return address so that the closure
returns the data directly to the caller. */
- if (cif->flags == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
- || cif->flags == FFI_TYPE_LONGDOUBLE
-#endif
- )
+ if (cif->flags == FFI_TYPE_STRUCT || cif->flags == FFI_TYPE_LONGDOUBLE)
rvalue = (void *) gpr[0];
/* Always skip the structure return address. */
for (i = 0; i < cif->nargs; i++)
{
if (arg_types[i]->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
- || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
-#endif
- )
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
{
/* Straight copy of invisible reference. */
avalue[i] = (void *)gpr[argn++];
argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
/* Align on a 16-byte boundary. */
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
if (arg_types[i]->type == FFI_TYPE_LONGDOUBLE && (argn % 2) != 0)
argn++;
-#endif
if (i < fp_slot_max
&& (arg_types[i]->type == FFI_TYPE_FLOAT
|| arg_types[i]->type == FFI_TYPE_DOUBLE
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
- || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
-#endif
- ))
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
avalue[i] = ((char *) &fpr[argn]) - arg_types[i]->size;
else
avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;