diff options
author | tduehr <tduehr@gmail.com> | 2015-03-19 16:44:33 -0700 |
---|---|---|
committer | tduehr <tduehr@gmail.com> | 2015-06-17 09:01:47 -0500 |
commit | e9d07620ae8ac090863998d22ab7ca0db9cd1e89 (patch) | |
tree | ba0c75a8e11e88123926cb9817a3bb0a7c1b157b /ext/ffi_c/libffi/testsuite/libffi.call/many2.c | |
parent | 194784d60f53e242a8aab88c216126785dc047dd (diff) | |
download | ffi-libffi-3.2.1.tar.gz |
update libffilibffi-3.2.1
Diffstat (limited to 'ext/ffi_c/libffi/testsuite/libffi.call/many2.c')
-rw-r--r-- | ext/ffi_c/libffi/testsuite/libffi.call/many2.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ext/ffi_c/libffi/testsuite/libffi.call/many2.c b/ext/ffi_c/libffi/testsuite/libffi.call/many2.c new file mode 100644 index 0000000..1c85746 --- /dev/null +++ b/ext/ffi_c/libffi/testsuite/libffi.call/many2.c @@ -0,0 +1,57 @@ +/* Area: ffi_call + Purpose: Check uint8_t arguments. + Limitations: none. + PR: PR45677. + Originator: Dan Witte <dwitte@gmail.com> 20100916 */ + +/* { dg-do run } */ + +#include "ffitest.h" + +#define NARGS 7 + +typedef unsigned char u8; + +#ifdef __GNUC__ +__attribute__((noinline)) +#endif +uint8_t +foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d, + uint8_t e, uint8_t f, uint8_t g) +{ + return a + b + c + d + e + f + g; +} + +uint8_t ABI_ATTR +bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d, + uint8_t e, uint8_t f, uint8_t g) +{ + return foo (a, b, c, d, e, f, g); +} + +int +main (void) +{ + ffi_type *ffitypes[NARGS]; + int i; + ffi_cif cif; + ffi_arg result = 0; + uint8_t args[NARGS]; + void *argptrs[NARGS]; + + for (i = 0; i < NARGS; ++i) + ffitypes[i] = &ffi_type_uint8; + + CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS, + &ffi_type_uint8, ffitypes) == FFI_OK); + + for (i = 0; i < NARGS; ++i) + { + args[i] = i; + argptrs[i] = &args[i]; + } + ffi_call (&cif, FFI_FN (bar), &result, argptrs); + + CHECK (result == 21); + return 0; +} |