OSDN Git Service

*** empty log message ***
[pf3gnuchains/gcc-fork.git] / libffi / testsuite / libffi.call / cls_uint.c
1 /* Area:        closure_call
2    Purpose:     Check return value uint.
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_uint_fn(ffi_cif* cif,void* resp,void** args,
11                              void* userdata)
12  {
13    *(unsigned int*)resp = *(unsigned int *)args[0];
14    
15    printf("%d: %d\n",*(unsigned int *)args[0], 
16           *(unsigned int *)resp);
17  }
18 typedef unsigned int (*cls_ret_uint)(unsigned int);
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   
28   cl_arg_types[0] = &ffi_type_uint32;
29   cl_arg_types[1] = NULL;
30   
31   /* Initialize the cif */
32   CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
33                      &ffi_type_uint32, cl_arg_types) == FFI_OK);
34   
35   CHECK(ffi_prep_closure(pcl, &cif, cls_ret_uint_fn, NULL)  == FFI_OK);
36   
37   (*((cls_ret_uint)pcl))(2147483647);
38   /* { dg-output "2147483647: 2147483647" } */
39
40   exit(0);  
41 }