1 /* Area:	ffi_call
2    Purpose:	Check for proper argument alignment.
3    Limitations:	none.
4    PR:		none.
5    Originator:	<twalljava@java.net> (from many_win32.c) */
6 
7 /* { dg-do run } */
8 
9 #include "ffitest.h"
10 
align_arguments(int i1,double f2,int i3,double f4)11 static float ABI_ATTR align_arguments(int i1,
12                                       double f2,
13                                       int i3,
14                                       double f4)
15 {
16   return i1+f2+i3+f4;
17 }
18 
main(void)19 int main(void)
20 {
21   ffi_cif cif;
22   ffi_type *args[4] = {
23     &ffi_type_sint,
24     &ffi_type_double,
25     &ffi_type_sint,
26     &ffi_type_double
27   };
28   double fa[2] = {1,2};
29   int ia[2] = {1,2};
30   void *values[4] = {&ia[0], &fa[0], &ia[1], &fa[1]};
31   float f, ff;
32 
33   /* Initialize the cif */
34   CHECK(ffi_prep_cif(&cif, ABI_NUM, 4,
35 		     &ffi_type_float, args) == FFI_OK);
36 
37   ff = align_arguments(ia[0], fa[0], ia[1], fa[1]);;
38 
39   ffi_call(&cif, FFI_FN(align_arguments), &f, values);
40 
41   if (f == ff)
42     printf("align arguments tests ok!\n");
43   else
44     CHECK(0);
45   exit(0);
46 }
47