Daily bump.
[official-gcc.git] / libffi / testsuite / libffi.call / negint.c
blob6e2f26fc100e1a74dbcc8c41bd7acf030d90c9bf
1 /* Area: ffi_call
2 Purpose: Check that negative integers are passed correctly.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
9 #include "ffitest.h"
11 static int checking(int a, short b, signed char c)
14 return (a < 0 && b < 0 && c < 0);
17 int main (void)
19 ffi_cif cif;
20 ffi_type *args[MAX_ARGS];
21 void *values[MAX_ARGS];
22 ffi_arg rint;
24 signed int si;
25 signed short ss;
26 signed char sc;
28 args[0] = &ffi_type_sint;
29 values[0] = &si;
30 args[1] = &ffi_type_sshort;
31 values[1] = &ss;
32 args[2] = &ffi_type_schar;
33 values[2] = &sc;
35 /* Initialize the cif */
36 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
37 &ffi_type_sint, args) == FFI_OK);
39 si = -6;
40 ss = -12;
41 sc = -1;
43 checking (si, ss, sc);
45 ffi_call(&cif, FFI_FN(checking), &rint, values);
47 printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));
49 CHECK(rint != 0);
51 exit (0);