diff options
author | Tom Tromey <tromey@redhat.com> | 2005-09-26 19:56:22 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-09-26 19:56:22 +0000 |
commit | d674eb2f5c198a128ea401681e2f0937587e6369 (patch) | |
tree | 46d3d81e265f2f30ae68f0c9b3ef0bd546515080 /libffi/testsuite/libffi.call/float1.c | |
parent | 608af77dc182f5ef8a440bce31713ac11d5fa8d4 (diff) | |
download | gcc-d674eb2f5c198a128ea401681e2f0937587e6369.zip gcc-d674eb2f5c198a128ea401681e2f0937587e6369.tar.gz gcc-d674eb2f5c198a128ea401681e2f0937587e6369.tar.bz2 |
float1.c (value_type): New typedef.
* testsuite/libffi.call/float1.c (value_type): New typedef.
(CANARY): New define.
(main): Check for result buffer overflow.
* src/powerpc/linux64.S: Handle linux64 long double returns.
* src/powerpc/ffi.c (FLAG_RETURNS_128BITS): New constant.
(ffi_prep_cif_machdep): Handle linux64 long double returns.
From-SVN: r104660
Diffstat (limited to 'libffi/testsuite/libffi.call/float1.c')
-rw-r--r-- | libffi/testsuite/libffi.call/float1.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libffi/testsuite/libffi.call/float1.c b/libffi/testsuite/libffi.call/float1.c index 94636a2..fb81d7d 100644 --- a/libffi/testsuite/libffi.call/float1.c +++ b/libffi/testsuite/libffi.call/float1.c @@ -8,6 +8,14 @@ #include "ffitest.h" #include "float.h" +typedef union +{ + double d; + unsigned char c[sizeof (double)]; +} value_type; + +#define CANARY 0xba + static double dblit(float f) { return f/3.0; @@ -19,8 +27,8 @@ int main (void) ffi_type *args[MAX_ARGS]; void *values[MAX_ARGS]; float f; - double d; - + value_type result[2]; + int i; args[0] = &ffi_type_float; values[0] = &f; @@ -31,11 +39,19 @@ int main (void) f = 3.14159; - ffi_call(&cif, FFI_FN(dblit), &d, values); + /* Put a canary in the return array. This is a regression test for + a buffer overrun. */ + memset(result[1].c, CANARY, sizeof (double)); + + ffi_call(&cif, FFI_FN(dblit), &result[0].d, values); /* These are not always the same!! Check for a reasonable delta */ - CHECK(d - dblit(f) < DBL_EPSILON); + CHECK(result[0].d - dblit(f) < DBL_EPSILON); + + /* Check the canary. */ + for (i = 0; i < sizeof (double); ++i) + CHECK(result[1].c[i] == CANARY); exit(0); |