OSDN Git Service

79be6d632dd9632b3219149426b06eaebcec4ddd
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / many_win32.c
1 /* Area:        ffi_call
2    Purpose:     Check stdcall many call on X86_WIN32 systems.
3    Limitations: none.
4    PR:          none.
5    Originator:  From the original ffitest.c  */
6
7 /* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
8
9 #include "ffitest.h"
10
11 static float __attribute__((stdcall)) stdcall_many(float f1,
12                                                    float f2,
13                                                    float f3,
14                                                    float f4,
15                                                    float f5,
16                                                    float f6,
17                                                    float f7,
18                                                    float f8,
19                                                    float f9,
20                                                    float f10,
21                                                    float f11,
22                                                    float f12,
23                                                    float f13)
24 {
25   return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
26 }
27
28 int main (void) 
29 {
30   ffi_cif cif;
31   ffi_type *args[13];
32   void *values[13];
33   float fa[13];
34   float f, ff;
35   int i;
36   
37   for (ul = 0; ul < 13; ul++)
38     {
39       args[ul] = &ffi_type_float;
40       values[ul] = &fa[ul];
41         fa[ul] = (float) ul;
42     }
43   
44   /* Initialize the cif */
45   CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 13,
46                      &ffi_type_float, args) == FFI_OK);
47   
48   ff =  stdcall_many(fa[0], fa[1],      
49                      fa[2], fa[3],      
50                      fa[4], fa[5],      
51                      fa[6], fa[7],
52                      fa[8], fa[9],                      
53                      fa[10], fa[11], fa[12]);
54
55   ffi_call(&cif, FFI_FN(stdcall_many), &f, values);
56   
57   if (f - ff < FLT_EPSILON)
58     printf("stdcall many arg tests ok!\n");
59   else
60     CHECK(0);   
61   exit(0);      
62 }