Debian Codegraph @

testsuite/libffi.call/return_ul.c

raw
1 /* Area: ffi_call
2 Purpose: Check if unsigned long as return type is handled correctly.
3 Limitations: none.
4 PR: none.
5 Originator: <kaffeetisch at gmx dot de> 20060724 */
6
7 /* { dg-do run } */
8 #include "ffitest.h"
9 static unsigned long return_ul(unsigned long ul1, unsigned long ul2)
10 {
11 CHECK(ul1 == 1073741823L);
12 CHECK(ul2 == 1073741824L);
13 return ul1 + ul2;
14 }
15
16 int main (void)
17 {
18 ffi_cif cif;
19 ffi_type *args[MAX_ARGS];
20 void *values[MAX_ARGS];
21 ffi_arg res;
22 unsigned long ul1, ul2;
23
24 args[0] = &ffi_type_ulong;
25 args[1] = &ffi_type_ulong;
26 values[0] = &ul1;
27 values[1] = &ul2;
28
29 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
30 &ffi_type_ulong, args) == FFI_OK);
31
32 ul1 = 1073741823L;
33 ul2 = 1073741824L;
34
35 ffi_call(&cif, FFI_FN(return_ul), &res, values);
36 printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2);
37 /* { dg-output "res: 2147483647, 2147483647" } */
38 CHECK(res == 2147483647L);
39 CHECK(ul1 + ul2 == 2147483647L);
40
41 exit(0);
42 }