OSDN Git Service

*** empty log message ***
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / cls_ulonglong.c
1 /* Area:        closure_call
2    Purpose:     Check return value long long.
3    Limitations: none.
4    PR:          none.
5    Originator:  <andreast@gcc.gnu.org> 20030828  */
6
7 /* { dg-do run } */
8 #include "ffitest.h"
9
10 static void cls_ret_ulonglong_fn(ffi_cif* cif,void* resp,void** args,
11                              void* userdata)
12  {
13    *(unsigned long long *)resp=  *(unsigned long long *)args[0];
14   
15    printf("%llu: %llu\n",*(unsigned long long *)args[0], 
16           *(unsigned long long *)resp);
17  }
18 typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
19
20 int main (void)
21 {
22   ffi_cif cif;
23   static ffi_closure cl;
24   ffi_closure *pcl = &cl;
25   ffi_type * cl_arg_types[2];
26   
27   cl_arg_types[0] = &ffi_type_uint64;
28   cl_arg_types[1] = NULL;
29   
30   /* Initialize the cif */
31   CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
32                      &ffi_type_uint64, cl_arg_types) == FFI_OK);
33   CHECK(ffi_prep_closure(pcl, &cif, cls_ret_ulonglong_fn, NULL)  == FFI_OK);
34   (*((cls_ret_ulonglong)pcl))(214LL);
35   /* { dg-output "214: 214" } */
36   (*((cls_ret_ulonglong)pcl))(9223372035854775808LL);
37   /* { dg-output "\n9223372035854775808: 9223372035854775808" } */
38   
39   exit(0);  
40 }