1/* -*-c-*- */ 2#include "ffitest.h" 3 4#include <stdlib.h> 5#include <complex.h> 6 7static _Complex T_C_TYPE many(_Complex T_C_TYPE c1, 8 _Complex T_C_TYPE c2, 9 _Complex T_C_TYPE c3, 10 _Complex T_C_TYPE c4, 11 _Complex T_C_TYPE c5, 12 _Complex T_C_TYPE c6, 13 _Complex T_C_TYPE c7, 14 _Complex T_C_TYPE c8, 15 _Complex T_C_TYPE c9, 16 _Complex T_C_TYPE c10, 17 _Complex T_C_TYPE c11, 18 _Complex T_C_TYPE c12, 19 _Complex T_C_TYPE c13) 20{ 21 printf("0 :%f,%fi\n" 22 "1 :%f,%fi\n" 23 "2 :%f,%fi\n" 24 "3 :%f,%fi\n" 25 "4 :%f,%fi\n" 26 "5 :%f,%fi\n" 27 "6 :%f,%fi\n" 28 "7 :%f,%fi\n" 29 "8 :%f,%fi\n" 30 "9 :%f,%fi\n" 31 "10:%f,%fi\n" 32 "11:%f,%fi\n" 33 "12:%f,%fi\n", 34 T_CONV creal (c1), T_CONV cimag (c1), 35 T_CONV creal (c2), T_CONV cimag (c2), 36 T_CONV creal (c3), T_CONV cimag (c3), 37 T_CONV creal (c4), T_CONV cimag (c4), 38 T_CONV creal (c5), T_CONV cimag (c5), 39 T_CONV creal (c6), T_CONV cimag (c6), 40 T_CONV creal (c7), T_CONV cimag (c7), 41 T_CONV creal (c8), T_CONV cimag (c8), 42 T_CONV creal (c9), T_CONV cimag (c9), 43 T_CONV creal (c10), T_CONV cimag (c10), 44 T_CONV creal (c11), T_CONV cimag (c11), 45 T_CONV creal (c12), T_CONV cimag (c12), 46 T_CONV creal (c13), T_CONV cimag (c13)); 47 48 return (c1+c2-c3-c4+c5+c6+c7-c8-c9-c10-c11+c12+c13); 49} 50 51int main (void) 52{ 53 ffi_cif cif; 54 ffi_type *args[13]; 55 void *values[13]; 56 _Complex T_C_TYPE ca[13]; 57 _Complex T_C_TYPE c, cc; 58 int i; 59 60 for (i = 0; i < 13; i++) 61 { 62 args[i] = &T_FFI_TYPE; 63 values[i] = &ca[i]; 64 ca[i] = i + (-20 - i) * I; 65 } 66 67 /* Initialize the cif */ 68 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, &T_FFI_TYPE, args) == FFI_OK); 69 70 ffi_call(&cif, FFI_FN(many), &c, values); 71 72 cc = many(ca[0], ca[1], ca[2], ca[3], ca[4], ca[5], ca[6], ca[7], ca[8], 73 ca[9], ca[10], ca[11], ca[12]); 74 CHECK(creal (cc) == creal (c)); 75 CHECK(cimag (cc) == cimag (c)); 76 77 exit(0); 78} 79