diff options
Diffstat (limited to 'libffi/testsuite')
91 files changed, 1619 insertions, 358 deletions
diff --git a/libffi/testsuite/Makefile.am b/libffi/testsuite/Makefile.am index f94ca00..146fdf9 100644 --- a/libffi/testsuite/Makefile.am +++ b/libffi/testsuite/Makefile.am @@ -14,3 +14,72 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \ AM_RUNTESTFLAGS = 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/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 libffi.call/cls_align_sint32.c \ +libffi.call/nested_struct2.c libffi.call/ffitest.h \ +libffi.call/nested_struct4.c 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/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 libffi.call/call.exp \ +libffi.call/cls_double.c libffi.call/cls_align_sint16.c \ +libffi.call/cls_uint.c libffi.call/return_ll1.c \ +libffi.call/nested_struct3.c libffi.call/cls_20byte1.c \ +libffi.call/closure_fn4.c libffi.call/cls_uchar.c \ +libffi.call/struct2.c libffi.call/cls_7byte.c libffi.call/strlen.c \ +libffi.call/many.c libffi.call/testclosure.c libffi.call/return_fl.c \ +libffi.call/struct5.c libffi.call/cls_12byte.c \ +libffi.call/cls_multi_sshortchar.c \ +libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ +libffi.call/return_fl3.c libffi.call/stret_medium.c \ +libffi.call/nested_struct6.c libffi.call/a.out \ +libffi.call/closure_fn3.c libffi.call/float3.c libffi.call/many2.c \ +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/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/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 \ +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/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 \ +libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ +libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ +libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ +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/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 lib/libffi.exp diff --git a/libffi/testsuite/Makefile.in b/libffi/testsuite/Makefile.in index fae969b..44ca9c2 100644 --- a/libffi/testsuite/Makefile.in +++ b/libffi/testsuite/Makefile.in @@ -1,9 +1,9 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,6 +15,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -37,22 +54,32 @@ target_triplet = @target@ subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \ - $(top_srcdir)/../config/lead-dot.m4 \ - $(top_srcdir)/../config/multi.m4 \ - $(top_srcdir)/../config/override.m4 \ - $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ - $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ - $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \ + $(top_srcdir)/m4/ax_cc_maxopt.m4 \ + $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compiler_vendor.m4 \ + $(top_srcdir)/m4/ax_configure_args.m4 \ + $(top_srcdir)/m4/ax_enable_builddir.m4 \ + $(top_srcdir)/m4/ax_gcc_archflag.m4 \ + $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/fficonfig.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac DEJATOOL = $(PACKAGE) RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -77,6 +104,7 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -84,6 +112,7 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@ FGREP = @FGREP@ GREP = @GREP@ HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@ @@ -102,6 +131,7 @@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -117,6 +147,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PRTDIAG = @PRTDIAG@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -129,6 +160,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -136,6 +168,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +ax_enable_builddir_sed = @ax_enable_builddir_sed@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -163,7 +196,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -multi_basedir = @multi_basedir@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ @@ -172,6 +204,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +sys_symbol_underscore = @sys_symbol_underscore@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -195,6 +228,75 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \ else echo runtest; fi` 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/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 libffi.call/cls_align_sint32.c \ +libffi.call/nested_struct2.c libffi.call/ffitest.h \ +libffi.call/nested_struct4.c 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/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 libffi.call/call.exp \ +libffi.call/cls_double.c libffi.call/cls_align_sint16.c \ +libffi.call/cls_uint.c libffi.call/return_ll1.c \ +libffi.call/nested_struct3.c libffi.call/cls_20byte1.c \ +libffi.call/closure_fn4.c libffi.call/cls_uchar.c \ +libffi.call/struct2.c libffi.call/cls_7byte.c libffi.call/strlen.c \ +libffi.call/many.c libffi.call/testclosure.c libffi.call/return_fl.c \ +libffi.call/struct5.c libffi.call/cls_12byte.c \ +libffi.call/cls_multi_sshortchar.c \ +libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \ +libffi.call/return_fl3.c libffi.call/stret_medium.c \ +libffi.call/nested_struct6.c libffi.call/a.out \ +libffi.call/closure_fn3.c libffi.call/float3.c libffi.call/many2.c \ +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/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/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 \ +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/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 \ +libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \ +libffi.call/stret_large.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_ushort.c libffi.call/nested_struct1.c \ +libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \ +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/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 lib/libffi.exp + all: all-am .SUFFIXES: @@ -242,7 +344,7 @@ CTAGS: check-DEJAGNU: site.exp - srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + srcdir='$(srcdir)'; export srcdir; \ EXPECT=$(EXPECT); export EXPECT; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ @@ -253,12 +355,12 @@ check-DEJAGNU: site.exp else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi; \ exit $$exit_status -site.exp: Makefile +site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG) @echo 'Making a new site.exp file...' @echo '## these variables are automatically generated by make ##' >site.tmp @echo '# Do not edit here. If you wish to override these values' >>site.tmp @echo '# edit the last section' >>site.tmp - @echo 'set srcdir $(srcdir)' >>site.tmp + @echo 'set srcdir "$(srcdir)"' >>site.tmp @echo "set objdir `pwd`" >>site.tmp @echo 'set build_alias "$(build_alias)"' >>site.tmp @echo 'set build_triplet $(build_triplet)' >>site.tmp @@ -266,9 +368,16 @@ site.exp: Makefile @echo 'set host_triplet $(host_triplet)' >>site.tmp @echo 'set target_alias "$(target_alias)"' >>site.tmp @echo 'set target_triplet $(target_triplet)' >>site.tmp - @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp - @test ! -f site.exp || \ - sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \ + echo "## Begin content included from file $$f. Do not modify. ##" \ + && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \ + && echo "## End content included from file $$f. ##" \ + || exit 1; \ + done >> site.tmp + @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp + @if test -f site.exp; then \ + sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \ + fi @-rm -f site.bak @test ! -f site.exp || mv site.exp site.bak @mv site.tmp site.exp @@ -324,10 +433,15 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: diff --git a/libffi/testsuite/lib/libffi.exp b/libffi/testsuite/lib/libffi.exp index 82d6652..8ee3f15 100644 --- a/libffi/testsuite/lib/libffi.exp +++ b/libffi/testsuite/lib/libffi.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2005, 2008, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011 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 @@ -16,7 +16,7 @@ proc load_gcc_lib { filename } { global srcdir - load_file $srcdir/../../gcc/testsuite/lib/$filename + load_file $srcdir/lib/$filename } load_lib dg.exp @@ -94,7 +94,6 @@ proc libffi-init { args } { global srcdir global blddirffi global objdir - global blddircxx global TOOL_OPTIONS global tool global libffi_include @@ -102,10 +101,8 @@ proc libffi-init { args } { global tool_root_dir global ld_library_path - set blddirffi [lookfor_file [get_multilibs] libffi] + set blddirffi [pwd]/.. verbose "libffi $blddirffi" - set blddircxx [lookfor_file [get_multilibs] libstdc++-v3] - verbose "libstdc++ $blddircxx" set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] if {$gccdir != ""} { @@ -132,8 +129,6 @@ proc libffi-init { args } { } # add the library path for libffi. append ld_library_path ":${blddirffi}/.libs" - # add the library path for libstdc++ as well. - append ld_library_path ":${blddircxx}/src/.libs" verbose "ld_library_path: $ld_library_path" @@ -146,7 +141,6 @@ proc libffi-init { args } { if { $libffi_dir != "" } { set libffi_dir [file dirname ${libffi_dir}] set libffi_link_flags "-L${libffi_dir}/.libs" - lappend libffi_link_flags "-L${blddircxx}/src/.libs" } set_ld_library_path_env_vars @@ -209,6 +203,10 @@ proc libffi_target_compile { source dest type options } { lappend options "libs= -lffi" + if { [string match "aarch64*-*-linux*" $target_triplet] } { + lappend options "libs= -lpthread" + } + verbose "options: $options" return [target_compile $source $dest $type $options] } diff --git a/libffi/testsuite/libffi.call/closure_stdcall.c b/libffi/testsuite/libffi.call/closure_stdcall.c index 6bfcc1f..1407f02 100644 --- a/libffi/testsuite/libffi.call/closure_stdcall.c +++ b/libffi/testsuite/libffi.call/closure_stdcall.c @@ -49,9 +49,17 @@ int main (void) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_stdcall, (void *) 3 /* userdata */, code) == FFI_OK); +#ifdef _MSC_VER + __asm { mov sp_pre, esp } +#else asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); +#endif res = (*(closure_test_type0)code)(0, 1, 2, 3); +#ifdef _MSC_VER + __asm { mov sp_post, esp } +#else asm volatile (" movl %%esp,%0" : "=g" (sp_post)); +#endif /* { dg-output "0 1 2 3: 9" } */ printf("res: %d\n",res); diff --git a/libffi/testsuite/libffi.call/closure_thiscall.c b/libffi/testsuite/libffi.call/closure_thiscall.c index 6c46f35..0f93649 100644 --- a/libffi/testsuite/libffi.call/closure_thiscall.c +++ b/libffi/testsuite/libffi.call/closure_thiscall.c @@ -49,9 +49,17 @@ int main (void) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_thiscall, (void *) 3 /* userdata */, code) == FFI_OK); +#ifdef _MSC_VER + __asm { mov sp_pre, esp } +#else asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); +#endif res = (*(closure_test_type0)code)(0, 1, 2, 3); +#ifdef _MSC_VER + __asm { mov sp_post, esp } +#else asm volatile (" movl %%esp,%0" : "=g" (sp_post)); +#endif /* { dg-output "0 1 2 3: 9" } */ printf("res: %d\n",res); diff --git a/libffi/testsuite/libffi.call/cls_12byte.c b/libffi/testsuite/libffi.call/cls_12byte.c index f0a334f..ea0825d 100644 --- a/libffi/testsuite/libffi.call/cls_12byte.c +++ b/libffi/testsuite/libffi.call/cls_12byte.c @@ -49,15 +49,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_12byte h_dbl = { 7, 4, 9 }; + struct cls_struct_12byte j_dbl = { 1, 5, 3 }; + struct cls_struct_12byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_12byte h_dbl = { 7, 4, 9 }; - struct cls_struct_12byte j_dbl = { 1, 5, 3 }; - struct cls_struct_12byte res_dbl; - cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/cls_16byte.c b/libffi/testsuite/libffi.call/cls_16byte.c index 9b9292a..89a08a2 100644 --- a/libffi/testsuite/libffi.call/cls_16byte.c +++ b/libffi/testsuite/libffi.call/cls_16byte.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; + struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; + struct cls_struct_16byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_16byte h_dbl = { 7, 8.0, 9 }; - struct cls_struct_16byte j_dbl = { 1, 9.0, 3 }; - struct cls_struct_16byte res_dbl; - cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/cls_18byte.c b/libffi/testsuite/libffi.call/cls_18byte.c index 40c8c6d..9f75da8 100644 --- a/libffi/testsuite/libffi.call/cls_18byte.c +++ b/libffi/testsuite/libffi.call/cls_18byte.c @@ -54,15 +54,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; + struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; + struct cls_struct_18byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 }; - struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 }; - struct cls_struct_18byte res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_19byte.c b/libffi/testsuite/libffi.call/cls_19byte.c index aa64248..278794b 100644 --- a/libffi/testsuite/libffi.call/cls_19byte.c +++ b/libffi/testsuite/libffi.call/cls_19byte.c @@ -57,15 +57,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; + struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; + struct cls_struct_19byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 }; - struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 }; - struct cls_struct_19byte res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_1_1byte.c b/libffi/testsuite/libffi.call/cls_1_1byte.c index b9402d6..82492c0 100644 --- a/libffi/testsuite/libffi.call/cls_1_1byte.c +++ b/libffi/testsuite/libffi.call/cls_1_1byte.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_1_1byte g_dbl = { 12 }; + struct cls_struct_1_1byte f_dbl = { 178 }; + struct cls_struct_1_1byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_1_1byte g_dbl = { 12 }; - struct cls_struct_1_1byte f_dbl = { 178 }; - struct cls_struct_1_1byte res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_20byte.c b/libffi/testsuite/libffi.call/cls_20byte.c index 80dd7ac..3f8bb28 100644 --- a/libffi/testsuite/libffi.call/cls_20byte.c +++ b/libffi/testsuite/libffi.call/cls_20byte.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; + struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; + struct cls_struct_20byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 }; - struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 }; - struct cls_struct_20byte res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/cls_20byte1.c b/libffi/testsuite/libffi.call/cls_20byte1.c index 50bcbbf..6562727 100644 --- a/libffi/testsuite/libffi.call/cls_20byte1.c +++ b/libffi/testsuite/libffi.call/cls_20byte1.c @@ -52,15 +52,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; + struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; + struct cls_struct_20byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 }; - struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 }; - struct cls_struct_20byte res_dbl; - cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/cls_24byte.c b/libffi/testsuite/libffi.call/cls_24byte.c index 46a6eb4..1d82f6e 100644 --- a/libffi/testsuite/libffi.call/cls_24byte.c +++ b/libffi/testsuite/libffi.call/cls_24byte.c @@ -61,17 +61,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct cls_struct_24byte e_dbl = { 9.0, 2.0, 6, 5.0 }; struct cls_struct_24byte f_dbl = { 1.0, 2.0, 3, 7.0 }; struct cls_struct_24byte g_dbl = { 4.0, 5.0, 7, 9.0 }; struct cls_struct_24byte h_dbl = { 8.0, 6.0, 1, 4.0 }; struct cls_struct_24byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/cls_2byte.c b/libffi/testsuite/libffi.call/cls_2byte.c index 101e130..81bb0a6 100644 --- a/libffi/testsuite/libffi.call/cls_2byte.c +++ b/libffi/testsuite/libffi.call/cls_2byte.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_2byte g_dbl = { 12, 127 }; + struct cls_struct_2byte f_dbl = { 1, 13 }; + struct cls_struct_2byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_2byte g_dbl = { 12, 127 }; - struct cls_struct_2byte f_dbl = { 1, 13 }; - struct cls_struct_2byte res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_3_1byte.c b/libffi/testsuite/libffi.call/cls_3_1byte.c index fc780c3..b782746 100644 --- a/libffi/testsuite/libffi.call/cls_3_1byte.c +++ b/libffi/testsuite/libffi.call/cls_3_1byte.c @@ -54,15 +54,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; + struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; + struct cls_struct_3_1byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_3_1byte g_dbl = { 12, 13, 14 }; - struct cls_struct_3_1byte f_dbl = { 178, 179, 180 }; - struct cls_struct_3_1byte res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_3byte1.c b/libffi/testsuite/libffi.call/cls_3byte1.c index 5705ce3..a02c463 100644 --- a/libffi/testsuite/libffi.call/cls_3byte1.c +++ b/libffi/testsuite/libffi.call/cls_3byte1.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_3byte g_dbl = { 12, 119 }; + struct cls_struct_3byte f_dbl = { 1, 15 }; + struct cls_struct_3byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_3byte g_dbl = { 12, 119 }; - struct cls_struct_3byte f_dbl = { 1, 15 }; - struct cls_struct_3byte res_dbl; - cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_3byte2.c b/libffi/testsuite/libffi.call/cls_3byte2.c index 01770a0..c7251ce 100644 --- a/libffi/testsuite/libffi.call/cls_3byte2.c +++ b/libffi/testsuite/libffi.call/cls_3byte2.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_3byte_1 g_dbl = { 15, 125 }; + struct cls_struct_3byte_1 f_dbl = { 9, 19 }; + struct cls_struct_3byte_1 res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_3byte_1 g_dbl = { 15, 125 }; - struct cls_struct_3byte_1 f_dbl = { 9, 19 }; - struct cls_struct_3byte_1 res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_4_1byte.c b/libffi/testsuite/libffi.call/cls_4_1byte.c index f3806d7..2d6d8b6 100644 --- a/libffi/testsuite/libffi.call/cls_4_1byte.c +++ b/libffi/testsuite/libffi.call/cls_4_1byte.c @@ -56,15 +56,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; + struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; + struct cls_struct_4_1byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 }; - struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 }; - struct cls_struct_4_1byte res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_4byte.c b/libffi/testsuite/libffi.call/cls_4byte.c index a1aba3c..4ac3787 100644 --- a/libffi/testsuite/libffi.call/cls_4byte.c +++ b/libffi/testsuite/libffi.call/cls_4byte.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_4byte g_dbl = { 127, 120 }; + struct cls_struct_4byte f_dbl = { 12, 128 }; + struct cls_struct_4byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_4byte g_dbl = { 127, 120 }; - struct cls_struct_4byte f_dbl = { 12, 128 }; - struct cls_struct_4byte res_dbl; - cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_5_1_byte.c b/libffi/testsuite/libffi.call/cls_5_1_byte.c index 2ceba3d..ad9d51c 100644 --- a/libffi/testsuite/libffi.call/cls_5_1_byte.c +++ b/libffi/testsuite/libffi.call/cls_5_1_byte.c @@ -58,15 +58,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 }; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_5byte.c b/libffi/testsuite/libffi.call/cls_5byte.c index 61d595c..4e0c000 100644 --- a/libffi/testsuite/libffi.call/cls_5byte.c +++ b/libffi/testsuite/libffi.call/cls_5byte.c @@ -53,15 +53,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_5byte g_dbl = { 127, 120, 1 }; + struct cls_struct_5byte f_dbl = { 12, 128, 9 }; + struct cls_struct_5byte res_dbl = { 0, 0, 0 }; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_5byte g_dbl = { 127, 120, 1 }; - struct cls_struct_5byte f_dbl = { 12, 128, 9 }; - struct cls_struct_5byte res_dbl = { 0, 0, 0 }; - cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_64byte.c b/libffi/testsuite/libffi.call/cls_64byte.c index 576ebe0..a55edc2 100644 --- a/libffi/testsuite/libffi.call/cls_64byte.c +++ b/libffi/testsuite/libffi.call/cls_64byte.c @@ -66,17 +66,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct cls_struct_64byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0 }; struct cls_struct_64byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0 }; struct cls_struct_64byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0 }; struct cls_struct_64byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0 }; struct cls_struct_64byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/cls_6_1_byte.c b/libffi/testsuite/libffi.call/cls_6_1_byte.c index 9f2eff6..b4dcdba 100644 --- a/libffi/testsuite/libffi.call/cls_6_1_byte.c +++ b/libffi/testsuite/libffi.call/cls_6_1_byte.c @@ -60,15 +60,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; + struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 }; - struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 }; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_6byte.c b/libffi/testsuite/libffi.call/cls_6byte.c index 73257b0..7406780 100644 --- a/libffi/testsuite/libffi.call/cls_6byte.c +++ b/libffi/testsuite/libffi.call/cls_6byte.c @@ -56,15 +56,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; + struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; + struct cls_struct_6byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 }; - struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 }; - struct cls_struct_6byte res_dbl; - cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_7_1_byte.c b/libffi/testsuite/libffi.call/cls_7_1_byte.c index 50d09c9..14a7e96 100644 --- a/libffi/testsuite/libffi.call/cls_7_1_byte.c +++ b/libffi/testsuite/libffi.call/cls_7_1_byte.c @@ -62,15 +62,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; + struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 }; - struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 }; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_7byte.c b/libffi/testsuite/libffi.call/cls_7byte.c index f5c0000..1645cc6 100644 --- a/libffi/testsuite/libffi.call/cls_7byte.c +++ b/libffi/testsuite/libffi.call/cls_7byte.c @@ -55,15 +55,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; + struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; + struct cls_struct_7byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 }; - struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 }; - struct cls_struct_7byte res_dbl; - cls_struct_fields[0] = &ffi_type_ushort; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_8byte.c b/libffi/testsuite/libffi.call/cls_8byte.c index 4aa99d1..f6c1ea5 100644 --- a/libffi/testsuite/libffi.call/cls_8byte.c +++ b/libffi/testsuite/libffi.call/cls_8byte.c @@ -49,15 +49,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_8byte g_dbl = { 1, 2.0 }; + struct cls_struct_8byte f_dbl = { 4, 5.0 }; + struct cls_struct_8byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_8byte g_dbl = { 1, 2.0 }; - struct cls_struct_8byte f_dbl = { 4, 5.0 }; - struct cls_struct_8byte res_dbl; - cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_9byte1.c b/libffi/testsuite/libffi.call/cls_9byte1.c index cc5e9d6..0b85722 100644 --- a/libffi/testsuite/libffi.call/cls_9byte1.c +++ b/libffi/testsuite/libffi.call/cls_9byte1.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_9byte h_dbl = { 7, 8.0}; + struct cls_struct_9byte j_dbl = { 1, 9.0}; + struct cls_struct_9byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_9byte h_dbl = { 7, 8.0}; - struct cls_struct_9byte j_dbl = { 1, 9.0}; - struct cls_struct_9byte res_dbl; - cls_struct_fields[0] = &ffi_type_sint; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_9byte2.c b/libffi/testsuite/libffi.call/cls_9byte2.c index 5c0ba0d..edf991d 100644 --- a/libffi/testsuite/libffi.call/cls_9byte2.c +++ b/libffi/testsuite/libffi.call/cls_9byte2.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_9byte h_dbl = { 7.0, 8}; + struct cls_struct_9byte j_dbl = { 1.0, 9}; + struct cls_struct_9byte res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_9byte h_dbl = { 7.0, 8}; - struct cls_struct_9byte j_dbl = { 1.0, 9}; - struct cls_struct_9byte res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_align_double.c b/libffi/testsuite/libffi.call/cls_align_double.c index 22b94d5..aad5f3c 100644 --- a/libffi/testsuite/libffi.call/cls_align_double.c +++ b/libffi/testsuite/libffi.call/cls_align_double.c @@ -52,15 +52,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_float.c b/libffi/testsuite/libffi.call/cls_align_float.c index 62637f2..37e0855 100644 --- a/libffi/testsuite/libffi.call/cls_align_float.c +++ b/libffi/testsuite/libffi.call/cls_align_float.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble.c b/libffi/testsuite/libffi.call/cls_align_longdouble.c index af38060..b3322d8 100644 --- a/libffi/testsuite/libffi.call/cls_align_longdouble.c +++ b/libffi/testsuite/libffi.call/cls_align_longdouble.c @@ -51,15 +51,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble_split.c b/libffi/testsuite/libffi.call/cls_align_longdouble_split.c index a3732bd..15f9365 100644 --- a/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +++ b/libffi/testsuite/libffi.call/cls_align_longdouble_split.c @@ -87,15 +87,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_longdouble; diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c b/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c index 63a0f76..ca1c356 100644 --- a/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +++ b/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c @@ -67,15 +67,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; + struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; + struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 }; - struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_longdouble; cls_struct_fields[2] = &ffi_type_longdouble; diff --git a/libffi/testsuite/libffi.call/cls_align_pointer.c b/libffi/testsuite/libffi.call/cls_align_pointer.c index cbc4f95..8fbf36a 100644 --- a/libffi/testsuite/libffi.call/cls_align_pointer.c +++ b/libffi/testsuite/libffi.call/cls_align_pointer.c @@ -54,15 +54,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; + struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, (void *)4951, 127 }; - struct cls_struct_align f_dbl = { 1, (void *)9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_pointer; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_sint16.c b/libffi/testsuite/libffi.call/cls_align_sint16.c index 383ea41..039b874 100644 --- a/libffi/testsuite/libffi.call/cls_align_sint16.c +++ b/libffi/testsuite/libffi.call/cls_align_sint16.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sshort; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_sint32.c b/libffi/testsuite/libffi.call/cls_align_sint32.c index 705d78c..c96c6d1 100644 --- a/libffi/testsuite/libffi.call/cls_align_sint32.c +++ b/libffi/testsuite/libffi.call/cls_align_sint32.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_sint64.c b/libffi/testsuite/libffi.call/cls_align_sint64.c index 31d53af..9aa7bdd 100644 --- a/libffi/testsuite/libffi.call/cls_align_sint64.c +++ b/libffi/testsuite/libffi.call/cls_align_sint64.c @@ -51,15 +51,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_sint64; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_uint16.c b/libffi/testsuite/libffi.call/cls_align_uint16.c index cb6b748..97620b7 100644 --- a/libffi/testsuite/libffi.call/cls_align_uint16.c +++ b/libffi/testsuite/libffi.call/cls_align_uint16.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_ushort; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_uint32.c b/libffi/testsuite/libffi.call/cls_align_uint32.c index e453d3e..5766fad 100644 --- a/libffi/testsuite/libffi.call/cls_align_uint32.c +++ b/libffi/testsuite/libffi.call/cls_align_uint32.c @@ -50,15 +50,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_align_uint64.c b/libffi/testsuite/libffi.call/cls_align_uint64.c index 495c79f..a52cb89 100644 --- a/libffi/testsuite/libffi.call/cls_align_uint64.c +++ b/libffi/testsuite/libffi.call/cls_align_uint64.c @@ -52,15 +52,15 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; + struct cls_struct_align g_dbl = { 12, 4951, 127 }; + struct cls_struct_align f_dbl = { 1, 9320, 13 }; + struct cls_struct_align res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; - struct cls_struct_align g_dbl = { 12, 4951, 127 }; - struct cls_struct_align f_dbl = { 1, 9320, 13 }; - struct cls_struct_align res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint64; cls_struct_fields[2] = &ffi_type_uchar; diff --git a/libffi/testsuite/libffi.call/cls_dbls_struct.c b/libffi/testsuite/libffi.call/cls_dbls_struct.c index 660dabb..d663791 100644 --- a/libffi/testsuite/libffi.call/cls_dbls_struct.c +++ b/libffi/testsuite/libffi.call/cls_dbls_struct.c @@ -37,6 +37,8 @@ int main(int argc __UNUSED__, char** argv __UNUSED__) ffi_type ts1_type; ffi_type* ts1_type_elements[4]; + Dbls arg = { 1.0, 2.0 }; + ts1_type.size = 0; ts1_type.alignment = 0; ts1_type.type = FFI_TYPE_STRUCT; @@ -48,8 +50,6 @@ int main(int argc __UNUSED__, char** argv __UNUSED__) cl_arg_types[0] = &ts1_type; - Dbls arg = { 1.0, 2.0 }; - /* Initialize the cif */ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, cl_arg_types) == FFI_OK); diff --git a/libffi/testsuite/libffi.call/cls_double_va.c b/libffi/testsuite/libffi.call/cls_double_va.c index 67e44a4..dbf2000 100644 --- a/libffi/testsuite/libffi.call/cls_double_va.c +++ b/libffi/testsuite/libffi.call/cls_double_va.c @@ -7,7 +7,6 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ /* { dg-output "" { xfail avr32*-*-* } } */ /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ -/* { dg-skip-if "" arm*-*-* { "-mfloat-abi=hard" } { "" } } */ #include "ffitest.h" diff --git a/libffi/testsuite/libffi.call/cls_longdouble_va.c b/libffi/testsuite/libffi.call/cls_longdouble_va.c index 6b8484a..4fa1ea2 100644 --- a/libffi/testsuite/libffi.call/cls_longdouble_va.c +++ b/libffi/testsuite/libffi.call/cls_longdouble_va.c @@ -7,7 +7,6 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */ /* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */ -/* { dg-skip-if "" arm*-*-* { "-mfloat-abi=hard" } { "" } } */ #include "ffitest.h" diff --git a/libffi/testsuite/libffi.call/cls_pointer_stack.c b/libffi/testsuite/libffi.call/cls_pointer_stack.c index d631cf8..e31139e 100644 --- a/libffi/testsuite/libffi.call/cls_pointer_stack.c +++ b/libffi/testsuite/libffi.call/cls_pointer_stack.c @@ -28,11 +28,12 @@ void* cls_pointer_fn2(void* a1, void* a2) char trample6 = trample4 + ((char*)&a2)[1]; long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; char trample8 = trample6 + trample2; + void* result; dummyVar = dummy_func(trample1, trample2, trample3, trample4, trample5, trample6, trample7, trample8); - void* result = (void*)((intptr_t)a1 + (intptr_t)a2); + result = (void*)((intptr_t)a1 + (intptr_t)a2); printf("0x%08x 0x%08x: 0x%08x\n", (unsigned int)(uintptr_t) a1, @@ -52,11 +53,12 @@ void* cls_pointer_fn1(void* a1, void* a2) char trample6 = trample4 + ((char*)&a2)[1]; long double trample7 = (intptr_t)trample5 + (intptr_t)trample1; char trample8 = trample6 + trample2; + void* result; dummyVar = dummy_func(trample1, trample2, trample3, trample4, trample5, trample6, trample7, trample8); - void* result = (void*)((intptr_t)a1 + (intptr_t)a2); + result = (void*)((intptr_t)a1 + (intptr_t)a2); printf("0x%08x 0x%08x: 0x%08x\n", (unsigned int)(intptr_t) a1, diff --git a/libffi/testsuite/libffi.call/cls_struct_va1.c b/libffi/testsuite/libffi.call/cls_struct_va1.c new file mode 100644 index 0000000..91772bd --- /dev/null +++ b/libffi/testsuite/libffi.call/cls_struct_va1.c @@ -0,0 +1,114 @@ +/* Area: ffi_call, closure_call + Purpose: Test doubles passed in variable argument lists. + Limitations: none. + PR: none. + Originator: Blake Chaffin 6/6/2007 */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ +#include "ffitest.h" + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static void +test_fn (ffi_cif* cif __UNUSED__, void* resp, + void** args, void* userdata __UNUSED__) +{ + int n = *(int*)args[0]; + struct small_tag s1 = * (struct small_tag *) args[1]; + struct large_tag l1 = * (struct large_tag *) args[2]; + struct small_tag s2 = * (struct small_tag *) args[3]; + + printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b, + l1.a, l1.b, l1.c, l1.d, l1.e, + s2.a, s2.b); + * (int*) resp = 42; +} + +int +main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc (sizeof (ffi_closure), &code); + ffi_type* arg_types[5]; + + ffi_arg res = 0; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int si; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, + arg_types) == FFI_OK); + + si = 4; + s1.a = 5; + s1.b = 6; + + s2.a = 20; + s2.b = 21; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + CHECK(ffi_prep_closure_loc(pcl, &cif, test_fn, NULL, code) == FFI_OK); + + res = ((int (*)(int, ...))(code))(si, s1, l1, s2); + // { dg-output "4 5 6 10 11 12 13 14 20 21" } + printf("res: %d\n", (int) res); + // { dg-output "\nres: 42" } + + exit(0); +} diff --git a/libffi/testsuite/libffi.call/cls_uchar_va.c b/libffi/testsuite/libffi.call/cls_uchar_va.c new file mode 100644 index 0000000..19cd4f3 --- /dev/null +++ b/libffi/testsuite/libffi.call/cls_uchar_va.c @@ -0,0 +1,44 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned char argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef unsigned char T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(T *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_uchar; + cl_arg_types[1] = &ffi_type_uchar; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_uchar, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/libffi/testsuite/libffi.call/cls_uint_va.c b/libffi/testsuite/libffi.call/cls_uint_va.c new file mode 100644 index 0000000..150fddd --- /dev/null +++ b/libffi/testsuite/libffi.call/cls_uint_va.c @@ -0,0 +1,45 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned int argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef unsigned int T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(T *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_uint; + cl_arg_types[1] = &ffi_type_uint; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_uint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/libffi/testsuite/libffi.call/cls_ulong_va.c b/libffi/testsuite/libffi.call/cls_ulong_va.c new file mode 100644 index 0000000..0315082 --- /dev/null +++ b/libffi/testsuite/libffi.call/cls_ulong_va.c @@ -0,0 +1,45 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned long argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ + +#include "ffitest.h" + +typedef unsigned long T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(T *)resp = *(T *)args[0]; + + printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_ulong; + cl_arg_types[1] = &ffi_type_ulong; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_ulong, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %ld\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/libffi/testsuite/libffi.call/cls_ushort_va.c b/libffi/testsuite/libffi.call/cls_ushort_va.c new file mode 100644 index 0000000..b2b5a3b --- /dev/null +++ b/libffi/testsuite/libffi.call/cls_ushort_va.c @@ -0,0 +1,44 @@ +/* Area: closure_call + Purpose: Test anonymous unsigned short argument. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef unsigned short T; + +static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) + { + *(T *)resp = *(T *)args[0]; + + printf("%d: %d %d\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + } + +typedef T (*cls_ret_T)(T, ...); + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type * cl_arg_types[3]; + T res; + + cl_arg_types[0] = &ffi_type_ushort; + cl_arg_types[1] = &ffi_type_ushort; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, + &ffi_type_ushort, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK); + res = ((((cls_ret_T)code)(67, 4))); + /* { dg-output "67: 67 4" } */ + printf("res: %d\n", res); + /* { dg-output "\nres: 67" } */ + exit(0); +} diff --git a/libffi/testsuite/libffi.call/err_bad_typedef.c b/libffi/testsuite/libffi.call/err_bad_typedef.c index 2539273..bf60161 100644 --- a/libffi/testsuite/libffi.call/err_bad_typedef.c +++ b/libffi/testsuite/libffi.call/err_bad_typedef.c @@ -13,10 +13,10 @@ int main (void) ffi_cif cif; ffi_type* arg_types[1]; - arg_types[0] = NULL; - ffi_type badType = ffi_type_void; + arg_types[0] = NULL; + badType.size = 0; CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType, diff --git a/libffi/testsuite/libffi.call/fastthis1_win32.c b/libffi/testsuite/libffi.call/fastthis1_win32.c index b3c4c73..cbc4724 100644 --- a/libffi/testsuite/libffi.call/fastthis1_win32.c +++ b/libffi/testsuite/libffi.call/fastthis1_win32.c @@ -8,7 +8,7 @@ #include "ffitest.h" -static size_t __attribute__((fastcall)) my_fastcall_f(char *s, float a) +static size_t __FASTCALL__ my_fastcall_f(char *s, float a) { return (size_t) ((int) strlen(s) + (int) a); } diff --git a/libffi/testsuite/libffi.call/fastthis2_win32.c b/libffi/testsuite/libffi.call/fastthis2_win32.c index f148a12..7bdd0e1 100644 --- a/libffi/testsuite/libffi.call/fastthis2_win32.c +++ b/libffi/testsuite/libffi.call/fastthis2_win32.c @@ -8,7 +8,7 @@ #include "ffitest.h" -static size_t __attribute__((fastcall)) my_fastcall_f(float a, char *s) +static size_t __FASTCALL__ my_fastcall_f(float a, char *s) { return (size_t) ((int) strlen(s) + (int) a); } diff --git a/libffi/testsuite/libffi.call/fastthis3_win32.c b/libffi/testsuite/libffi.call/fastthis3_win32.c index 5cf82bb..b5d606d 100644 --- a/libffi/testsuite/libffi.call/fastthis3_win32.c +++ b/libffi/testsuite/libffi.call/fastthis3_win32.c @@ -8,7 +8,7 @@ #include "ffitest.h" -static size_t __attribute__((fastcall)) my_fastcall_f(float a, char *s, int i) +static size_t __FASTCALL__ my_fastcall_f(float a, char *s, int i) { return (size_t) ((int) strlen(s) + (int) a + i); } diff --git a/libffi/testsuite/libffi.call/ffitest.h b/libffi/testsuite/libffi.call/ffitest.h index 0e95e16..d81d4da 100644 --- a/libffi/testsuite/libffi.call/ffitest.h +++ b/libffi/testsuite/libffi.call/ffitest.h @@ -25,6 +25,14 @@ #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 file open. */ #ifdef HAVE_MMAP_ANON @@ -110,6 +118,15 @@ #endif #endif +/* MSVC kludge. */ +#if defined _MSC_VER +#define PRIuPTR "lu" +#define PRIu8 "u" +#define PRId8 "d" +#define PRIu64 "I64u" +#define PRId64 "I64d" +#endif + #ifdef USING_MMAP static inline void * allocate_mmap (size_t size) diff --git a/libffi/testsuite/libffi.call/float_va.c b/libffi/testsuite/libffi.call/float_va.c index 2039ae5..aae158e 100644 --- a/libffi/testsuite/libffi.call/float_va.c +++ b/libffi/testsuite/libffi.call/float_va.c @@ -25,18 +25,18 @@ double float_va_fn(unsigned int x, double y,...) total+=(double)x; total+=y; - printf("%u: %.1lf :", x, y); + printf("%u: %.1f :", x, y); va_start(ap, y); for(i=0;i<x;i++) { double arg=va_arg(ap, double); total+=arg; - printf(" %d:%.1lf ", i, arg); + printf(" %d:%.1f ", i, arg); } va_end(ap); - printf(" total: %.1lf\n", total); + printf(" total: %.1f\n", total); return total; } @@ -57,7 +57,7 @@ int main (void) /* Call it statically and then via ffi */ resfp=float_va_fn(0,2.0); // { dg-output "0: 2.0 : total: 2.0" } - printf("compiled: %.1lf\n", resfp); + printf("compiled: %.1f\n", resfp); // { dg-output "\ncompiled: 2.0" } arg_types[0] = &ffi_type_uint; @@ -72,14 +72,14 @@ int main (void) values[1] = &doubles[0]; ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); // { dg-output "\n0: 2.0 : total: 2.0" } - printf("ffi: %.1lf\n", resfp); + printf("ffi: %.1f\n", resfp); // { dg-output "\nffi: 2.0" } /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */ /* Call it statically and then via ffi */ resfp=float_va_fn(2,2.0,3.0,4.0); // { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } - printf("compiled: %.1lf\n", resfp); + printf("compiled: %.1f\n", resfp); // { dg-output "\ncompiled: 11.0" } arg_types[0] = &ffi_type_uint; @@ -100,7 +100,7 @@ int main (void) values[3] = &doubles[2]; ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); // { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } - printf("ffi: %.1lf\n", resfp); + printf("ffi: %.1f\n", resfp); // { dg-output "\nffi: 11.0" } exit(0); diff --git a/libffi/testsuite/libffi.call/huge_struct.c b/libffi/testsuite/libffi.call/huge_struct.c index e04e1d5..380fedf 100644 --- a/libffi/testsuite/libffi.call/huge_struct.c +++ b/libffi/testsuite/libffi.call/huge_struct.c @@ -229,6 +229,19 @@ main(int argc __UNUSED__, const char** argv __UNUSED__) ffi_type* st_fields[51]; BigStruct retVal; + uint8_t ui8 = 1; + int8_t si8 = 2; + uint16_t ui16 = 3; + int16_t si16 = 4; + uint32_t ui32 = 5; + int32_t si32 = 6; + uint64_t ui64 = 7; + int64_t si64 = 8; + float f = 9; + double d = 10; + long double ld = 11; + char* p = (char*)0x12345678; + memset (&retVal, 0, sizeof(retVal)); ret_struct_type.size = 0; @@ -251,19 +264,6 @@ main(int argc __UNUSED__, const char** argv __UNUSED__) st_fields[50] = NULL; - uint8_t ui8 = 1; - int8_t si8 = 2; - uint16_t ui16 = 3; - int16_t si16 = 4; - uint32_t ui32 = 5; - int32_t si32 = 6; - uint64_t ui64 = 7; - int64_t si64 = 8; - float f = 9; - double d = 10; - long double ld = 11; - char* p = (char*)0x12345678; - argTypes[0] = argTypes[12] = argTypes[24] = argTypes[36] = argTypes[48] = &ffi_type_uint8; argValues[0] = argValues[12] = argValues[24] = argValues[36] = argValues[48] = &ui8; argTypes[1] = argTypes[13] = argTypes[25] = argTypes[37] = argTypes[49] = &ffi_type_sint8; diff --git a/libffi/testsuite/libffi.call/nested_struct.c b/libffi/testsuite/libffi.call/nested_struct.c index 8aa527e..c15e3a0 100644 --- a/libffi/testsuite/libffi.call/nested_struct.c +++ b/libffi/testsuite/libffi.call/nested_struct.c @@ -77,6 +77,12 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[5]; + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_combined res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -92,12 +98,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_combined res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/nested_struct1.c b/libffi/testsuite/libffi.call/nested_struct1.c index 2a9f515..1087f7b 100644 --- a/libffi/testsuite/libffi.call/nested_struct1.c +++ b/libffi/testsuite/libffi.call/nested_struct1.c @@ -81,6 +81,13 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[5]; + struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; + struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; + struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, + {3, 1.0, 8.0}}; + struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; + struct cls_struct_combined res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -96,13 +103,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6}; - struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0}; - struct cls_struct_combined g_dbl = {{4.0, 5.0, 6}, - {3, 1.0, 8.0}}; - struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4}; - struct cls_struct_combined res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_float; cls_struct_fields[2] = &ffi_type_sint; diff --git a/libffi/testsuite/libffi.call/nested_struct10.c b/libffi/testsuite/libffi.call/nested_struct10.c index d6a718b..34a74e7 100644 --- a/libffi/testsuite/libffi.call/nested_struct10.c +++ b/libffi/testsuite/libffi.call/nested_struct10.c @@ -67,6 +67,12 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = { 99, {12LL , 127}, 255}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -82,12 +88,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = { 99, {12LL , 127}, 255}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct11.c b/libffi/testsuite/libffi.call/nested_struct11.c new file mode 100644 index 0000000..fce6948 --- /dev/null +++ b/libffi/testsuite/libffi.call/nested_struct11.c @@ -0,0 +1,121 @@ +/* Area: ffi_call, closure_call + Purpose: Check parameter passing with nested structs + of a single type. This tests the special cases + for homogenous floating-point aggregates in the + AArch64 PCS. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + float a_x; + float a_y; +} A; + +typedef struct B { + float b_x; + float b_y; +} B; + +typedef struct C { + A a; + B b; +} C; + +static C C_fn (int x, int y, int z, C source, int i, int j, int k) +{ + C result; + result.a.a_x = source.a.a_x; + result.a.a_y = source.a.a_y; + result.b.b_x = source.b.b_x; + result.b.b_y = source.b.b_y; + + printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); + + printf ("%.1f, %.1f, %.1f, %.1f, " + "%.1f, %.1f, %.1f, %.1f\n", + source.a.a_x, source.a.a_y, + source.b.b_x, source.b.b_y, + result.a.a_x, result.a.a_y, + result.b.b_x, result.b.b_y); + + return result; +} + +int main (void) +{ + ffi_cif cif; + + ffi_type* struct_fields_source_a[3]; + ffi_type* struct_fields_source_b[3]; + ffi_type* struct_fields_source_c[3]; + ffi_type* arg_types[8]; + + ffi_type struct_type_a, struct_type_b, struct_type_c; + + struct A source_fld_a = {1.0, 2.0}; + struct B source_fld_b = {4.0, 8.0}; + int k = 1; + + struct C result; + struct C source = {source_fld_a, source_fld_b}; + + struct_type_a.size = 0; + struct_type_a.alignment = 0; + struct_type_a.type = FFI_TYPE_STRUCT; + struct_type_a.elements = struct_fields_source_a; + + struct_type_b.size = 0; + struct_type_b.alignment = 0; + struct_type_b.type = FFI_TYPE_STRUCT; + struct_type_b.elements = struct_fields_source_b; + + struct_type_c.size = 0; + struct_type_c.alignment = 0; + struct_type_c.type = FFI_TYPE_STRUCT; + struct_type_c.elements = struct_fields_source_c; + + struct_fields_source_a[0] = &ffi_type_float; + struct_fields_source_a[1] = &ffi_type_float; + struct_fields_source_a[2] = NULL; + + struct_fields_source_b[0] = &ffi_type_float; + struct_fields_source_b[1] = &ffi_type_float; + struct_fields_source_b[2] = NULL; + + struct_fields_source_c[0] = &struct_type_a; + struct_fields_source_c[1] = &struct_type_b; + struct_fields_source_c[2] = NULL; + + arg_types[0] = &ffi_type_sint32; + arg_types[1] = &ffi_type_sint32; + arg_types[2] = &ffi_type_sint32; + arg_types[3] = &struct_type_c; + arg_types[4] = &ffi_type_sint32; + arg_types[5] = &ffi_type_sint32; + arg_types[6] = &ffi_type_sint32; + arg_types[7] = NULL; + + void *args[7]; + args[0] = &k; + args[1] = &k; + args[2] = &k; + args[3] = &source; + args[4] = &k; + args[5] = &k; + args[6] = &k; + CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, 7, &struct_type_c, + arg_types) == FFI_OK); + + ffi_call (&cif, FFI_FN (C_fn), &result, args); + /* { dg-output "1, 1, 1, 1, 1, 1\n" } */ + /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */ + CHECK (result.a.a_x == source.a.a_x); + CHECK (result.a.a_y == source.a.a_y); + CHECK (result.b.b_x == source.b.b_x); + CHECK (result.b.b_y == source.b.b_y); + exit (0); +} diff --git a/libffi/testsuite/libffi.call/nested_struct2.c b/libffi/testsuite/libffi.call/nested_struct2.c index de1584c..69268cd 100644 --- a/libffi/testsuite/libffi.call/nested_struct2.c +++ b/libffi/testsuite/libffi.call/nested_struct2.c @@ -57,6 +57,11 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; + struct A e_dbl = { 1, 7}; + struct B f_dbl = {{12 , 127}, 99}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -67,11 +72,6 @@ int main (void) cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; - struct A e_dbl = { 1, 7}; - struct B f_dbl = {{12 , 127}, 99}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_ulong; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct3.c b/libffi/testsuite/libffi.call/nested_struct3.c index 58aa853..ab18cad 100644 --- a/libffi/testsuite/libffi.call/nested_struct3.c +++ b/libffi/testsuite/libffi.call/nested_struct3.c @@ -58,6 +58,11 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -68,11 +73,6 @@ int main (void) cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct4.c b/libffi/testsuite/libffi.call/nested_struct4.c index 98e491e..2ffb4d6 100644 --- a/libffi/testsuite/libffi.call/nested_struct4.c +++ b/libffi/testsuite/libffi.call/nested_struct4.c @@ -58,6 +58,11 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -68,11 +73,6 @@ int main (void) cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct5.c b/libffi/testsuite/libffi.call/nested_struct5.c index d8e3537..6c79845 100644 --- a/libffi/testsuite/libffi.call/nested_struct5.c +++ b/libffi/testsuite/libffi.call/nested_struct5.c @@ -58,6 +58,11 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -68,11 +73,6 @@ int main (void) cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_longdouble; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct6.c b/libffi/testsuite/libffi.call/nested_struct6.c index 2f2b25a..59d3579 100644 --- a/libffi/testsuite/libffi.call/nested_struct6.c +++ b/libffi/testsuite/libffi.call/nested_struct6.c @@ -66,6 +66,12 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; + struct A e_dbl = { 1.0, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -81,12 +87,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct A e_dbl = { 1.0, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct7.c b/libffi/testsuite/libffi.call/nested_struct7.c index 14c7023..27595e6 100644 --- a/libffi/testsuite/libffi.call/nested_struct7.c +++ b/libffi/testsuite/libffi.call/nested_struct7.c @@ -58,6 +58,11 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1; ffi_type* dbl_arg_types[3]; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12.0 , 127}, 99}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -68,11 +73,6 @@ int main (void) cls_struct_type1.type = FFI_TYPE_STRUCT; cls_struct_type1.elements = cls_struct_fields1; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12.0 , 127}, 99}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct8.c b/libffi/testsuite/libffi.call/nested_struct8.c index bb77ead..0e6c682 100644 --- a/libffi/testsuite/libffi.call/nested_struct8.c +++ b/libffi/testsuite/libffi.call/nested_struct8.c @@ -66,6 +66,12 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; + struct A e_dbl = { 1LL, 7}; + struct B f_dbl = {{12LL , 127}, 99}; + struct C g_dbl = { 2LL, 9}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -81,12 +87,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct A e_dbl = { 1LL, 7}; - struct B f_dbl = {{12LL , 127}, 99}; - struct C g_dbl = { 2LL, 9}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_uint64; cls_struct_fields[1] = &ffi_type_uchar; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/nested_struct9.c b/libffi/testsuite/libffi.call/nested_struct9.c index e9f541c..5f7ac67 100644 --- a/libffi/testsuite/libffi.call/nested_struct9.c +++ b/libffi/testsuite/libffi.call/nested_struct9.c @@ -66,6 +66,12 @@ int main (void) ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type* dbl_arg_types[4]; + struct A e_dbl = { 1, 7LL}; + struct B f_dbl = {{12.0 , 127}, 99}; + struct C g_dbl = { 2, 9}; + + struct B res_dbl; + cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; @@ -81,12 +87,6 @@ int main (void) cls_struct_type2.type = FFI_TYPE_STRUCT; cls_struct_type2.elements = cls_struct_fields2; - struct A e_dbl = { 1, 7LL}; - struct B f_dbl = {{12.0 , 127}, 99}; - struct C g_dbl = { 2, 9}; - - struct B res_dbl; - cls_struct_fields[0] = &ffi_type_uchar; cls_struct_fields[1] = &ffi_type_uint64; cls_struct_fields[2] = NULL; diff --git a/libffi/testsuite/libffi.call/stret_large.c b/libffi/testsuite/libffi.call/stret_large.c index 23a93b9..f32938c 100644 --- a/libffi/testsuite/libffi.call/stret_large.c +++ b/libffi/testsuite/libffi.call/stret_large.c @@ -82,17 +82,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct_108byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 7 }; struct_108byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 4 }; struct_108byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 3 }; struct_108byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 2 }; struct_108byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/stret_large2.c b/libffi/testsuite/libffi.call/stret_large2.c index e2599d2..3b0ef9a 100644 --- a/libffi/testsuite/libffi.call/stret_large2.c +++ b/libffi/testsuite/libffi.call/stret_large2.c @@ -84,17 +84,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct_116byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 7 }; struct_116byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 6.0, 4 }; struct_116byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 7.0, 3 }; struct_116byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 8.0, 2 }; struct_116byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/stret_medium.c b/libffi/testsuite/libffi.call/stret_medium.c index 1fc6a9e..973ee02 100644 --- a/libffi/testsuite/libffi.call/stret_medium.c +++ b/libffi/testsuite/libffi.call/stret_medium.c @@ -68,17 +68,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7.0 }; struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0 }; struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3.0 }; struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2.0 }; struct_72byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/stret_medium2.c b/libffi/testsuite/libffi.call/stret_medium2.c index cb2f2fb..84323d1 100644 --- a/libffi/testsuite/libffi.call/stret_medium2.c +++ b/libffi/testsuite/libffi.call/stret_medium2.c @@ -69,17 +69,17 @@ int main (void) ffi_type cls_struct_type; ffi_type* dbl_arg_types[5]; - cls_struct_type.size = 0; - cls_struct_type.alignment = 0; - cls_struct_type.type = FFI_TYPE_STRUCT; - cls_struct_type.elements = cls_struct_fields; - struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7 }; struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4 }; struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3 }; struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2 }; struct_72byte res_dbl; + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_double; cls_struct_fields[2] = &ffi_type_double; diff --git a/libffi/testsuite/libffi.call/strlen2_win32.c b/libffi/testsuite/libffi.call/strlen2_win32.c index b348e43..0d81061 100644 --- a/libffi/testsuite/libffi.call/strlen2_win32.c +++ b/libffi/testsuite/libffi.call/strlen2_win32.c @@ -8,12 +8,11 @@ #include "ffitest.h" -static size_t __attribute__((fastcall)) my_fastcall_strlen(char *s) +static size_t __FASTCALL__ my_fastcall_strlen(char *s) { return (strlen(s)); } -int d int main (void) { ffi_cif cif; diff --git a/libffi/testsuite/libffi.call/struct1.c b/libffi/testsuite/libffi.call/struct1.c index ea76c85..bfc23f64 100644 --- a/libffi/testsuite/libffi.call/struct1.c +++ b/libffi/testsuite/libffi.call/struct1.c @@ -30,6 +30,13 @@ int main (void) 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; @@ -39,11 +46,6 @@ int main (void) ts1_type_elements[2] = &ffi_type_uint; ts1_type_elements[3] = NULL; - 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)); - args[0] = &ts1_type; values[0] = &ts1_arg; diff --git a/libffi/testsuite/libffi.call/struct1_win32.c b/libffi/testsuite/libffi.call/struct1_win32.c index 4a7eb944..b756f5a 100644 --- a/libffi/testsuite/libffi.call/struct1_win32.c +++ b/libffi/testsuite/libffi.call/struct1_win32.c @@ -14,7 +14,7 @@ typedef struct unsigned int ui; } test_structure_1; -static __attribute__ ((fastcall)) test_structure_1 struct1(test_structure_1 ts) +static test_structure_1 __FASTCALL__ struct1(test_structure_1 ts) { ts.uc++; ts.d--; @@ -30,6 +30,13 @@ int main (void) 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; @@ -39,11 +46,6 @@ int main (void) ts1_type_elements[2] = &ffi_type_uint; ts1_type_elements[3] = NULL; - 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)); - args[0] = &ts1_type; values[0] = &ts1_arg; diff --git a/libffi/testsuite/libffi.call/struct2.c b/libffi/testsuite/libffi.call/struct2.c index 14bc9fd..d85385e 100644 --- a/libffi/testsuite/libffi.call/struct2.c +++ b/libffi/testsuite/libffi.call/struct2.c @@ -29,6 +29,11 @@ int main (void) 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; @@ -37,11 +42,6 @@ int main (void) ts2_type_elements[1] = &ffi_type_double; ts2_type_elements[2] = NULL; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - args[0] = &ts2_type; values[0] = &ts2_arg; diff --git a/libffi/testsuite/libffi.call/struct2_win32.c b/libffi/testsuite/libffi.call/struct2_win32.c index 2bfbdc5..5d02285 100644 --- a/libffi/testsuite/libffi.call/struct2_win32.c +++ b/libffi/testsuite/libffi.call/struct2_win32.c @@ -13,7 +13,7 @@ typedef struct double d2; } test_structure_2; -static test_structure_2 __attribute__ ((fastcall)) struct2(test_structure_2 ts) +static test_structure_2 __FASTCALL__ struct2(test_structure_2 ts) { ts.d1--; ts.d2--; @@ -29,6 +29,11 @@ int main (void) 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; @@ -37,11 +42,6 @@ int main (void) ts2_type_elements[1] = &ffi_type_double; ts2_type_elements[2] = NULL; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_2 *ts2_result = - (test_structure_2 *) malloc (sizeof(test_structure_2)); - args[0] = &ts2_type; values[0] = &ts2_arg; diff --git a/libffi/testsuite/libffi.call/struct3.c b/libffi/testsuite/libffi.call/struct3.c index e0bb09b..de883c2 100644 --- a/libffi/testsuite/libffi.call/struct3.c +++ b/libffi/testsuite/libffi.call/struct3.c @@ -27,6 +27,11 @@ int main (void) int compare_value; ffi_type ts3_type; ffi_type *ts3_type_elements[2]; + + test_structure_3 ts3_arg; + test_structure_3 *ts3_result = + (test_structure_3 *) malloc (sizeof(test_structure_3)); + ts3_type.size = 0; ts3_type.alignment = 0; ts3_type.type = FFI_TYPE_STRUCT; @@ -34,10 +39,6 @@ int main (void) ts3_type_elements[0] = &ffi_type_sint; ts3_type_elements[1] = NULL; - test_structure_3 ts3_arg; - test_structure_3 *ts3_result = - (test_structure_3 *) malloc (sizeof(test_structure_3)); - args[0] = &ts3_type; values[0] = &ts3_arg; diff --git a/libffi/testsuite/libffi.call/struct4.c b/libffi/testsuite/libffi.call/struct4.c index 0ad0a83..48e0349 100644 --- a/libffi/testsuite/libffi.call/struct4.c +++ b/libffi/testsuite/libffi.call/struct4.c @@ -28,21 +28,22 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts4_type; ffi_type *ts4_type_elements[4]; + + test_structure_4 ts4_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_4 *ts4_result = + (test_structure_4 *) malloc (sizeof(test_structure_4)); + ts4_type.size = 0; ts4_type.alignment = 0; ts4_type.type = FFI_TYPE_STRUCT; - test_structure_4 ts4_arg; ts4_type.elements = ts4_type_elements; ts4_type_elements[0] = &ffi_type_uint; ts4_type_elements[1] = &ffi_type_uint; ts4_type_elements[2] = &ffi_type_uint; ts4_type_elements[3] = NULL; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_4 *ts4_result = - (test_structure_4 *) malloc (sizeof(test_structure_4)); - args[0] = &ts4_type; values[0] = &ts4_arg; diff --git a/libffi/testsuite/libffi.call/struct5.c b/libffi/testsuite/libffi.call/struct5.c index c03cc97..28b1f0c 100644 --- a/libffi/testsuite/libffi.call/struct5.c +++ b/libffi/testsuite/libffi.call/struct5.c @@ -27,6 +27,13 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts5_type; ffi_type *ts5_type_elements[3]; + + test_structure_5 ts5_arg1, ts5_arg2; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_5 *ts5_result = + (test_structure_5 *) malloc (sizeof(test_structure_5)); + ts5_type.size = 0; ts5_type.alignment = 0; ts5_type.type = FFI_TYPE_STRUCT; @@ -35,12 +42,6 @@ int main (void) ts5_type_elements[1] = &ffi_type_schar; ts5_type_elements[2] = NULL; - test_structure_5 ts5_arg1, ts5_arg2; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_5 *ts5_result = - (test_structure_5 *) malloc (sizeof(test_structure_5)); - args[0] = &ts5_type; args[1] = &ts5_type; values[0] = &ts5_arg1; diff --git a/libffi/testsuite/libffi.call/struct6.c b/libffi/testsuite/libffi.call/struct6.c index 83db9af..0e26746 100644 --- a/libffi/testsuite/libffi.call/struct6.c +++ b/libffi/testsuite/libffi.call/struct6.c @@ -27,6 +27,13 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts6_type; ffi_type *ts6_type_elements[3]; + + test_structure_6 ts6_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_6 *ts6_result = + (test_structure_6 *) malloc (sizeof(test_structure_6)); + ts6_type.size = 0; ts6_type.alignment = 0; ts6_type.type = FFI_TYPE_STRUCT; @@ -35,13 +42,6 @@ int main (void) ts6_type_elements[1] = &ffi_type_double; ts6_type_elements[2] = NULL; - - test_structure_6 ts6_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_6 *ts6_result = - (test_structure_6 *) malloc (sizeof(test_structure_6)); - args[0] = &ts6_type; values[0] = &ts6_arg; diff --git a/libffi/testsuite/libffi.call/struct7.c b/libffi/testsuite/libffi.call/struct7.c index 58aac4c..8f2bbfd 100644 --- a/libffi/testsuite/libffi.call/struct7.c +++ b/libffi/testsuite/libffi.call/struct7.c @@ -29,6 +29,13 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts7_type; ffi_type *ts7_type_elements[4]; + + test_structure_7 ts7_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_7 *ts7_result = + (test_structure_7 *) malloc (sizeof(test_structure_7)); + ts7_type.size = 0; ts7_type.alignment = 0; ts7_type.type = FFI_TYPE_STRUCT; @@ -38,13 +45,6 @@ int main (void) ts7_type_elements[2] = &ffi_type_double; ts7_type_elements[3] = NULL; - - test_structure_7 ts7_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_7 *ts7_result = - (test_structure_7 *) malloc (sizeof(test_structure_7)); - args[0] = &ts7_type; values[0] = &ts7_arg; diff --git a/libffi/testsuite/libffi.call/struct8.c b/libffi/testsuite/libffi.call/struct8.c index c773ac7..266e1f0 100644 --- a/libffi/testsuite/libffi.call/struct8.c +++ b/libffi/testsuite/libffi.call/struct8.c @@ -31,6 +31,13 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts8_type; ffi_type *ts8_type_elements[5]; + + test_structure_8 ts8_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_8 *ts8_result = + (test_structure_8 *) malloc (sizeof(test_structure_8)); + ts8_type.size = 0; ts8_type.alignment = 0; ts8_type.type = FFI_TYPE_STRUCT; @@ -41,12 +48,6 @@ int main (void) ts8_type_elements[3] = &ffi_type_float; ts8_type_elements[4] = NULL; - test_structure_8 ts8_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_8 *ts8_result = - (test_structure_8 *) malloc (sizeof(test_structure_8)); - args[0] = &ts8_type; values[0] = &ts8_arg; diff --git a/libffi/testsuite/libffi.call/struct9.c b/libffi/testsuite/libffi.call/struct9.c index f30091f..efeb716 100644 --- a/libffi/testsuite/libffi.call/struct9.c +++ b/libffi/testsuite/libffi.call/struct9.c @@ -28,6 +28,13 @@ int main (void) void *values[MAX_ARGS]; ffi_type ts9_type; ffi_type *ts9_type_elements[3]; + + test_structure_9 ts9_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_9 *ts9_result = + (test_structure_9 *) malloc (sizeof(test_structure_9)); + ts9_type.size = 0; ts9_type.alignment = 0; ts9_type.type = FFI_TYPE_STRUCT; @@ -36,12 +43,6 @@ int main (void) ts9_type_elements[1] = &ffi_type_sint; ts9_type_elements[2] = NULL; - test_structure_9 ts9_arg; - - /* This is a hack to get a properly aligned result buffer */ - test_structure_9 *ts9_result = - (test_structure_9 *) malloc (sizeof(test_structure_9)); - args[0] = &ts9_type; values[0] = &ts9_arg; diff --git a/libffi/testsuite/libffi.call/testclosure.c b/libffi/testsuite/libffi.call/testclosure.c index 161cc89..ca31056 100644 --- a/libffi/testsuite/libffi.call/testclosure.c +++ b/libffi/testsuite/libffi.call/testclosure.c @@ -43,13 +43,13 @@ int main (void) ffi_type cls_struct_type0; ffi_type* dbl_arg_types[5]; + struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; + cls_struct_type0.size = 0; cls_struct_type0.alignment = 0; cls_struct_type0.type = FFI_TYPE_STRUCT; cls_struct_type0.elements = cls_struct_fields0; - struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; - cls_struct_fields0[0] = &ffi_type_float; cls_struct_fields0[1] = &ffi_type_float; cls_struct_fields0[2] = &ffi_type_float; diff --git a/libffi/testsuite/libffi.call/uninitialized.c b/libffi/testsuite/libffi.call/uninitialized.c new file mode 100644 index 0000000..f00d830 --- /dev/null +++ b/libffi/testsuite/libffi.call/uninitialized.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned char uc; + double d; + unsigned int ui; +} test_structure_1; + +static test_structure_1 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]; + + memset(&cif, 1, sizeof(cif)); + 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; + + 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)); + + args[0] = &ts1_type; + values[0] = &ts1_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 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/libffi/testsuite/libffi.call/va_1.c b/libffi/testsuite/libffi.call/va_1.c new file mode 100644 index 0000000..5c7cce9 --- /dev/null +++ b/libffi/testsuite/libffi.call/va_1.c @@ -0,0 +1,196 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* x86_64-*-*-* } } */ + +#include "ffitest.h" +#include <stdarg.h> + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static int +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + unsigned char uc; + signed char sc; + unsigned short us; + signed short ss; + unsigned int ui; + signed int si; + unsigned long ul; + signed long sl; + float f; + double d; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + + uc = va_arg (ap, unsigned); + sc = va_arg (ap, signed); + + us = va_arg (ap, unsigned); + ss = va_arg (ap, signed); + + ui = va_arg (ap, unsigned int); + si = va_arg (ap, signed int); + + ul = va_arg (ap, unsigned long); + sl = va_arg (ap, signed long); + + f = va_arg (ap, double); /* C standard promotes float->double + when anonymous */ + d = va_arg (ap, double); + + printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n", + s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b, + uc, sc, + us, ss, + ui, si, + ul, sl, + f, d); + va_end (ap); + return n + 1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[15]; + ffi_type* arg_types[15]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + int res; + + unsigned char uc; + signed char sc; + unsigned short us; + signed short ss; + unsigned int ui; + signed int si; + unsigned long ul; + signed long sl; + double d1; + double f1; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = &ffi_type_uint; + arg_types[5] = &ffi_type_sint; + arg_types[6] = &ffi_type_uint; + arg_types[7] = &ffi_type_sint; + arg_types[8] = &ffi_type_uint; + arg_types[9] = &ffi_type_sint; + arg_types[10] = &ffi_type_ulong; + arg_types[11] = &ffi_type_slong; + arg_types[12] = &ffi_type_double; + arg_types[13] = &ffi_type_double; + arg_types[14] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + uc = 9; + sc = 10; + us = 11; + ss = 12; + ui = 13; + si = 14; + ul = 15; + sl = 16; + f1 = 2.12; + d1 = 3.13; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = &uc; + args[5] = ≻ + args[6] = &us; + args[7] = &ss; + args[8] = &ui; + args[9] = &si; + args[10] = &ul; + args[11] = &sl; + args[12] = &f1; + args[13] = &d1; + args[14] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 42" } */ + + return 0; +} diff --git a/libffi/testsuite/libffi.call/va_struct1.c b/libffi/testsuite/libffi.call/va_struct1.c new file mode 100644 index 0000000..11d1f10 --- /dev/null +++ b/libffi/testsuite/libffi.call/va_struct1.c @@ -0,0 +1,121 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include <stdarg.h> + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static int +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + return n + 1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + int res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d\n", (int) res); + /* { dg-output "\nres: 42" } */ + + return 0; +} diff --git a/libffi/testsuite/libffi.call/va_struct2.c b/libffi/testsuite/libffi.call/va_struct2.c new file mode 100644 index 0000000..56f5b9c --- /dev/null +++ b/libffi/testsuite/libffi.call/va_struct2.c @@ -0,0 +1,123 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include <stdarg.h> + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static struct small_tag +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + s1.a += s2.a; + s1.b += s2.b; + return s1; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + struct small_tag res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &s_type, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d %d\n", res.a, res.b); + /* { dg-output "\nres: 12 14" } */ + + return 0; +} diff --git a/libffi/testsuite/libffi.call/va_struct3.c b/libffi/testsuite/libffi.call/va_struct3.c new file mode 100644 index 0000000..9a27e7f --- /dev/null +++ b/libffi/testsuite/libffi.call/va_struct3.c @@ -0,0 +1,125 @@ +/* Area: ffi_call + Purpose: Test passing struct in variable argument lists. + Limitations: none. + PR: none. + Originator: ARM Ltd. */ + +/* { dg-do run } */ +/* { dg-output "" { xfail avr32*-*-* } } */ + +#include "ffitest.h" +#include <stdarg.h> + +struct small_tag +{ + unsigned char a; + unsigned char b; +}; + +struct large_tag +{ + unsigned a; + unsigned b; + unsigned c; + unsigned d; + unsigned e; +}; + +static struct large_tag +test_fn (int n, ...) +{ + va_list ap; + struct small_tag s1; + struct small_tag s2; + struct large_tag l; + + va_start (ap, n); + s1 = va_arg (ap, struct small_tag); + l = va_arg (ap, struct large_tag); + s2 = va_arg (ap, struct small_tag); + printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, + s2.a, s2.b); + va_end (ap); + l.a += s1.a; + l.b += s1.b; + l.c += s2.a; + l.d += s2.b; + return l; +} + +int +main (void) +{ + ffi_cif cif; + void* args[5]; + ffi_type* arg_types[5]; + + ffi_type s_type; + ffi_type *s_type_elements[3]; + + ffi_type l_type; + ffi_type *l_type_elements[6]; + + struct small_tag s1; + struct small_tag s2; + struct large_tag l1; + + int n; + struct large_tag res; + + s_type.size = 0; + s_type.alignment = 0; + s_type.type = FFI_TYPE_STRUCT; + s_type.elements = s_type_elements; + + s_type_elements[0] = &ffi_type_uchar; + s_type_elements[1] = &ffi_type_uchar; + s_type_elements[2] = NULL; + + l_type.size = 0; + l_type.alignment = 0; + l_type.type = FFI_TYPE_STRUCT; + l_type.elements = l_type_elements; + + l_type_elements[0] = &ffi_type_uint; + l_type_elements[1] = &ffi_type_uint; + l_type_elements[2] = &ffi_type_uint; + l_type_elements[3] = &ffi_type_uint; + l_type_elements[4] = &ffi_type_uint; + l_type_elements[5] = NULL; + + arg_types[0] = &ffi_type_sint; + arg_types[1] = &s_type; + arg_types[2] = &l_type; + arg_types[3] = &s_type; + arg_types[4] = NULL; + + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &l_type, arg_types) == FFI_OK); + + s1.a = 5; + s1.b = 6; + + l1.a = 10; + l1.b = 11; + l1.c = 12; + l1.d = 13; + l1.e = 14; + + s2.a = 7; + s2.b = 8; + + n = 41; + + args[0] = &n; + args[1] = &s1; + args[2] = &l1; + args[3] = &s2; + args[4] = NULL; + + ffi_call(&cif, FFI_FN(test_fn), &res, args); + /* { dg-output "5 6 10 11 12 13 14 7 8" } */ + printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e); + /* { dg-output "\nres: 15 17 19 21 14" } */ + + return 0; +} |