2018-02-18 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libffi / testsuite / libffi.call / many2.c
blob1c85746e4c4bc6488f8726a1efa8a15dccdddc04
1 /* Area: ffi_call
2 Purpose: Check uint8_t arguments.
3 Limitations: none.
4 PR: PR45677.
5 Originator: Dan Witte <dwitte@gmail.com> 20100916 */
7 /* { dg-do run } */
9 #include "ffitest.h"
11 #define NARGS 7
13 typedef unsigned char u8;
15 #ifdef __GNUC__
16 __attribute__((noinline))
17 #endif
18 uint8_t
19 foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
20 uint8_t e, uint8_t f, uint8_t g)
22 return a + b + c + d + e + f + g;
25 uint8_t ABI_ATTR
26 bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
27 uint8_t e, uint8_t f, uint8_t g)
29 return foo (a, b, c, d, e, f, g);
32 int
33 main (void)
35 ffi_type *ffitypes[NARGS];
36 int i;
37 ffi_cif cif;
38 ffi_arg result = 0;
39 uint8_t args[NARGS];
40 void *argptrs[NARGS];
42 for (i = 0; i < NARGS; ++i)
43 ffitypes[i] = &ffi_type_uint8;
45 CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS,
46 &ffi_type_uint8, ffitypes) == FFI_OK);
48 for (i = 0; i < NARGS; ++i)
50 args[i] = i;
51 argptrs[i] = &args[i];
53 ffi_call (&cif, FFI_FN (bar), &result, argptrs);
55 CHECK (result == 21);
56 return 0;