OSDN Git Service

* testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*.
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / cls_longdouble_va.c
1 /* Area:                ffi_call, closure_call
2    Purpose:             Test long doubles passed in variable argument lists.
3    Limitations: none.
4    PR:                  none.
5    Originator:  Blake Chaffin 6/6/2007   */
6
7 /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
8 #include "ffitest.h"
9
10 static void
11 cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, 
12                      void** args, void* userdata __UNUSED__)
13 {
14         char*           format  = *(char**)args[0];
15         long double     ldValue = *(long double*)args[1];
16
17         *(ffi_arg*)resp = printf(format, ldValue);
18 }
19
20 int main (void)
21 {
22         ffi_cif cif;
23 #ifndef USING_MMAP
24         static ffi_closure cl;
25 #endif
26         ffi_closure *pcl;
27         void* args[3];
28         ffi_type* arg_types[3];
29
30 #ifdef USING_MMAP
31         pcl = allocate_mmap (sizeof(ffi_closure));
32 #else
33         pcl = &cl;
34 #endif
35
36         char*           format  = "%L.1f\n";
37         long double     ldArg   = 7;
38         ffi_arg         res             = 0;
39
40         arg_types[0] = &ffi_type_pointer;
41         arg_types[1] = &ffi_type_longdouble;
42         arg_types[2] = NULL;
43
44         CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
45                 arg_types) == FFI_OK);
46
47         args[0] = &format;
48         args[1] = &ldArg;
49         args[2] = NULL;
50
51         ffi_call(&cif, FFI_FN(printf), &res, args);
52         // { dg-output "7.0" { xfail i*86-*-linux-* x86_64-*-linux-* sh*-*-linux-* } }
53         printf("res: %d\n", (int) res);
54         // { dg-output "\nres: 4" { xfail i*86-*-linux-* x86_64-*-linux-* sh*-*-linux-* } }
55
56         CHECK(ffi_prep_closure(pcl, &cif, cls_longdouble_va_fn, NULL) == FFI_OK);
57
58         res     = ((int(*)(char*, long double))(pcl))(format, ldArg);
59         // { dg-output "\n7.0" }
60         printf("res: %d\n", (int) res);
61         // { dg-output "\nres: 4" }
62
63         exit(0);
64 }