Debian Codegraph @

testsuite/libffi.call/x32.c

raw
1 /* Area: ffi_call
2 Purpose: Check zero-extension of pointers on x32.
3 Limitations: none.
4 PR: 887
5 Originator: Mikulas Patocka <[email protected]> */
6
7 /* { dg-do run } */
8
9 #include "ffitest.h"
10
11 static int ABI_ATTR fn(int *a)
12 {
13 if (a)
14 return *a;
15 return -1;
16 }
17
18 int main(void)
19 {
20 ffi_cif cif;
21 ffi_type *args[MAX_ARGS];
22 void *values[MAX_ARGS];
23 void *z[2] = { (void *)0, (void *)1 };
24 ffi_arg rint;
25 args[0] = &ffi_type_pointer;
26 values[0] = z;
27 CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ffi_type_sint, args) == FFI_OK);
28 ffi_call(&cif, FFI_FN(fn), &rint, values);
29 CHECK((int)rint == -1);
30 exit(0);
31 }