Debian Codegraph @

testsuite/libffi.call/return_sl.c

raw
1 /* Area: ffi_call
2 Purpose: Check if long as return type is handled correctly.
3 Limitations: none.
4 PR: none.
5 */
6
7 /* { dg-do run } */
8 #include "ffitest.h"
9 static long return_sl(long l1, long l2)
10 {
11 CHECK(l1 == 1073741823L);
12 CHECK(l2 == 1073741824L);
13 return l1 - l2;
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 l1, l2;
23
24 args[0] = &ffi_type_slong;
25 args[1] = &ffi_type_slong;
26 values[0] = &l1;
27 values[1] = &l2;
28
29 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
30 &ffi_type_slong, args) == FFI_OK);
31
32 l1 = 1073741823L;
33 l2 = 1073741824L;
34
35 ffi_call(&cif, FFI_FN(return_sl), &res, values);
36 printf("res: %ld, %ld\n", (long)res, l1 - l2);
37 /* { dg-output "res: -1, -1" } */
38 CHECK((long)res == -1);
39 CHECK(l1 + 1 == l2);
40
41 exit(0);
42 }