diff options
author | Richard Henderson <rth@redhat.com> | 2015-01-12 08:19:59 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2015-01-12 08:19:59 -0800 |
commit | b1760f7f915a36ee9b4636fb54719c9b3ae59356 (patch) | |
tree | 1a64d747b069bdebf651d856989dd40a54daf0cc /libffi/testsuite/libffi.complex/return_complex.inc | |
parent | 62e22fcb7985349b93646b86351033e1fb09c46c (diff) |
Merge libffi to upstream commit c82cc159426d8d4402375fa1ae3f045b9cf82e16
From-SVN: r219477
Diffstat (limited to 'libffi/testsuite/libffi.complex/return_complex.inc')
-rw-r--r-- | libffi/testsuite/libffi.complex/return_complex.inc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libffi/testsuite/libffi.complex/return_complex.inc b/libffi/testsuite/libffi.complex/return_complex.inc new file mode 100644 index 00000000000..8bf0c1fbab8 --- /dev/null +++ b/libffi/testsuite/libffi.complex/return_complex.inc @@ -0,0 +1,37 @@ +/* -*-c-*- */ +#include "ffitest.h" +#include <complex.h> + +static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c) +{ + printf ("%f,%fi\n", T_CONV creal (c), T_CONV cimag (c)); + return 2 * c; +} +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + _Complex T_C_TYPE c, rc, rc2; + T_C_TYPE cr, ci; + + args[0] = &T_FFI_TYPE; + values[0] = &c; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + &T_FFI_TYPE, args) == FFI_OK); + + for (cr = -127.0; cr < 127; cr++) + { + ci = 1000.0 - cr; + c = cr + ci * I; + ffi_call(&cif, FFI_FN(return_c), &rc, values); + rc2 = return_c(c); + printf ("%f,%fi vs %f,%fi\n", + T_CONV creal (rc), T_CONV cimag (rc), + T_CONV creal (rc2), T_CONV cimag (rc2)); + CHECK(rc == 2 * c); + } + exit(0); +} |