Merge pull request #34 from davidsch/armhf Fix ARM hard-float support for large numbers of VFP arguments
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
diff --git a/ChangeLog b/ChangeLog
index e0b057c..4603e68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-03-28 David Schneider <david.schneider@bivab.de>
+
+ * src/arm/ffi.c: Fix support for ARM hard-float calling convention.
+ * src/arm/sysv.S: call different methods for SYSV and VFP ABIs.
+ * testsuite/libffi.call/cls_many_mixed_args.c: testcase for a closure with
+ mixed arguments, many doubles.
+ * testsuite/libffi.call/many_double.c: testcase for calling a function using
+ more than 8 doubles.
+ * testcase/libffi.call/many.c: use absolute value to check result against an
+ epsilon
+
2013-03-17 Anthony Green <green@moxielogic.com>
* README: Update for 3.0.13.
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index 3ccceb9..4c3b146 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -37,6 +37,84 @@
static int vfp_type_p (ffi_type *);
static void layout_vfp_args (ffi_cif *);
+static char* ffi_align(ffi_type **p_arg, char *argp)
+{
+ /* Align if necessary */
+ register size_t alignment = (*p_arg)->alignment;
+ if (alignment < 4)
+ {
+ alignment = 4;
+ }
+#ifdef _WIN32_WCE
+ if (alignment > 4)
+ {
+ alignment = 4;
+ }
+#endif
+ if ((alignment - 1) & (unsigned) argp)
+ {
+ argp = (char *) ALIGN(argp, alignment);
+ }
+
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ argp = (char *) ALIGN(argp, 4);
+ }
+ return argp;
+}
+
+static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
+{
+ register char* argp = stack;
+ register ffi_type **p_arg = arg_type;
+ register void **p_argv = arg;
+ register size_t z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *p_argv, (*p_arg)->size);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof(int))
+ {
+ 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
@@ -44,14 +122,14 @@ static void layout_vfp_args (ffi_cif *);
value is cif->vfp_used (word bitset of VFP regs used for passing
arguments). These are only used for the VFP hard-float ABI.
*/
-int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
+int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
{
- register unsigned int i, vi = 0;
+ register unsigned int i;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
-
argp = stack;
+
if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
*(void **) argp = ecif->rvalue;
@@ -62,81 +140,89 @@ int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0);
- i--, p_arg++)
+ i--, p_arg++, p_argv++)
{
- size_t z;
- size_t alignment;
+ argp = ffi_align(p_arg, argp);
+ argp += ffi_put_arg(p_arg, p_argv, argp);
+ }
- /* 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);
- p_argv++;
- continue;
- }
+ return 0;
+}
- /* Align if necessary */
- alignment = (*p_arg)->alignment;
-#ifdef _WIN32_WCE
- if (alignment > 4)
- alignment = 4;
-#endif
- if ((alignment - 1) & (unsigned) argp) {
- argp = (char *) ALIGN(argp, alignment);
- }
+int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
+{
+ // make sure we are using FFI_VFP
+ FFI_ASSERT(ecif->cif->abi == FFI_VFP);
- if ((*p_arg)->type == FFI_TYPE_STRUCT)
- argp = (char *) ALIGN(argp, 4);
+ register unsigned int i, vi = 0;
+ register void **p_argv;
+ register char *argp, *regp, *eo_regp;
+ register ffi_type **p_arg;
+ char stack_used = 0;
+ char done_with_regs = 0;
+ char is_vfp_type;
+
+ /* the first 4 words on the stack are used for values passed in core
+ * registers. */
+ regp = stack;
+ eo_regp = argp = regp + 16;
+
- z = (*p_arg)->size;
- if (z < sizeof(int))
- {
- z = sizeof(int);
- switch ((*p_arg)->type)
- {
- case FFI_TYPE_SINT8:
- *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
- break;
-
- case FFI_TYPE_UINT8:
- *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
- break;
-
- case FFI_TYPE_SINT16:
- *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
- break;
-
- case FFI_TYPE_UINT16:
- *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
- break;
-
- case FFI_TYPE_STRUCT:
- memcpy(argp, *p_argv, (*p_arg)->size);
- break;
-
- default:
- FFI_ASSERT(0);
- }
- }
- else if (z == sizeof(int))
- {
- *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
- }
- else
- {
- memcpy(argp, *p_argv, z);
- }
- p_argv++;
- argp += z;
- }
+ /* if the function returns an FFI_TYPE_STRUCT in memory, that address is
+ * passed in r0 to the function */
+ if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
+ *(void **) regp = ecif->rvalue;
+ regp += 4;
+ }
+
+ p_argv = ecif->avalue;
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++, p_argv++)
+ {
+ is_vfp_type = vfp_type_p (*p_arg);
+
+ /* Allocated in VFP registers. */
+ if(vi < ecif->cif->vfp_nargs && is_vfp_type)
+ {
+ char *vfp_slot = (char *)(vfp_space + ecif->cif->vfp_args[vi++]);
+ ffi_put_arg(p_arg, p_argv, vfp_slot);
+ continue;
+ }
+ /* Try allocating in core registers. */
+ else if (!done_with_regs && !is_vfp_type)
+ {
+ char *tregp = ffi_align(p_arg, regp);
+ size_t size = (*p_arg)->size;
+ size = (size < 4)? 4 : size; // pad
+ /* Check if there is space left in the aligned register area to place
+ * the argument */
+ if(tregp + size <= eo_regp)
+ {
+ regp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
+ done_with_regs = (regp == argp);
+ // ensure we did not write into the stack area
+ FFI_ASSERT(regp <= argp);
+ continue;
+ }
+ /* In case there are no arguments in the stack area yet,
+ the argument is passed in the remaining core registers and on the
+ stack. */
+ else if (!stack_used)
+ {
+ stack_used = 1;
+ done_with_regs = 1;
+ argp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
+ FFI_ASSERT(eo_regp < argp);
+ continue;
+ }
+ }
+ /* Base case, arguments are passed on the stack */
+ stack_used = 1;
+ argp = ffi_align(p_arg, argp);
+ argp += ffi_put_arg(p_arg, p_argv, argp);
+ }
/* Indicate the VFP registers used. */
return ecif->cif->vfp_used;
}
@@ -271,6 +357,9 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif, float *vfp_stack);
+static void ffi_prep_incoming_args_VFP (char *stack, void **ret,
+ void** args, ffi_cif* cif, float *vfp_stack);
+
void ffi_closure_SYSV (ffi_closure *);
void ffi_closure_VFP (ffi_closure *);
@@ -278,7 +367,7 @@ void ffi_closure_VFP (ffi_closure *);
/* This function is jumped to by the trampoline */
unsigned int
-ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
+ffi_closure_inner (closure, respp, args, vfp_args)
ffi_closure *closure;
void **respp;
void *args;
@@ -296,8 +385,10 @@ ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address. */
-
- ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
+ if (cif->abi == FFI_VFP)
+ ffi_prep_incoming_args_VFP(args, respp, arg_area, cif, vfp_args);
+ else
+ ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
(closure->fun) (cif, *respp, arg_area, closure->user_data);
@@ -312,7 +403,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
float *vfp_stack)
/*@=exportheader@*/
{
- register unsigned int i, vi = 0;
+ register unsigned int i;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
@@ -329,27 +420,8 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{
size_t z;
- size_t alignment;
-
- if (cif->abi == FFI_VFP
- && vi < cif->vfp_nargs && vfp_type_p (*p_arg))
- {
- *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
- continue;
- }
- alignment = (*p_arg)->alignment;
- if (alignment < 4)
- alignment = 4;
-#ifdef _WIN32_WCE
- else
- if (alignment > 4)
- alignment = 4;
-#endif
- /* Align if necessary */
- if ((alignment - 1) & (unsigned) argp) {
- argp = (char *) ALIGN(argp, alignment);
- }
+ argp = ffi_align(p_arg, argp);
z = (*p_arg)->size;
@@ -364,6 +436,90 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
return;
}
+/*@-exportheader@*/
+static void
+ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif,
+ /* Used only under VFP hard-float ABI. */
+ float *vfp_stack)
+/*@=exportheader@*/
+{
+ register unsigned int i, vi = 0;
+ register void **p_argv;
+ register char *argp, *regp, *eo_regp;
+ register ffi_type **p_arg;
+ char done_with_regs = 0;
+ char stack_used = 0;
+ char is_vfp_type;
+
+ FFI_ASSERT(cif->abi == FFI_VFP);
+ regp = stack;
+ eo_regp = argp = regp + 16;
+
+ if ( cif->flags == FFI_TYPE_STRUCT ) {
+ *rvalue = *(void **) regp;
+ regp += 4;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+ is_vfp_type = vfp_type_p (*p_arg);
+
+ if(vi < cif->vfp_nargs && is_vfp_type)
+ {
+ *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
+ continue;
+ }
+ else if (!done_with_regs && !is_vfp_type)
+ {
+ char* tregp = ffi_align(p_arg, regp);
+
+ z = (*p_arg)->size;
+ z = (z < 4)? 4 : z; // pad
+
+ /* if the arguments either fits into the registers or uses registers
+ * and stack, while we haven't read other things from the stack */
+ if(tregp + z <= eo_regp || !stack_used)
+ {
+ /* because we're little endian, this is what it turns into. */
+ *p_argv = (void*) tregp;
+
+ p_argv++;
+ regp = tregp + z;
+ /* if regp points above the end of the register area */
+ if(regp >= eo_regp)
+ {
+ /* sanity check that we haven't read from the stack area before
+ * reaching this point */
+ FFI_ASSERT(argp <= regp);
+ FFI_ASSERT(argp == stack + 16);
+ argp = regp;
+ done_with_regs = 1;
+ stack_used = 1;
+ }
+ continue;
+ }
+ }
+ stack_used = 1;
+
+ argp = ffi_align(p_arg, argp);
+
+ z = (*p_arg)->size;
+
+ /* because we're little endian, this is what it turns into. */
+
+ *p_argv = (void*) argp;
+
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
/* How to make a trampoline. */
extern unsigned int ffi_arm_trampoline[3];
diff --git a/src/arm/sysv.S b/src/arm/sysv.S
index fb38cd6..454dfc9 100644
--- a/src/arm/sysv.S
+++ b/src/arm/sysv.S
@@ -187,7 +187,7 @@ ARM_FUNC_START ffi_call_SYSV
@ r1 already set
@ Call ffi_prep_args(stack, &ecif)
- bl CNAME(ffi_prep_args)
+ bl CNAME(ffi_prep_args_SYSV)
@ move first 4 parameters in registers
ldmia sp, {r0-r3}
@@ -260,7 +260,7 @@ LSYM(Lepilogue):
/*
unsigned int FFI_HIDDEN
- ffi_closure_SYSV_inner (closure, respp, args)
+ ffi_closure_inner (closure, respp, args)
ffi_closure *closure;
void **respp;
void *args;
@@ -276,7 +276,7 @@ ARM_FUNC_START ffi_closure_SYSV
sub sp, sp, #16
str sp, [sp, #8]
add r1, sp, #8
- bl CNAME(ffi_closure_SYSV_inner)
+ bl CNAME(ffi_closure_inner)
cmp r0, #FFI_TYPE_INT
beq .Lretint
@@ -364,7 +364,7 @@ ARM_FUNC_START ffi_call_VFP
sub r2, fp, #64 @ VFP scratch space
@ Call ffi_prep_args(stack, &ecif, vfp_space)
- bl CNAME(ffi_prep_args)
+ bl CNAME(ffi_prep_args_VFP)
@ Load VFP register args if needed
cmp r0, #0
@@ -446,7 +446,7 @@ ARM_FUNC_START ffi_closure_VFP
sub sp, sp, #72
str sp, [sp, #64]
add r1, sp, #64
- bl CNAME(ffi_closure_SYSV_inner)
+ bl CNAME(ffi_closure_inner)
cmp r0, #FFI_TYPE_INT
beq .Lretint_vfp
diff --git a/testsuite/libffi.call/cls_many_mixed_args.c b/testsuite/libffi.call/cls_many_mixed_args.c
new file mode 100644
index 0000000..fc75b1d
--- /dev/null
+++ b/testsuite/libffi.call/cls_many_mixed_args.c
@@ -0,0 +1,68 @@
+/* Area: closure_call
+ Purpose: Check closures called with many args of mixed types
+ Limitations: none.
+ PR: none.
+ Originator: <david.schneider@picle.org> */
+
+/* { dg-do run } */
+#include "ffitest.h"
+#include <float.h>
+#include <math.h>
+
+#define NARGS 12
+
+static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ int i;
+ double r;
+ double t;
+ for(i = 0; i < NARGS; i++)
+ {
+ if(i == 8)
+ {
+ t = *(long int *)args[i];
+ CHECK(t == i+1);
+ }
+ else
+ {
+ t = *(double *)args[i];
+ CHECK(fabs(t - ((i+1) * 0.1)) < FLT_EPSILON);
+ }
+ r += t;
+ }
+ *(double *)resp = r;
+}
+typedef double (*cls_ret_double)(double, double, double, double, double, double, double, double, long int, double, double, double);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[NARGS];
+ double res;
+ int i;
+ double expected = 15.9;
+
+ for(i = 0; i < NARGS; i++)
+ {
+ if(i == 8)
+ cl_arg_types[i] = &ffi_type_slong;
+ else
+ cl_arg_types[i] = &ffi_type_double;
+ }
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NARGS,
+ &ffi_type_double, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK);
+
+ res = (((cls_ret_double)code))(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 9,
+ 1.0, 1.1, 1.2);
+ if (abs(res - expected) < FLT_EPSILON)
+ exit(0);
+ else
+ abort();
+}
diff --git a/testsuite/libffi.call/many.c b/testsuite/libffi.call/many.c
index 4869ba9..67a367f 100644
--- a/testsuite/libffi.call/many.c
+++ b/testsuite/libffi.call/many.c
@@ -7,7 +7,9 @@
/* { dg-do run } */
#include "ffitest.h"
+#include <stdlib.h>
#include <float.h>
+#include <math.h>
static float many(float f1,
float f2,
@@ -62,7 +64,7 @@ int main (void)
fa[8], fa[9],
fa[10],fa[11],fa[12]);
- if (f - ff < FLT_EPSILON)
+ if (fabs(f - ff) < FLT_EPSILON)
exit(0);
else
abort();
diff --git a/testsuite/libffi.call/many_double.c b/testsuite/libffi.call/many_double.c
new file mode 100644
index 0000000..4ef8c8a
--- /dev/null
+++ b/testsuite/libffi.call/many_double.c
@@ -0,0 +1,70 @@
+/* Area: ffi_call
+ Purpose: Check return value double, with many arguments
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+#include <stdlib.h>
+#include <float.h>
+#include <math.h>
+
+static double many(double f1,
+ double f2,
+ double f3,
+ double f4,
+ double f5,
+ double f6,
+ double f7,
+ double f8,
+ double f9,
+ double f10,
+ double f11,
+ double f12,
+ double f13)
+{
+#if 0
+ printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
+ (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
+ (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
+ (double) f11, (double) f12, (double) f13);
+#endif
+
+ return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[13];
+ void *values[13];
+ double fa[13];
+ double f, ff;
+ int i;
+
+ for (i = 0; i < 13; i++)
+ {
+ args[i] = &ffi_type_double;
+ values[i] = &fa[i];
+ fa[i] = (double) i;
+ }
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
+ &ffi_type_double, args) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(many), &f, values);
+
+ ff = many(fa[0], fa[1],
+ fa[2], fa[3],
+ fa[4], fa[5],
+ fa[6], fa[7],
+ fa[8], fa[9],
+ fa[10],fa[11],fa[12]);
+ if (fabs(f - ff) < FLT_EPSILON)
+ exit(0);
+ else
+ abort();
+}