diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-12 16:19:59 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-12 16:19:59 +0000 |
commit | 89d8a412de548b218cf7c967e65ad98bceb1ed4e (patch) | |
tree | 1a64d747b069bdebf651d856989dd40a54daf0cc /libffi/testsuite/libffi.complex/complex.inc | |
parent | b34b273b07f29735c2db4754deef3392b5e563aa (diff) | |
download | gcc-89d8a412de548b218cf7c967e65ad98bceb1ed4e.tar.gz |
Merge libffi to upstream commit c82cc159426d8d4402375fa1ae3f045b9cf82e16
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219477 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi/testsuite/libffi.complex/complex.inc')
-rw-r--r-- | libffi/testsuite/libffi.complex/complex.inc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libffi/testsuite/libffi.complex/complex.inc b/libffi/testsuite/libffi.complex/complex.inc new file mode 100644 index 00000000000..515ae3e60de --- /dev/null +++ b/libffi/testsuite/libffi.complex/complex.inc @@ -0,0 +1,51 @@ +/* -*-c-*-*/ +#include "ffitest.h" +#include <complex.h> + +static _Complex T_C_TYPE f_complex(_Complex T_C_TYPE c, int x, int *py) +{ + c = -(2 * creal (c)) + (cimag (c) + 1)* I; + *py += x; + + return c; +} + +int main (void) +{ + ffi_cif cif; + ffi_type *args[MAX_ARGS]; + void *values[MAX_ARGS]; + + _Complex T_C_TYPE tc_arg; + _Complex T_C_TYPE tc_result; + int tc_int_arg_x; + int tc_y; + int *tc_ptr_arg_y = &tc_y; + + args[0] = &T_FFI_TYPE; + args[1] = &ffi_type_sint; + args[2] = &ffi_type_pointer; + values[0] = &tc_arg; + values[1] = &tc_int_arg_x; + values[2] = &tc_ptr_arg_y; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, + &T_FFI_TYPE, args) == FFI_OK); + + tc_arg = 1 + 7 * I; + tc_int_arg_x = 1234; + tc_y = 9876; + ffi_call(&cif, FFI_FN(f_complex), &tc_result, values); + + printf ("%f,%fi %f,%fi, x %d 1234, y %d 11110\n", + T_CONV creal (tc_result), T_CONV cimag (tc_result), + T_CONV creal (2.0), T_CONV creal (8.0), tc_int_arg_x, tc_y); + + CHECK (creal (tc_result) == -2); + CHECK (cimag (tc_result) == 8); + CHECK (tc_int_arg_x == 1234); + CHECK (*tc_ptr_arg_y == 11110); + + exit(0); +} |