diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-26 19:56:22 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-26 19:56:22 +0000 |
commit | d3eb23fbe92790268582002b677110fc2bbd449c (patch) | |
tree | 46d3d81e265f2f30ae68f0c9b3ef0bd546515080 /libffi/testsuite | |
parent | 18c5dc56d9dd2914aab770bbac1c7eec0df29307 (diff) | |
download | gcc-d3eb23fbe92790268582002b677110fc2bbd449c.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104660 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi/testsuite')
-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 94636a230ed..fb81d7d7fd0 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); |