1/* Area: closure_call 2 Purpose: Check multiple values passing from different type. 3 Also, exceed the limit of gpr and fpr registers on PowerPC 4 Darwin. 5 Limitations: none. 6 PR: none. 7 Originator: <andreast@gcc.gnu.org> 20030828 */ 8 9/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */ 10#include "ffitest.h" 11 12static void 13closure_test_fn0(ffi_cif* cif,void* resp,void** args, void* userdata) 14{ 15 *(ffi_arg*)resp = 16 (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) + 17 (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] + 18 (int)(*(signed short *)args[4]) + 19 (int)(*(unsigned long long *)args[5]) + 20 (int)*(int *)args[6] + (int)(*(int *)args[7]) + 21 (int)(*(double *)args[8]) + (int)*(int *)args[9] + 22 (int)(*(int *)args[10]) + (int)(*(float *)args[11]) + 23 (int)*(int *)args[12] + (int)(*(int *)args[13]) + 24 (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata; 25 26 printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n", 27 (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]), 28 (int)(*(unsigned long long *)args[2]), 29 (int)*(int *)args[3], (int)(*(signed short *)args[4]), 30 (int)(*(unsigned long long *)args[5]), 31 (int)*(int *)args[6], (int)(*(int *)args[7]), 32 (int)(*(double *)args[8]), (int)*(int *)args[9], 33 (int)(*(int *)args[10]), (int)(*(float *)args[11]), 34 (int)*(int *)args[12], (int)(*(int *)args[13]), 35 (int)(*(int *)args[14]),*(int *)args[15], 36 (int)(long)userdata, (int)*(ffi_arg *)resp); 37 38} 39 40typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, 41 int, signed short, unsigned long long, int, 42 int, double, int, int, float, int, int, 43 int, int); 44 45int main (void) 46{ 47 ffi_cif cif; 48#ifndef USING_MMAP 49 static ffi_closure cl; 50#endif 51 ffi_closure *pcl; 52 ffi_type * cl_arg_types[17]; 53 int res; 54 55#ifdef USING_MMAP 56 pcl = allocate_mmap (sizeof(ffi_closure)); 57#else 58 pcl = &cl; 59#endif 60 61 cl_arg_types[0] = &ffi_type_uint64; 62 cl_arg_types[1] = &ffi_type_uint; 63 cl_arg_types[2] = &ffi_type_uint64; 64 cl_arg_types[3] = &ffi_type_uint; 65 cl_arg_types[4] = &ffi_type_sshort; 66 cl_arg_types[5] = &ffi_type_uint64; 67 cl_arg_types[6] = &ffi_type_uint; 68 cl_arg_types[7] = &ffi_type_uint; 69 cl_arg_types[8] = &ffi_type_double; 70 cl_arg_types[9] = &ffi_type_uint; 71 cl_arg_types[10] = &ffi_type_uint; 72 cl_arg_types[11] = &ffi_type_float; 73 cl_arg_types[12] = &ffi_type_uint; 74 cl_arg_types[13] = &ffi_type_uint; 75 cl_arg_types[14] = &ffi_type_uint; 76 cl_arg_types[15] = &ffi_type_uint; 77 cl_arg_types[16] = NULL; 78 79 /* Initialize the cif */ 80 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16, 81 &ffi_type_sint, cl_arg_types) == FFI_OK); 82 83 CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0, 84 (void *) 3 /* userdata */) == FFI_OK); 85 86 res = (*((closure_test_type0)pcl)) 87 (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, 88 19, 21, 1); 89 /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ 90 printf("res: %d\n",res); 91 /* { dg-output "\nres: 680" } */ 92 exit(0); 93} 94