1 /* Area: ffi_closure, unwind info
2 Purpose: Check if the unwind information is passed correctly.
5 Originator: Jeff Sturm <jsturm@one-point.com> */
8 #include "ffitestcxx.h"
11 closure_test_fn(ffi_cif
* cif
, void* resp
, void** args
, void* userdata
)
16 typedef void (*closure_test_type
)();
18 void closure_test_fn1(ffi_cif
* cif
,void* resp
,void** args
,
22 (int)*(float *)args
[0] +(int)(*(float *)args
[1]) +
23 (int)(*(float *)args
[2]) + (int)*(float *)args
[3] +
24 (int)(*(signed short *)args
[4]) + (int)(*(float *)args
[5]) +
25 (int)*(float *)args
[6] + (int)(*(int *)args
[7]) +
26 (int)(*(double*)args
[8]) + (int)*(int *)args
[9] +
27 (int)(*(int *)args
[10]) + (int)(*(float *)args
[11]) +
28 (int)*(int *)args
[12] + (int)(*(int *)args
[13]) +
29 (int)(*(int *)args
[14]) + *(int *)args
[15] + (int)(long)userdata
;
31 printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
32 (int)*(float *)args
[0], (int)(*(float *)args
[1]),
33 (int)(*(float *)args
[2]), (int)*(float *)args
[3],
34 (int)(*(signed short *)args
[4]), (int)(*(float *)args
[5]),
35 (int)*(float *)args
[6], (int)(*(int *)args
[7]),
36 (int)(*(double *)args
[8]), (int)*(int *)args
[9],
37 (int)(*(int *)args
[10]), (int)(*(float *)args
[11]),
38 (int)*(int *)args
[12], (int)(*(int *)args
[13]),
39 (int)(*(int *)args
[14]), *(int *)args
[15],
40 (int)(long)userdata
, *(int*)resp
);
45 typedef int (*closure_test_type1
)(float, float, float, float, signed short,
46 float, float, int, double, int, int, float,
53 ffi_type
* cl_arg_types
[17];
55 cl_arg_types
[1] = NULL
;
57 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 0,
58 &ffi_type_void
, cl_arg_types
) == FFI_OK
);
59 CHECK(ffi_prep_closure(&cl
, &cif
, closure_test_fn
, NULL
) == FFI_OK
);
63 (*((closure_test_type
)(&cl
)))();
64 } catch (int exception_code
)
66 CHECK(exception_code
== 9);
69 printf("part one OK\n");
70 /* { dg-output "part one OK" } */
75 cl_arg_types
[0] = &ffi_type_float
;
76 cl_arg_types
[1] = &ffi_type_float
;
77 cl_arg_types
[2] = &ffi_type_float
;
78 cl_arg_types
[3] = &ffi_type_float
;
79 cl_arg_types
[4] = &ffi_type_sshort
;
80 cl_arg_types
[5] = &ffi_type_float
;
81 cl_arg_types
[6] = &ffi_type_float
;
82 cl_arg_types
[7] = &ffi_type_uint
;
83 cl_arg_types
[8] = &ffi_type_double
;
84 cl_arg_types
[9] = &ffi_type_uint
;
85 cl_arg_types
[10] = &ffi_type_uint
;
86 cl_arg_types
[11] = &ffi_type_float
;
87 cl_arg_types
[12] = &ffi_type_uint
;
88 cl_arg_types
[13] = &ffi_type_uint
;
89 cl_arg_types
[14] = &ffi_type_uint
;
90 cl_arg_types
[15] = &ffi_type_uint
;
91 cl_arg_types
[16] = NULL
;
93 /* Initialize the cif */
94 CHECK(ffi_prep_cif(&cif
, FFI_DEFAULT_ABI
, 16,
95 &ffi_type_sint
, cl_arg_types
) == FFI_OK
);
97 CHECK(ffi_prep_closure(&cl
, &cif
, closure_test_fn1
,
98 (void *) 3 /* userdata */) == FFI_OK
);
101 (*((closure_test_type1
)(&cl
)))
102 (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
104 /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
105 } catch (int exception_code
)
107 CHECK(exception_code
== 255);
109 printf("part two OK\n");
110 /* { dg-output "\npart two OK" } */