2018-01-10 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libffi / testsuite / libffi.call / cls_uint_va.c
blobb04cfd19c2ce42fbd08906fd8e72aa7eac928f90
1 /* Area: closure_call
2 Purpose: Test anonymous unsigned int argument.
3 Limitations: none.
4 PR: none.
5 Originator: ARM Ltd. */
7 /* { dg-do run } */
9 #include "ffitest.h"
11 typedef unsigned int T;
13 static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14 void* userdata __UNUSED__)
16 *(ffi_arg *)resp = *(T *)args[0];
18 printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]);
21 typedef T (*cls_ret_T)(T, ...);
23 int main (void)
25 ffi_cif cif;
26 void *code;
27 ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
28 ffi_type * cl_arg_types[3];
29 T res;
31 cl_arg_types[0] = &ffi_type_uint;
32 cl_arg_types[1] = &ffi_type_uint;
33 cl_arg_types[2] = NULL;
35 /* Initialize the cif */
36 CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
37 &ffi_type_uint, cl_arg_types) == FFI_OK);
39 CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
40 res = ((((cls_ret_T)code)(67, 4)));
41 /* { dg-output "67: 67 4" } */
42 printf("res: %d\n", res);
43 /* { dg-output "\nres: 67" } */
44 exit(0);