From 98a793fa36a4ab3ba24d059cb80a2891cdb940e1 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 15:20:36 -0700 Subject: [PATCH 1/8] testsuite: Common up the ifdef blocks for compiler-specific macros --- testsuite/libffi.call/ffitest.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 136a7a6b..7c0f8e4b 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -17,20 +17,14 @@ #define CHECK(x) !(x) ? (abort(), 1) : 0 -/* Define __UNUSED__ that also other compilers than gcc can run the tests. */ +/* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) #define __UNUSED__ __attribute__((__unused__)) +#define __FASTCALL__ __attribute__((fastcall)) #else #define __UNUSED__ -#endif - -/* Define __FASTCALL__ so that other compilers than gcc can run the tests. */ -#undef __FASTCALL__ -#if defined _MSC_VER #define __FASTCALL__ __fastcall -#else -#define __FASTCALL__ __attribute__((fastcall)) #endif /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a From bad8948346e9b8813023a0cc78a3b6eb8d9c14c6 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 15:16:18 -0700 Subject: [PATCH 2/8] testsuite: Introduce a __STDCALL__ compiler-specific macro Several tests want to use stdcall, which differs in syntax by compiler, so introduce a macro for it in ffitest.h. --- testsuite/libffi.call/closure_stdcall.c | 5 +---- testsuite/libffi.call/ffitest.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/testsuite/libffi.call/closure_stdcall.c b/testsuite/libffi.call/closure_stdcall.c index 871d576d..fd1e4b03 100644 --- a/testsuite/libffi.call/closure_stdcall.c +++ b/testsuite/libffi.call/closure_stdcall.c @@ -23,10 +23,7 @@ closure_test_stdcall(ffi_cif* cif __UNUSED__, void* resp, void** args, } -#ifndef _MSC_VER -#define __stdcall __attribute__((stdcall)) -#endif -typedef int (__stdcall *closure_test_type0)(int, int, int, int); +typedef int (__STDCALL__ *closure_test_type0)(int, int, int, int); int main (void) { diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 7c0f8e4b..2fc25357 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -21,9 +21,11 @@ #undef __UNUSED__ #if defined(__GNUC__) #define __UNUSED__ __attribute__((__unused__)) +#define __STDCALL__ __attribute__((stdcall)) #define __FASTCALL__ __attribute__((fastcall)) #else #define __UNUSED__ +#define __STDCALL__ __stdcall #define __FASTCALL__ __fastcall #endif From dfdb02cc869855d3b68571e5f7aa77ae8c9d254a Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 15:26:26 -0700 Subject: [PATCH 3/8] testsuite: Introduce a __THISCALL__ compiler-specific macro --- testsuite/libffi.call/closure_thiscall.c | 5 +---- testsuite/libffi.call/ffitest.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/testsuite/libffi.call/closure_thiscall.c b/testsuite/libffi.call/closure_thiscall.c index 12a0a637..8f7d2fae 100644 --- a/testsuite/libffi.call/closure_thiscall.c +++ b/testsuite/libffi.call/closure_thiscall.c @@ -23,10 +23,7 @@ closure_test_thiscall(ffi_cif* cif __UNUSED__, void* resp, void** args, } -#ifndef _MSC_VER -#define __thiscall __attribute__((thiscall)) -#endif -typedef int (__thiscall *closure_test_type0)(int, int, int, int); +typedef int (__THISCALL__ *closure_test_type0)(int, int, int, int); int main (void) { diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 2fc25357..19193758 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -22,10 +22,12 @@ #if defined(__GNUC__) #define __UNUSED__ __attribute__((__unused__)) #define __STDCALL__ __attribute__((stdcall)) +#define __THISCALL__ __attribute__((thiscall)) #define __FASTCALL__ __attribute__((fastcall)) #else #define __UNUSED__ #define __STDCALL__ __stdcall +#define __THISCALL__ __thiscall #define __FASTCALL__ __fastcall #endif From 5695ec1444c5323e48fe4314f8c8f027625e67df Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 16:04:58 -0700 Subject: [PATCH 4/8] testsuite: Factor out a function to run a matrix of tests This commons up code from libffi.call/call.exp and libffi.special/special.exp, unifies the optimization option matrix between the two, and makes it easier to add more axes to the matrix in the future. --- testsuite/lib/libffi.exp | 17 +++++++++++++++++ testsuite/libffi.call/call.exp | 15 +-------------- testsuite/libffi.special/special.exp | 11 +---------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index 1ac2c360..014e5206 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -273,6 +273,23 @@ proc libffi-dg-runtest { testcases default-extra-flags } { } } +proc run-many-tests { testcases extra_flags } { + global using_gcc + if { [string match $using_gcc "yes"] } { + set common "-W -Wall" + set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" } + } else { + # Assume we are using the vendor compiler. + set common "" + set optimizations { "" } + } + + set common [ concat $common $extra_flags ] + foreach opt $optimizations { + set options [ concat $common $opt ] + dg-runtest $testcases $options "" + } +} # Like check_conditional_xfail, but callable from a dg test. diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index c3346850..c1ad7375 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -19,20 +19,7 @@ libffi-init global srcdir subdir -if { [string match $using_gcc "yes"] } { - - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" "" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" "" - -} else { - - # Assume we are using the vendor compiler. - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" "" - -} +run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" dg-finish diff --git a/testsuite/libffi.special/special.exp b/testsuite/libffi.special/special.exp index f1a5fa6d..f7155bf4 100644 --- a/testsuite/libffi.special/special.exp +++ b/testsuite/libffi.special/special.exp @@ -19,17 +19,8 @@ libffi-init global srcdir subdir -global cxx_options - -set cxx_options " -shared-libgcc -lstdc++" - if { [string match $using_gcc "yes"] } { - - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O0 -W -Wall" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O2" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O3" - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-Os" - + run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] "-shared-libgcc -lstdc++" } dg-finish From 0d9cce8edb937bbe771a6cdd25f671edf06d2128 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 16:22:58 -0700 Subject: [PATCH 5/8] testsuite: ffitest.h: Parenthesize the CHECK macro --- testsuite/libffi.call/ffitest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 19193758..752fe553 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -15,7 +15,7 @@ #define MAX_ARGS 256 -#define CHECK(x) !(x) ? (abort(), 1) : 0 +#define CHECK(x) (!(x) ? (abort(), 1) : 0) /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ From 3f97cf3413c46caf2a79f32ac9cda4620972c2d7 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 16:53:42 -0700 Subject: [PATCH 6/8] testsuite: Unify the C and C++ testsuites These two testsuites differ only in the source file glob and a couple of additional compiler options; unify the remaining bits. --- testsuite/Makefile.am | 6 ++-- testsuite/libffi.call/call.exp | 3 ++ .../ffitestcxx.h | 0 .../unwindtest.cc | 0 .../unwindtest_ffi_call.cc | 0 testsuite/libffi.special/special.exp | 30 ------------------- 6 files changed, 6 insertions(+), 33 deletions(-) rename testsuite/{libffi.special => libffi.call}/ffitestcxx.h (100%) rename testsuite/{libffi.special => libffi.call}/unwindtest.cc (100%) rename testsuite/{libffi.special => libffi.call}/unwindtest_ffi_call.cc (100%) delete mode 100644 testsuite/libffi.special/special.exp diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index edc6e61a..44738c9e 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -82,9 +82,9 @@ libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ libffi.call/return_sc.c libffi.call/struct7.c \ libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \ -libffi.call/cls_7_1_byte.c libffi.special/unwindtest.cc \ -libffi.special/special.exp libffi.special/unwindtest_ffi_call.cc \ -libffi.special/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \ +libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \ +libffi.call/unwindtest_ffi_call.cc \ +libffi.call/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \ lib/libffi.exp libffi.call/cls_struct_va1.c \ libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index c1ad7375..90e400f6 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -20,6 +20,9 @@ libffi-init global srcdir subdir run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" +if { [string match $using_gcc "yes"] } { + run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] "-shared-libgcc -lstdc++" +} dg-finish diff --git a/testsuite/libffi.special/ffitestcxx.h b/testsuite/libffi.call/ffitestcxx.h similarity index 100% rename from testsuite/libffi.special/ffitestcxx.h rename to testsuite/libffi.call/ffitestcxx.h diff --git a/testsuite/libffi.special/unwindtest.cc b/testsuite/libffi.call/unwindtest.cc similarity index 100% rename from testsuite/libffi.special/unwindtest.cc rename to testsuite/libffi.call/unwindtest.cc diff --git a/testsuite/libffi.special/unwindtest_ffi_call.cc b/testsuite/libffi.call/unwindtest_ffi_call.cc similarity index 100% rename from testsuite/libffi.special/unwindtest_ffi_call.cc rename to testsuite/libffi.call/unwindtest_ffi_call.cc diff --git a/testsuite/libffi.special/special.exp b/testsuite/libffi.special/special.exp deleted file mode 100644 index f7155bf4..00000000 --- a/testsuite/libffi.special/special.exp +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2003, 2006, 2009, 2010 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING3. If not see -# . - -dg-init -libffi-init - -global srcdir subdir - -if { [string match $using_gcc "yes"] } { - run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] "-shared-libgcc -lstdc++" -} - -dg-finish - -# Local Variables: -# tcl-indent-level:4 -# End: From 4d4d368e5a55d9443c4c53b1b70d58ab6d8c941c Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 17:02:05 -0700 Subject: [PATCH 7/8] testsuite: Replace ffitestcxx.h with ffitest.h ffitest.h contains a superset of the functionality of ffitestcxx.h; make the C++ tests include ffitest.h instead, and remove ffitestcxx.h. --- testsuite/Makefile.am | 2 +- testsuite/libffi.call/ffitestcxx.h | 55 -------------------- testsuite/libffi.call/unwindtest.cc | 10 +--- testsuite/libffi.call/unwindtest_ffi_call.cc | 2 +- 4 files changed, 3 insertions(+), 66 deletions(-) delete mode 100644 testsuite/libffi.call/ffitestcxx.h diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 44738c9e..3cb876b0 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -84,7 +84,7 @@ libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \ libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \ libffi.call/unwindtest_ffi_call.cc \ -libffi.call/ffitestcxx.h lib/wrapper.exp lib/target-libpath.exp \ +lib/wrapper.exp lib/target-libpath.exp \ lib/libffi.exp libffi.call/cls_struct_va1.c \ libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ diff --git a/testsuite/libffi.call/ffitestcxx.h b/testsuite/libffi.call/ffitestcxx.h deleted file mode 100644 index c6da7efd..00000000 --- a/testsuite/libffi.call/ffitestcxx.h +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include -#include "fficonfig.h" - -#define MAX_ARGS 256 - - -/* Define __UNUSED__ that also other compilers than gcc can run the tests. */ -#undef __UNUSED__ -#if defined(__GNUC__) -#define __UNUSED__ __attribute__((__unused__)) -#else -#define __UNUSED__ -#endif - -#define CHECK(x) (!(x) ? abort() : (void)0) - -/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a - file open. */ -#ifdef HAVE_MMAP_ANON -# undef HAVE_MMAP_DEV_ZERO - -# include -# ifndef MAP_FAILED -# define MAP_FAILED -1 -# endif -# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) -# define MAP_ANONYMOUS MAP_ANON -# endif -# define USING_MMAP - -#endif - -#ifdef HAVE_MMAP_DEV_ZERO - -# include -# ifndef MAP_FAILED -# define MAP_FAILED -1 -# endif -# define USING_MMAP - -#endif - - -/* MinGW kludge. */ -#ifdef _WIN64 -#define PRIdLL "I64d" -#define PRIuLL "I64u" -#else -#define PRIdLL "lld" -#define PRIuLL "llu" -#endif - diff --git a/testsuite/libffi.call/unwindtest.cc b/testsuite/libffi.call/unwindtest.cc index a78f4e72..02c34d85 100644 --- a/testsuite/libffi.call/unwindtest.cc +++ b/testsuite/libffi.call/unwindtest.cc @@ -6,15 +6,7 @@ /* { dg-do run } */ -#include "ffitestcxx.h" - -#if defined HAVE_STDINT_H -#include -#endif - -#if defined HAVE_INTTYPES_H -#include -#endif +#include "ffitest.h" void closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, diff --git a/testsuite/libffi.call/unwindtest_ffi_call.cc b/testsuite/libffi.call/unwindtest_ffi_call.cc index 57191f2a..ec611647 100644 --- a/testsuite/libffi.call/unwindtest_ffi_call.cc +++ b/testsuite/libffi.call/unwindtest_ffi_call.cc @@ -6,7 +6,7 @@ /* { dg-do run } */ -#include "ffitestcxx.h" +#include "ffitest.h" static int checking(int a __UNUSED__, short b __UNUSED__, signed char c __UNUSED__) From e48918ecf876bc85d040fc50a232059c566553a8 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 16 Mar 2014 20:29:27 -0700 Subject: [PATCH 8/8] testsuite: Add ABIs to the test matrix; unify tests across ABIs This eliminates all the *_win32.c tests in favor of the tests they were branched from, and expands test coverage to run many more tests on stdcall, thiscall, and fastcall. This same mechanism also supports testing any other target that has multiple ABIs. --- testsuite/Makefile.am | 24 ++++--- testsuite/lib/libffi.exp | 29 +++++++- testsuite/libffi.call/ffitest.h | 5 ++ testsuite/libffi.call/many.c | 16 +---- testsuite/libffi.call/many2.c | 4 +- testsuite/libffi.call/many2_win32.c | 63 ----------------- testsuite/libffi.call/many_win32.c | 63 ----------------- testsuite/libffi.call/strlen.c | 4 +- .../{fastthis1_win32.c => strlen2.c} | 15 ++--- testsuite/libffi.call/strlen2_win32.c | 44 ------------ .../{fastthis2_win32.c => strlen3.c} | 15 ++--- .../{fastthis3_win32.c => strlen4.c} | 15 ++--- testsuite/libffi.call/strlen_win32.c | 44 ------------ testsuite/libffi.call/struct1.c | 4 +- testsuite/libffi.call/struct1_win32.c | 67 ------------------- testsuite/libffi.call/struct2.c | 4 +- testsuite/libffi.call/struct2_win32.c | 67 ------------------- testsuite/libffi.call/struct3.c | 4 +- testsuite/libffi.call/struct4.c | 4 +- testsuite/libffi.call/struct5.c | 4 +- testsuite/libffi.call/struct6.c | 4 +- testsuite/libffi.call/struct7.c | 4 +- testsuite/libffi.call/struct8.c | 4 +- testsuite/libffi.call/struct9.c | 4 +- testsuite/libffi.call/unwindtest.cc | 2 +- 25 files changed, 90 insertions(+), 423 deletions(-) delete mode 100644 testsuite/libffi.call/many2_win32.c delete mode 100644 testsuite/libffi.call/many_win32.c rename testsuite/libffi.call/{fastthis1_win32.c => strlen2.c} (62%) delete mode 100644 testsuite/libffi.call/strlen2_win32.c rename testsuite/libffi.call/{fastthis2_win32.c => strlen3.c} (62%) rename testsuite/libffi.call/{fastthis3_win32.c => strlen4.c} (65%) delete mode 100644 testsuite/libffi.call/strlen_win32.c delete mode 100644 testsuite/libffi.call/struct1_win32.c delete mode 100644 testsuite/libffi.call/struct2_win32.c diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 3cb876b0..912e8e18 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -20,7 +20,7 @@ CLEANFILES = *.exe core* *.log *.sum EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \ libffi.call/cls_align_longdouble_split.c \ libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \ -libffi.call/closure_fn1.c libffi.call/many2_win32.c \ +libffi.call/closure_fn1.c \ libffi.call/return_ul.c libffi.call/cls_align_double.c \ libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \ libffi.call/cls_64byte.c libffi.call/nested_struct7.c \ @@ -30,7 +30,7 @@ libffi.call/cls_multi_ushort.c libffi.call/struct3.c \ libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \ libffi.call/struct8.c libffi.call/nested_struct8.c \ libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \ -libffi.call/fastthis2_win32.c libffi.call/cls_pointer.c \ +libffi.call/cls_pointer.c \ libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \ libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \ @@ -50,12 +50,12 @@ libffi.call/closure_stdcall.c libffi.call/cls_align_uint16.c \ libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \ libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \ libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \ -libffi.call/cls_sshort.c libffi.call/many_win32.c \ +libffi.call/cls_sshort.c \ libffi.call/nested_struct.c libffi.call/cls_20byte.c \ libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \ libffi.call/return_uc.c libffi.call/closure_thiscall.c \ libffi.call/cls_18byte.c libffi.call/cls_8byte.c \ -libffi.call/promotion.c libffi.call/struct1_win32.c \ +libffi.call/promotion.c \ libffi.call/return_dbl.c libffi.call/cls_24byte.c \ libffi.call/struct4.c libffi.call/cls_6byte.c \ libffi.call/cls_align_uint32.c libffi.call/float.c \ @@ -63,7 +63,7 @@ libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \ libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \ libffi.call/cls_align_float.c libffi.call/return_fl1.c \ libffi.call/nested_struct10.c libffi.call/nested_struct5.c \ -libffi.call/fastthis1_win32.c libffi.call/cls_align_sint64.c \ +libffi.call/cls_align_sint64.c \ libffi.call/stret_large2.c libffi.call/return_sl.c \ libffi.call/closure_fn0.c libffi.call/cls_5byte.c \ libffi.call/cls_2byte.c libffi.call/float2.c \ @@ -75,13 +75,13 @@ libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \ libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \ libffi.call/struct1.c libffi.call/nested_struct9.c \ libffi.call/huge_struct.c libffi.call/problem1.c \ -libffi.call/float4.c libffi.call/fastthis3_win32.c \ -libffi.call/return_ldl.c libffi.call/strlen2_win32.c \ -libffi.call/closure_fn5.c libffi.call/struct2_win32.c \ +libffi.call/float4.c \ +libffi.call/return_ldl.c \ +libffi.call/closure_fn5.c \ libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \ libffi.call/return_sc.c libffi.call/struct7.c \ libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \ -libffi.call/strlen_win32.c libffi.call/cls_6_1_byte.c \ +libffi.call/cls_6_1_byte.c \ libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \ libffi.call/unwindtest_ffi_call.cc \ lib/wrapper.exp lib/target-libpath.exp \ @@ -90,5 +90,7 @@ libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \ libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \ libffi.call/nested_struct11.c libffi.call/uninitialized.c \ libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \ -libffi.call/va_struct3.c - +libffi.call/va_struct3.c \ +libffi.call/strlen2.c \ +libffi.call/strlen3.c \ +libffi.call/strlen4.c diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index 014e5206..28d60369 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -284,10 +284,33 @@ proc run-many-tests { testcases extra_flags } { set optimizations { "" } } + set targetabis { "" } + if [string match $using_gcc "yes"] { + if [istarget "i?86-*-*"] { + set targetabis { + "" + "-DABI_NUM=FFI_STDCALL -DABI_ATTR=__STDCALL__" + "-DABI_NUM=FFI_THISCALL -DABI_ATTR=__THISCALL__" + "-DABI_NUM=FFI_FASTCALL -DABI_ATTR=__FASTCALL__" + } + } + } + set common [ concat $common $extra_flags ] - foreach opt $optimizations { - set options [ concat $common $opt ] - dg-runtest $testcases $options "" + foreach test $testcases { + set testname [file tail $test] + if [search_for $test "ABI_NUM"] { + set abis $targetabis + } else { + set abis { "" } + } + foreach opt $optimizations { + foreach abi $abis { + set options [concat $common $opt $abi] + verbose "Testing $testname, $options" 1 + dg-test $test $options "" + } + } } } diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 752fe553..316e5c0f 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -31,6 +31,11 @@ #define __FASTCALL__ __fastcall #endif +#ifndef ABI_NUM +#define ABI_NUM FFI_DEFAULT_ABI +#define ABI_ATTR +#endif + /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a file open. */ #ifdef HAVE_MMAP_ANON diff --git a/testsuite/libffi.call/many.c b/testsuite/libffi.call/many.c index 5447664f..336968c7 100644 --- a/testsuite/libffi.call/many.c +++ b/testsuite/libffi.call/many.c @@ -11,19 +11,7 @@ #include #include -static float many(float f1, - float f2, - float f3, - float f4, - float f5, - float f6, - float f7, - float f8, - float f9, - float f10, - float f11, - float f12, - float f13) +static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13) { #if 0 printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n", @@ -52,7 +40,7 @@ int main (void) } /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 13, &ffi_type_float, args) == FFI_OK); ffi_call(&cif, FFI_FN(many), &f, values); diff --git a/testsuite/libffi.call/many2.c b/testsuite/libffi.call/many2.c index 98eac601..1c85746e 100644 --- a/testsuite/libffi.call/many2.c +++ b/testsuite/libffi.call/many2.c @@ -22,7 +22,7 @@ foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d, return a + b + c + d + e + f + g; } -uint8_t +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) { @@ -42,7 +42,7 @@ main (void) for (i = 0; i < NARGS; ++i) ffitypes[i] = &ffi_type_uint8; - CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, NARGS, + CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS, &ffi_type_uint8, ffitypes) == FFI_OK); for (i = 0; i < NARGS; ++i) diff --git a/testsuite/libffi.call/many2_win32.c b/testsuite/libffi.call/many2_win32.c deleted file mode 100644 index de6f9bb1..00000000 --- a/testsuite/libffi.call/many2_win32.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Area: ffi_call - Purpose: Check stdcall many call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ - -#include "ffitest.h" -#include - -static float __attribute__((fastcall)) fastcall_many(float f1, - float f2, - float f3, - float f4, - float f5, - float f6, - float f7, - float f8, - float f9, - float f10, - float f11, - float f12, - float f13) -{ - return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - float fa[13]; - float f, ff; - unsigned long ul; - - for (ul = 0; ul < 13; ul++) - { - args[ul] = &ffi_type_float; - values[ul] = &fa[ul]; - fa[ul] = (float) ul; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 13, - &ffi_type_float, args) == FFI_OK); - - ff = fastcall_many(fa[0], fa[1], - fa[2], fa[3], - fa[4], fa[5], - fa[6], fa[7], - fa[8], fa[9], - fa[10], fa[11], fa[12]); - - ffi_call(&cif, FFI_FN(fastcall_many), &f, values); - - if (f - ff < FLT_EPSILON) - printf("fastcall many arg tests ok!\n"); - else - CHECK(0); - exit(0); -} diff --git a/testsuite/libffi.call/many_win32.c b/testsuite/libffi.call/many_win32.c deleted file mode 100644 index e696c93a..00000000 --- a/testsuite/libffi.call/many_win32.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Area: ffi_call - Purpose: Check stdcall many call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ - -#include "ffitest.h" -#include - -static float __attribute__((stdcall)) stdcall_many(float f1, - float f2, - float f3, - float f4, - float f5, - float f6, - float f7, - float f8, - float f9, - float f10, - float f11, - float f12, - float f13) -{ - return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[13]; - void *values[13]; - float fa[13]; - float f, ff; - unsigned long ul; - - for (ul = 0; ul < 13; ul++) - { - args[ul] = &ffi_type_float; - values[ul] = &fa[ul]; - fa[ul] = (float) ul; - } - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 13, - &ffi_type_float, args) == FFI_OK); - - ff = stdcall_many(fa[0], fa[1], - fa[2], fa[3], - fa[4], fa[5], - fa[6], fa[7], - fa[8], fa[9], - fa[10], fa[11], fa[12]); - - ffi_call(&cif, FFI_FN(stdcall_many), &f, values); - - if (f - ff < FLT_EPSILON) - printf("stdcall many arg tests ok!\n"); - else - CHECK(0); - exit(0); -} diff --git a/testsuite/libffi.call/strlen.c b/testsuite/libffi.call/strlen.c index 3de45de7..35b70ea4 100644 --- a/testsuite/libffi.call/strlen.c +++ b/testsuite/libffi.call/strlen.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -static size_t my_strlen(char *s) +static size_t ABI_ATTR my_strlen(char *s) { return (strlen(s)); } @@ -24,7 +24,7 @@ int main (void) values[0] = (void*) &s; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ffi_type_sint, args) == FFI_OK); s = "a"; diff --git a/testsuite/libffi.call/fastthis1_win32.c b/testsuite/libffi.call/strlen2.c similarity index 62% rename from testsuite/libffi.call/fastthis1_win32.c rename to testsuite/libffi.call/strlen2.c index 2bac3b27..96282bc0 100644 --- a/testsuite/libffi.call/fastthis1_win32.c +++ b/testsuite/libffi.call/strlen2.c @@ -1,14 +1,14 @@ /* Area: ffi_call - Purpose: Check fastcall fct call on X86_WIN32 systems. + Purpose: Check strlen function call with additional arguments. Limitations: none. PR: none. Originator: From the original ffitest.c */ -/* { dg-do run { target i?86-*-* } } */ +/* { dg-do run } */ #include "ffitest.h" -static size_t __FASTCALL__ my_fastcall_f(char *s, float a) +static size_t ABI_ATTR my_f(char *s, float a) { return (size_t) ((int) strlen(s) + (int) a); } @@ -27,24 +27,23 @@ int main (void) values[1] = (void*) &v2; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ffi_type_sint, args) == FFI_OK); s = "a"; v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 1); s = "1234567"; v2 = -1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 6); s = "1234567890123456789012345"; v2 = 1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 26); - printf("fastcall fct1 tests passed\n"); exit(0); } diff --git a/testsuite/libffi.call/strlen2_win32.c b/testsuite/libffi.call/strlen2_win32.c deleted file mode 100644 index 465b6c3d..00000000 --- a/testsuite/libffi.call/strlen2_win32.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: ffi_call - Purpose: Check fastcall strlen call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ - -#include "ffitest.h" - -static size_t __FASTCALL__ my_fastcall_strlen(char *s) -{ - return (strlen(s)); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - args[0] = &ffi_type_pointer; - values[0] = (void*) &s; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 7); - - s = "1234567890123456789012345"; - ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values); - CHECK(rint == 25); - - printf("fastcall strlen tests passed\n"); - exit(0); -} diff --git a/testsuite/libffi.call/fastthis2_win32.c b/testsuite/libffi.call/strlen3.c similarity index 62% rename from testsuite/libffi.call/fastthis2_win32.c rename to testsuite/libffi.call/strlen3.c index e78018ce..beba86e9 100644 --- a/testsuite/libffi.call/fastthis2_win32.c +++ b/testsuite/libffi.call/strlen3.c @@ -1,14 +1,14 @@ /* Area: ffi_call - Purpose: Check fastcall fct call on X86_WIN32 systems. + Purpose: Check strlen function call with additional arguments. Limitations: none. PR: none. Originator: From the original ffitest.c */ -/* { dg-do run { target i?86-*-* } } */ +/* { dg-do run } */ #include "ffitest.h" -static size_t __FASTCALL__ my_fastcall_f(float a, char *s) +static size_t ABI_ATTR my_f(float a, char *s) { return (size_t) ((int) strlen(s) + (int) a); } @@ -27,24 +27,23 @@ int main (void) values[0] = (void*) &v2; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 2, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ffi_type_sint, args) == FFI_OK); s = "a"; v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 1); s = "1234567"; v2 = -1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 6); s = "1234567890123456789012345"; v2 = 1.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 26); - printf("fastcall fct2 tests passed\n"); exit(0); } diff --git a/testsuite/libffi.call/fastthis3_win32.c b/testsuite/libffi.call/strlen4.c similarity index 65% rename from testsuite/libffi.call/fastthis3_win32.c rename to testsuite/libffi.call/strlen4.c index c3af8011..d5d42b4f 100644 --- a/testsuite/libffi.call/fastthis3_win32.c +++ b/testsuite/libffi.call/strlen4.c @@ -1,14 +1,14 @@ /* Area: ffi_call - Purpose: Check fastcall f call on X86_WIN32 systems. + Purpose: Check strlen function call with additional arguments. Limitations: none. PR: none. Originator: From the original ffitest.c */ -/* { dg-do run { target i?86-*-* } } */ +/* { dg-do run } */ #include "ffitest.h" -static size_t __FASTCALL__ my_fastcall_f(float a, char *s, int i) +static size_t ABI_ATTR my_f(float a, char *s, int i) { return (size_t) ((int) strlen(s) + (int) a + i); } @@ -30,27 +30,26 @@ int main (void) values[0] = (void*) &v2; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 3, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 3, &ffi_type_sint, args) == FFI_OK); s = "a"; v1 = 1; v2 = 0.0; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 2); s = "1234567"; v2 = -1.0; v1 = -2; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 4); s = "1234567890123456789012345"; v2 = 1.0; v1 = 2; - ffi_call(&cif, FFI_FN(my_fastcall_f), &rint, values); + ffi_call(&cif, FFI_FN(my_f), &rint, values); CHECK(rint == 28); - printf("fastcall fct3 tests passed\n"); exit(0); } diff --git a/testsuite/libffi.call/strlen_win32.c b/testsuite/libffi.call/strlen_win32.c deleted file mode 100644 index 2a14b967..00000000 --- a/testsuite/libffi.call/strlen_win32.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Area: ffi_call - Purpose: Check stdcall strlen call on X86_WIN32 systems. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ - -#include "ffitest.h" - -static size_t __attribute__((stdcall)) my_stdcall_strlen(char *s) -{ - return (strlen(s)); -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_arg rint; - char *s; - args[0] = &ffi_type_pointer; - values[0] = (void*) &s; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 1, - &ffi_type_sint, args) == FFI_OK); - - s = "a"; - ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values); - CHECK(rint == 1); - - s = "1234567"; - ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values); - CHECK(rint == 7); - - s = "1234567890123456789012345"; - ffi_call(&cif, FFI_FN(my_stdcall_strlen), &rint, values); - CHECK(rint == 25); - - printf("stdcall strlen tests passed\n"); - exit(0); -} diff --git a/testsuite/libffi.call/struct1.c b/testsuite/libffi.call/struct1.c index bfc23f64..c13e23f8 100644 --- a/testsuite/libffi.call/struct1.c +++ b/testsuite/libffi.call/struct1.c @@ -14,7 +14,7 @@ typedef struct unsigned int ui; } test_structure_1; -static test_structure_1 struct1(test_structure_1 ts) +static test_structure_1 ABI_ATTR struct1(test_structure_1 ts) { ts.uc++; ts.d--; @@ -50,7 +50,7 @@ int main (void) values[0] = &ts1_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts1_type, args) == FFI_OK); ts1_arg.uc = '\x01'; diff --git a/testsuite/libffi.call/struct1_win32.c b/testsuite/libffi.call/struct1_win32.c deleted file mode 100644 index 6decf02b..00000000 --- a/testsuite/libffi.call/struct1_win32.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures with fastcall/thiscall convention. - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ -#include "ffitest.h" - -typedef struct -{ - unsigned char uc; - double d; - unsigned int ui; -} test_structure_1; - -static test_structure_1 __FASTCALL__ struct1(test_structure_1 ts) -{ - ts.uc++; - ts.d--; - ts.ui++; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - ffi_type ts1_type; - ffi_type *ts1_type_elements[4]; - - test_structure_1 ts1_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_1 *ts1_result = - (test_structure_1 *) malloc (sizeof(test_structure_1)); - - ts1_type.size = 0; - ts1_type.alignment = 0; - ts1_type.type = FFI_TYPE_STRUCT; - ts1_type.elements = ts1_type_elements; - ts1_type_elements[0] = &ffi_type_uchar; - ts1_type_elements[1] = &ffi_type_double; - ts1_type_elements[2] = &ffi_type_uint; - ts1_type_elements[3] = NULL; - - args[0] = &ts1_type; - values[0] = &ts1_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, - &ts1_type, args) == FFI_OK); - - ts1_arg.uc = '\x01'; - ts1_arg.d = 3.14159; - ts1_arg.ui = 555; - - ffi_call(&cif, FFI_FN(struct1), ts1_result, values); - - CHECK(ts1_result->ui == 556); - CHECK(ts1_result->d == 3.14159 - 1); - - free (ts1_result); - exit(0); -} diff --git a/testsuite/libffi.call/struct2.c b/testsuite/libffi.call/struct2.c index d85385e7..5077a5ee 100644 --- a/testsuite/libffi.call/struct2.c +++ b/testsuite/libffi.call/struct2.c @@ -13,7 +13,7 @@ typedef struct double d2; } test_structure_2; -static test_structure_2 struct2(test_structure_2 ts) +static test_structure_2 ABI_ATTR struct2(test_structure_2 ts) { ts.d1--; ts.d2--; @@ -46,7 +46,7 @@ int main (void) values[0] = &ts2_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts2_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts2_type, args) == FFI_OK); ts2_arg.d1 = 5.55; ts2_arg.d2 = 6.66; diff --git a/testsuite/libffi.call/struct2_win32.c b/testsuite/libffi.call/struct2_win32.c deleted file mode 100644 index 17a45196..00000000 --- a/testsuite/libffi.call/struct2_win32.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Area: ffi_call - Purpose: Check structures in fastcall/stdcall function - Limitations: none. - PR: none. - Originator: From the original ffitest.c */ - -/* { dg-do run { target i?86-*-* } } */ -#include "ffitest.h" - -typedef struct -{ - double d1; - double d2; -} test_structure_2; - -static test_structure_2 __FASTCALL__ struct2(test_structure_2 ts) -{ - ts.d1--; - ts.d2--; - - return ts; -} - -int main (void) -{ - ffi_cif cif; - ffi_type *args[MAX_ARGS]; - void *values[MAX_ARGS]; - test_structure_2 ts2_arg; - ffi_type ts2_type; - ffi_type *ts2_type_elements[3]; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - - ts2_type.size = 0; - ts2_type.alignment = 0; - ts2_type.type = FFI_TYPE_STRUCT; - ts2_type.elements = ts2_type_elements; - ts2_type_elements[0] = &ffi_type_double; - ts2_type_elements[1] = &ffi_type_double; - ts2_type_elements[2] = NULL; - - args[0] = &ts2_type; - values[0] = &ts2_arg; - - /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1, &ts2_type, args) == FFI_OK); - - ts2_arg.d1 = 5.55; - ts2_arg.d2 = 6.66; - - printf ("%g\n", ts2_arg.d1); - printf ("%g\n", ts2_arg.d2); - - ffi_call(&cif, FFI_FN(struct2), ts2_result, values); - - printf ("%g\n", ts2_result->d1); - printf ("%g\n", ts2_result->d2); - - CHECK(ts2_result->d1 == 5.55 - 1); - CHECK(ts2_result->d2 == 6.66 - 1); - - free (ts2_result); - exit(0); -} diff --git a/testsuite/libffi.call/struct3.c b/testsuite/libffi.call/struct3.c index de883c26..7eba0ead 100644 --- a/testsuite/libffi.call/struct3.c +++ b/testsuite/libffi.call/struct3.c @@ -12,7 +12,7 @@ typedef struct int si; } test_structure_3; -static test_structure_3 struct3(test_structure_3 ts) +static test_structure_3 ABI_ATTR struct3(test_structure_3 ts) { ts.si = -(ts.si*2); @@ -43,7 +43,7 @@ int main (void) values[0] = &ts3_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts3_type, args) == FFI_OK); ts3_arg.si = -123; diff --git a/testsuite/libffi.call/struct4.c b/testsuite/libffi.call/struct4.c index 48e03495..66a9551d 100644 --- a/testsuite/libffi.call/struct4.c +++ b/testsuite/libffi.call/struct4.c @@ -14,7 +14,7 @@ typedef struct unsigned ui3; } test_structure_4; -static test_structure_4 struct4(test_structure_4 ts) +static test_structure_4 ABI_ATTR struct4(test_structure_4 ts) { ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3; @@ -48,7 +48,7 @@ int main (void) values[0] = &ts4_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts4_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts4_type, args) == FFI_OK); ts4_arg.ui1 = 2; ts4_arg.ui2 = 3; diff --git a/testsuite/libffi.call/struct5.c b/testsuite/libffi.call/struct5.c index 28b1f0c4..23e2a3f7 100644 --- a/testsuite/libffi.call/struct5.c +++ b/testsuite/libffi.call/struct5.c @@ -12,7 +12,7 @@ typedef struct char c2; } test_structure_5; -static test_structure_5 struct5(test_structure_5 ts1, test_structure_5 ts2) +static test_structure_5 ABI_ATTR struct5(test_structure_5 ts1, test_structure_5 ts2) { ts1.c1 += ts2.c1; ts1.c2 -= ts2.c2; @@ -48,7 +48,7 @@ int main (void) values[1] = &ts5_arg2; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ts5_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ts5_type, args) == FFI_OK); ts5_arg1.c1 = 2; ts5_arg1.c2 = 6; diff --git a/testsuite/libffi.call/struct6.c b/testsuite/libffi.call/struct6.c index 0e267467..173c66eb 100644 --- a/testsuite/libffi.call/struct6.c +++ b/testsuite/libffi.call/struct6.c @@ -12,7 +12,7 @@ typedef struct double d; } test_structure_6; -static test_structure_6 struct6 (test_structure_6 ts) +static test_structure_6 ABI_ATTR struct6 (test_structure_6 ts) { ts.f += 1; ts.d += 1; @@ -46,7 +46,7 @@ int main (void) values[0] = &ts6_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts6_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts6_type, args) == FFI_OK); ts6_arg.f = 5.55f; ts6_arg.d = 6.66; diff --git a/testsuite/libffi.call/struct7.c b/testsuite/libffi.call/struct7.c index 8f2bbfd9..badc7e05 100644 --- a/testsuite/libffi.call/struct7.c +++ b/testsuite/libffi.call/struct7.c @@ -13,7 +13,7 @@ typedef struct double d; } test_structure_7; -static test_structure_7 struct7 (test_structure_7 ts) +static test_structure_7 ABI_ATTR struct7 (test_structure_7 ts) { ts.f1 += 1; ts.f2 += 1; @@ -49,7 +49,7 @@ int main (void) values[0] = &ts7_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts7_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts7_type, args) == FFI_OK); ts7_arg.f1 = 5.55f; ts7_arg.f2 = 55.5f; diff --git a/testsuite/libffi.call/struct8.c b/testsuite/libffi.call/struct8.c index 266e1f0a..ef204ecb 100644 --- a/testsuite/libffi.call/struct8.c +++ b/testsuite/libffi.call/struct8.c @@ -14,7 +14,7 @@ typedef struct float f4; } test_structure_8; -static test_structure_8 struct8 (test_structure_8 ts) +static test_structure_8 ABI_ATTR struct8 (test_structure_8 ts) { ts.f1 += 1; ts.f2 += 1; @@ -52,7 +52,7 @@ int main (void) values[0] = &ts8_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts8_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts8_type, args) == FFI_OK); ts8_arg.f1 = 5.55f; ts8_arg.f2 = 55.5f; diff --git a/testsuite/libffi.call/struct9.c b/testsuite/libffi.call/struct9.c index efeb7161..4a13b818 100644 --- a/testsuite/libffi.call/struct9.c +++ b/testsuite/libffi.call/struct9.c @@ -13,7 +13,7 @@ typedef struct int i; } test_structure_9; -static test_structure_9 struct9 (test_structure_9 ts) +static test_structure_9 ABI_ATTR struct9 (test_structure_9 ts) { ts.f += 1; ts.i += 1; @@ -47,7 +47,7 @@ int main (void) values[0] = &ts9_arg; /* Initialize the cif */ - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ts9_type, args) == FFI_OK); + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts9_type, args) == FFI_OK); ts9_arg.f = 5.55f; ts9_arg.i = 5; diff --git a/testsuite/libffi.call/unwindtest.cc b/testsuite/libffi.call/unwindtest.cc index 02c34d85..67cfefec 100644 --- a/testsuite/libffi.call/unwindtest.cc +++ b/testsuite/libffi.call/unwindtest.cc @@ -8,7 +8,7 @@ #include "ffitest.h" -void +void ABI_ATTR closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, void** args __UNUSED__, void* userdata __UNUSED__) {