From 1d6059446fb986d2de933f7ccf6fe38bcdf0c76c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 24 Oct 2019 05:25:11 -0400 Subject: [PATCH 001/231] Add missing dist files. --- Makefile.am | 65 ++++++------- testsuite/Makefile.am | 220 +++++++++++++++++++++--------------------- 2 files changed, 138 insertions(+), 147 deletions(-) diff --git a/Makefile.am b/Makefile.am index 07d928e31..c2db5fade 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ generate-darwin-source-and-headers.py \ libffi.xcodeproj/project.pbxproj \ libtool-ldflags libtool-version configure.host README.md \ - libffi.map.in + libffi.map.in LICENSE-BUILDTOOLS msvc_build # local.exp is generated by configure DISTCLEANFILES = local.exp @@ -77,43 +77,32 @@ noinst_HEADERS = \ src/xtensa/ffitarget.h \ src/dlmalloc.c -EXTRA_libffi_la_SOURCES = \ - src/aarch64/ffi.c src/aarch64/sysv.S \ - src/aarch64/win64_armasm.S \ - src/alpha/ffi.c src/alpha/osf.S \ - src/arc/ffi.c src/arc/arcompact.S \ - src/arm/ffi.c src/arm/sysv.S \ - src/arm/ffi.c src/arm/sysv_msvc_arm32.S \ - src/avr32/ffi.c src/avr32/sysv.S \ - src/bfin/ffi.c src/bfin/sysv.S \ - src/cris/ffi.c src/cris/sysv.S \ - src/frv/ffi.c src/frv/eabi.S \ - src/ia64/ffi.c src/ia64/unix.S \ - src/m32r/ffi.c src/m32r/sysv.S \ - src/m68k/ffi.c src/m68k/sysv.S \ - src/m88k/ffi.c src/m88k/obsd.S \ - src/metag/ffi.c src/metag/sysv.S \ - src/microblaze/ffi.c src/microblaze/sysv.S \ - src/mips/ffi.c src/mips/o32.S src/mips/n32.S \ - src/moxie/ffi.c src/moxie/eabi.S \ - src/nios2/ffi.c src/nios2/sysv.S \ - src/or1k/ffi.c src/or1k/sysv.S \ - src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ - src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ - src/powerpc/sysv.S src/powerpc/linux64.S \ - src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ - src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \ - src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ - src/riscv/ffi.c src/riscv/sysv.S \ - src/s390/ffi.c src/s390/sysv.S \ - src/sh/ffi.c src/sh/sysv.S \ - src/sh64/ffi.c src/sh64/sysv.S \ - src/sparc/ffi.c src/sparc/ffi64.c src/sparc/v8.S src/sparc/v9.S \ - src/tile/ffi.c src/tile/tile.S \ - src/vax/ffi.c src/vax/elfbsd.S \ - src/x86/ffi.c src/x86/sysv.S \ - src/x86/ffiw64.c src/x86/win64.S \ - src/x86/ffi64.c src/x86/unix64.S \ +EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \ + src/aarch64/win64_armasm.S src/alpha/ffi.c src/alpha/osf.S \ + src/arc/ffi.c src/arc/arcompact.S src/arm/ffi.c \ + src/arm/sysv.S src/arm/ffi.c src/arm/sysv_msvc_arm32.S \ + src/avr32/ffi.c src/avr32/sysv.S src/bfin/ffi.c \ + src/bfin/sysv.S src/cris/ffi.c src/cris/sysv.S src/frv/ffi.c \ + src/frv/eabi.S src/ia64/ffi.c src/ia64/unix.S src/m32r/ffi.c \ + src/m32r/sysv.S src/m68k/ffi.c src/m68k/sysv.S src/m88k/ffi.c \ + src/m88k/obsd.S src/metag/ffi.c src/metag/sysv.S \ + src/microblaze/ffi.c src/microblaze/sysv.S src/mips/ffi.c \ + src/mips/o32.S src/mips/n32.S src/moxie/ffi.c \ + src/moxie/eabi.S src/nios2/ffi.c src/nios2/sysv.S \ + src/or1k/ffi.c src/or1k/sysv.S src/pa/ffi.c src/pa/linux.S \ + src/pa/hpux32.S src/powerpc/ffi.c src/powerpc/ffi_sysv.c \ + src/powerpc/ffi_linux64.c src/powerpc/sysv.S \ + src/powerpc/linux64.S src/powerpc/linux64_closure.S \ + src/powerpc/ppc_closure.S src/powerpc/aix.S \ + src/powerpc/darwin.S src/powerpc/aix_closure.S \ + src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ + src/riscv/ffi.c src/riscv/sysv.S src/s390/ffi.c \ + src/s390/sysv.S src/sh/ffi.c src/sh/sysv.S src/sh64/ffi.c \ + src/sh64/sysv.S src/sparc/ffi.c src/sparc/ffi64.c \ + src/sparc/v8.S src/sparc/v9.S src/tile/ffi.c src/tile/tile.S \ + src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \ + src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \ + src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \ src/xtensa/ffi.c src/xtensa/sysv.S TARGET_OBJ = @TARGET_OBJ@ diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 40c789fa0..ccc78a1f3 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -6,112 +6,114 @@ EXTRA_DEJAGNU_SITE_CONFIG=../local.exp CLEANFILES = *.exe core* *.log *.sum -EXTRA_DIST = lib/target-libpath.exp lib/libffi.exp lib/wrapper.exp \ -libffi.call/strlen4.c libffi.call/cls_multi_sshort.c \ -libffi.call/cls_align_longdouble_split2.c libffi.call/cls_1_1byte.c \ -libffi.call/struct10.c libffi.call/cls_uint_va.c \ -libffi.call/many_mixed.c libffi.call/float.c libffi.call/struct5.c \ -libffi.call/return_fl3.c libffi.call/cls_3_1byte.c \ -libffi.call/return_fl1.c libffi.call/cls_many_mixed_args.c \ -libffi.call/cls_20byte1.c libffi.call/cls_pointer_stack.c \ -libffi.call/cls_align_float.c libffi.call/call.exp \ -libffi.call/pyobjc-tc.c libffi.call/float_va.c \ -libffi.call/cls_5_1_byte.c libffi.call/cls_9byte1.c \ -libffi.call/cls_align_uint32.c libffi.call/stret_medium.c \ -libffi.call/cls_3byte1.c libffi.call/cls_align_uint64.c \ -libffi.call/cls_longdouble_va.c libffi.call/cls_align_pointer.c \ -libffi.call/cls_19byte.c libffi.call/cls_ushort.c \ -libffi.call/cls_align_sint32.c libffi.call/struct8.c \ -libffi.call/pr1172638.c libffi.call/cls_ulonglong.c \ -libffi.call/cls_struct_va1.c libffi.call/cls_9byte2.c \ -libffi.call/closure_fn5.c libffi.call/cls_5byte.c \ -libffi.call/cls_3float.c libffi.call/return_sc.c \ -libffi.call/cls_schar.c libffi.call/closure_fn4.c \ -libffi.call/cls_uchar_va.c libffi.call/closure_fn0.c \ -libffi.call/huge_struct.c libffi.call/va_struct1.c \ -libffi.call/cls_ushort_va.c libffi.call/struct9.c libffi.call/va_1.c \ -libffi.call/cls_64byte.c libffi.call/va_struct2.c \ -libffi.call/cls_longdouble.c libffi.call/return_fl2.c \ -libffi.call/cls_ulong_va.c libffi.call/cls_6_1_byte.c \ -libffi.call/cls_align_uint16.c libffi.call/closure_fn2.c \ -libffi.call/align_mixed.c libffi.call/unwindtest_ffi_call.cc \ -libffi.call/cls_multi_ushortchar.c libffi.call/cls_8byte.c \ -libffi.call/ffitest.h libffi.call/nested_struct8.c \ -libffi.call/cls_pointer.c libffi.call/nested_struct2.c \ -libffi.call/nested_struct.c libffi.call/struct4.c \ -libffi.call/cls_multi_schar.c libffi.call/cls_align_longdouble_split.c \ -libffi.call/cls_uchar.c libffi.call/return_ldl.c \ -libffi.call/nested_struct9.c libffi.call/cls_float.c \ -libffi.call/stret_medium2.c libffi.call/closure_loc_fn0.c \ -libffi.call/float3.c libffi.call/cls_6byte.c libffi.call/return_sl.c \ -libffi.call/closure_simple.c libffi.call/return_dbl1.c \ -libffi.call/cls_align_double.c libffi.call/cls_multi_uchar.c \ -libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ -libffi.call/closure_fn3.c libffi.call/return_ll1.c \ -libffi.call/return_dbl2.c libffi.call/cls_align_sint64.c \ -libffi.call/nested_struct1.c libffi.call/negint.c \ -libffi.call/nested_struct3.c libffi.call/unwindtest.cc \ -libffi.call/struct2.c libffi.call/struct3.c libffi.call/return_fl.c \ -libffi.call/nested_struct5.c libffi.call/cls_multi_ushort.c \ -libffi.call/nested_struct11.c libffi.call/cls_multi_sshortchar.c \ -libffi.call/cls_align_longdouble.c libffi.call/cls_dbls_struct.c \ -libffi.call/cls_many_mixed_float_double.c libffi.call/stret_large.c \ -libffi.call/stret_large2.c libffi.call/cls_align_sint16.c \ -libffi.call/cls_2byte.c libffi.call/offsets.c libffi.call/struct7.c \ -libffi.call/nested_struct4.c libffi.call/problem1.c \ -libffi.call/va_struct3.c libffi.call/testclosure.c \ -libffi.call/float1.c libffi.call/nested_struct6.c \ -libffi.call/cls_4byte.c libffi.call/cls_24byte.c \ -libffi.call/uninitialized.c libffi.call/many2.c \ -libffi.call/nested_struct10.c libffi.call/struct6.c \ -libffi.call/strlen2.c libffi.call/float2.c libffi.call/cls_uint.c \ -libffi.call/cls_12byte.c libffi.call/return_ul.c \ -libffi.call/cls_sint.c libffi.call/cls_7_1_byte.c \ -libffi.call/struct1.c libffi.call/cls_sshort.c \ -libffi.call/cls_16byte.c libffi.call/strlen3.c \ -libffi.call/nested_struct7.c libffi.call/cls_double_va.c \ -libffi.call/return_dbl.c libffi.call/cls_3byte2.c libffi.call/float4.c \ -libffi.call/cls_double.c libffi.call/many.c libffi.call/cls_7byte.c \ -libffi.call/strlen.c libffi.call/closure_fn6.c libffi.call/return_uc.c \ -libffi.call/closure_fn1.c libffi.call/cls_20byte.c \ -libffi.call/cls_18byte.c libffi.call/err_bad_abi.c \ -libffi.call/many_double.c libffi.call/return_ll.c \ -libffi.call/promotion.c libffi.complex/complex_defs_longdouble.inc \ -libffi.complex/cls_align_complex_float.c \ -libffi.complex/cls_complex_va_float.c \ -libffi.complex/cls_complex_struct_float.c \ -libffi.complex/return_complex2_longdouble.c \ -libffi.complex/cls_complex_float.c \ -libffi.complex/return_complex_longdouble.c \ -libffi.complex/return_complex2_float.c libffi.complex/cls_complex.inc \ -libffi.complex/cls_complex_va_longdouble.c \ -libffi.complex/return_complex_double.c \ -libffi.complex/return_complex.inc libffi.complex/many_complex.inc \ -libffi.complex/complex_float.c libffi.complex/cls_align_complex.inc \ -libffi.complex/return_complex2_double.c \ -libffi.complex/many_complex_float.c libffi.complex/ffitest.h \ -libffi.complex/return_complex1_double.c \ -libffi.complex/cls_complex_struct_longdouble.c \ -libffi.complex/complex_defs_double.inc \ -libffi.complex/cls_complex_va_double.c \ -libffi.complex/many_complex_double.c \ -libffi.complex/return_complex2.inc \ -libffi.complex/return_complex1_float.c \ -libffi.complex/complex_longdouble.c \ -libffi.complex/complex_defs_float.inc \ -libffi.complex/cls_complex_double.c \ -libffi.complex/cls_align_complex_double.c \ -libffi.complex/cls_align_complex_longdouble.c \ -libffi.complex/complex_double.c libffi.complex/cls_complex_va.inc \ -libffi.complex/many_complex_longdouble.c libffi.complex/complex.inc \ -libffi.complex/return_complex1_longdouble.c \ -libffi.complex/complex_int.c libffi.complex/cls_complex_longdouble.c \ -libffi.complex/cls_complex_struct_double.c \ -libffi.complex/return_complex1.inc libffi.complex/complex.exp \ -libffi.complex/cls_complex_struct.inc \ -libffi.complex/return_complex_float.c libffi.go/closure1.c \ -libffi.go/aa-direct.c libffi.go/ffitest.h libffi.go/go.exp \ -libffi.go/static-chain.h libffi.bhaible/bhaible.exp \ -libffi.bhaible/test-call.c libffi.bhaible/alignof.h \ -libffi.bhaible/testcases.c libffi.bhaible/test-callback.c \ -libffi.bhaible/Makefile libffi.bhaible/README config/default.exp +EXTRA_DIST = lib/target-libpath.exp lib/libffi.exp lib/wrapper.exp \ +libffi.call/strlen4.c libffi.call/cls_multi_sshort.c \ +libffi.call/cls_align_longdouble_split2.c libffi.call/cls_1_1byte.c \ +libffi.call/struct10.c libffi.call/cls_uint_va.c \ +libffi.call/many_mixed.c libffi.call/float.c libffi.call/struct5.c \ +libffi.call/return_fl3.c libffi.call/cls_3_1byte.c \ +libffi.call/return_fl1.c libffi.call/cls_many_mixed_args.c \ +libffi.call/cls_20byte1.c libffi.call/cls_pointer_stack.c \ +libffi.call/cls_align_float.c libffi.call/call.exp \ +libffi.call/pyobjc-tc.c libffi.call/float_va.c \ +libffi.call/cls_5_1_byte.c libffi.call/cls_9byte1.c \ +libffi.call/cls_align_uint32.c libffi.call/stret_medium.c \ +libffi.call/cls_3byte1.c libffi.call/cls_align_uint64.c \ +libffi.call/cls_longdouble_va.c libffi.call/cls_align_pointer.c \ +libffi.call/cls_19byte.c libffi.call/cls_ushort.c \ +libffi.call/cls_align_sint32.c libffi.call/struct8.c \ +libffi.call/pr1172638.c libffi.call/cls_ulonglong.c \ +libffi.call/cls_struct_va1.c libffi.call/cls_9byte2.c \ +libffi.call/closure_fn5.c libffi.call/cls_5byte.c \ +libffi.call/cls_3float.c libffi.call/return_sc.c \ +libffi.call/cls_schar.c libffi.call/closure_fn4.c \ +libffi.call/cls_uchar_va.c libffi.call/closure_fn0.c \ +libffi.call/huge_struct.c libffi.call/va_struct1.c \ +libffi.call/cls_ushort_va.c libffi.call/struct9.c libffi.call/va_1.c \ +libffi.call/cls_64byte.c libffi.call/va_struct2.c \ +libffi.call/cls_longdouble.c libffi.call/return_fl2.c \ +libffi.call/cls_ulong_va.c libffi.call/cls_6_1_byte.c \ +libffi.call/cls_align_uint16.c libffi.call/closure_fn2.c \ +libffi.call/align_mixed.c libffi.call/unwindtest_ffi_call.cc \ +libffi.call/cls_multi_ushortchar.c libffi.call/cls_8byte.c \ +libffi.call/ffitest.h libffi.call/nested_struct8.c \ +libffi.call/cls_pointer.c libffi.call/nested_struct2.c \ +libffi.call/nested_struct.c libffi.call/struct4.c \ +libffi.call/cls_multi_schar.c \ +libffi.call/cls_align_longdouble_split.c libffi.call/cls_uchar.c \ +libffi.call/return_ldl.c libffi.call/nested_struct9.c \ +libffi.call/cls_float.c libffi.call/stret_medium2.c \ +libffi.call/closure_loc_fn0.c libffi.call/float3.c \ +libffi.call/cls_6byte.c libffi.call/return_sl.c \ +libffi.call/closure_simple.c libffi.call/return_dbl1.c \ +libffi.call/cls_align_double.c libffi.call/cls_multi_uchar.c \ +libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ +libffi.call/closure_fn3.c libffi.call/return_ll1.c \ +libffi.call/return_dbl2.c libffi.call/cls_align_sint64.c \ +libffi.call/nested_struct1.c libffi.call/negint.c \ +libffi.call/nested_struct3.c libffi.call/unwindtest.cc \ +libffi.call/struct2.c libffi.call/struct3.c libffi.call/return_fl.c \ +libffi.call/nested_struct5.c libffi.call/cls_multi_ushort.c \ +libffi.call/nested_struct11.c libffi.call/cls_multi_sshortchar.c \ +libffi.call/cls_align_longdouble.c libffi.call/cls_dbls_struct.c \ +libffi.call/cls_many_mixed_float_double.c libffi.call/stret_large.c \ +libffi.call/stret_large2.c libffi.call/cls_align_sint16.c \ +libffi.call/cls_2byte.c libffi.call/offsets.c libffi.call/struct7.c \ +libffi.call/nested_struct4.c libffi.call/problem1.c \ +libffi.call/va_struct3.c libffi.call/testclosure.c \ +libffi.call/float1.c libffi.call/nested_struct6.c \ +libffi.call/cls_4byte.c libffi.call/cls_24byte.c \ +libffi.call/uninitialized.c libffi.call/many2.c \ +libffi.call/nested_struct10.c libffi.call/struct6.c \ +libffi.call/strlen2.c libffi.call/float2.c libffi.call/cls_uint.c \ +libffi.call/cls_12byte.c libffi.call/return_ul.c \ +libffi.call/cls_sint.c libffi.call/cls_7_1_byte.c \ +libffi.call/struct1.c libffi.call/cls_sshort.c \ +libffi.call/cls_16byte.c libffi.call/strlen3.c \ +libffi.call/nested_struct7.c libffi.call/cls_double_va.c \ +libffi.call/return_dbl.c libffi.call/cls_3byte2.c \ +libffi.call/float4.c libffi.call/cls_double.c libffi.call/many.c \ +libffi.call/cls_7byte.c libffi.call/strlen.c \ +libffi.call/closure_fn6.c libffi.call/return_uc.c \ +libffi.call/closure_fn1.c libffi.call/cls_20byte.c \ +libffi.call/cls_18byte.c libffi.call/err_bad_abi.c \ +libffi.call/many_double.c libffi.call/return_ll.c \ +libffi.call/promotion.c libffi.complex/complex_defs_longdouble.inc \ +libffi.call/align_stdcall.c libffi.complex/cls_align_complex_float.c \ +libffi.complex/cls_complex_va_float.c \ +libffi.complex/cls_complex_struct_float.c \ +libffi.complex/return_complex2_longdouble.c \ +libffi.complex/cls_complex_float.c \ +libffi.complex/return_complex_longdouble.c \ +libffi.complex/return_complex2_float.c libffi.complex/cls_complex.inc \ +libffi.complex/cls_complex_va_longdouble.c \ +libffi.complex/return_complex_double.c \ +libffi.complex/return_complex.inc libffi.complex/many_complex.inc \ +libffi.complex/complex_float.c libffi.complex/cls_align_complex.inc \ +libffi.complex/return_complex2_double.c \ +libffi.complex/many_complex_float.c libffi.complex/ffitest.h \ +libffi.complex/return_complex1_double.c \ +libffi.complex/cls_complex_struct_longdouble.c \ +libffi.complex/complex_defs_double.inc \ +libffi.complex/cls_complex_va_double.c \ +libffi.complex/many_complex_double.c \ +libffi.complex/return_complex2.inc \ +libffi.complex/return_complex1_float.c \ +libffi.complex/complex_longdouble.c \ +libffi.complex/complex_defs_float.inc \ +libffi.complex/cls_complex_double.c \ +libffi.complex/cls_align_complex_double.c \ +libffi.complex/cls_align_complex_longdouble.c \ +libffi.complex/complex_double.c libffi.complex/cls_complex_va.inc \ +libffi.complex/many_complex_longdouble.c libffi.complex/complex.inc \ +libffi.complex/return_complex1_longdouble.c \ +libffi.complex/complex_int.c libffi.complex/cls_complex_longdouble.c \ +libffi.complex/cls_complex_struct_double.c \ +libffi.complex/return_complex1.inc libffi.complex/complex.exp \ +libffi.complex/cls_complex_struct.inc \ +libffi.complex/return_complex_float.c libffi.go/closure1.c \ +libffi.go/aa-direct.c libffi.go/ffitest.h libffi.go/go.exp \ +libffi.go/static-chain.h libffi.bhaible/bhaible.exp \ +libffi.bhaible/test-call.c libffi.bhaible/alignof.h \ +libffi.bhaible/testcases.c libffi.bhaible/test-callback.c \ +libffi.bhaible/Makefile libffi.bhaible/README config/default.exp From 90fb897839bb7006a2f751d283e3d23b3bfec1ea Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 24 Oct 2019 06:24:14 -0400 Subject: [PATCH 002/231] Strip build status from README.md at 'make dist' time. --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index c2db5fade..ff12eeef3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,3 +155,4 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) dist-hook: if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog + s=`awk '/was released on/{ print NR; exit}' $(top_srcdir)/README.md`; tail -n +$$(($$s-1)) $(top_srcdir)/README.md > $(distdir)/README.md From ec042885cfa5a9450bfcc87152a41529d26545de Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 24 Oct 2019 06:39:00 -0400 Subject: [PATCH 003/231] Don't test ppc64le with buggy qemu. --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b13908219..2c44f9582 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,7 @@ matrix: include: - os: osx env: HOST=arm-apple-darwin - - os: linux - env: HOST=ppc64le-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - - os: linux - env: HOST=ppc64le-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - - os: linux - env: HOST=ppc64le-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" + - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux From 9b10df3be2d8f81876b7cc90ee5d8833ccdf6b34 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 24 Oct 2019 06:41:11 -0400 Subject: [PATCH 004/231] Remove some debugging output --- .travis/install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis/install.sh b/.travis/install.sh index 45a188a9f..b0b05bdcb 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -20,8 +20,6 @@ else echo 'deb https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list sudo apt-get clean # clear the cache sudo apt-get update ## -qq - # debug... - curl https://repos.moxielogic.org:7114/MoxieLogic/dists/moxiedev/main/binary-amd64/Packages sudo apt-get update sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim ;; From 52b066f04fdd81c1037e1cb714a07a2a352bcf9b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 24 Oct 2019 07:03:43 -0400 Subject: [PATCH 005/231] Update versions to 3.3-rc1 --- README.md | 2 +- configure.ac | 2 +- doc/version.texi | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5a8eeeefc..e988d80d3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.3-rc0 was released on April 2, 2018. Check the libffi web +libffi-3.3-rc1 was released on October 24, 2019. Check the libffi web page for updates: . diff --git a/configure.ac b/configure.ac index 055fe183c..edbfdece7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.3-rc0], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.3-rc1], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index 4d2f57448..f52bc68b1 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 2 April 2018 -@set UPDATED-MONTH April 2018 -@set EDITION 3.3-rc0 -@set VERSION 3.3-rc0 +@set UPDATED 24 October 2019 +@set UPDATED-MONTH October 2019 +@set EDITION 3.3-rc1 +@set VERSION 3.3-rc1 From ca112537df7b9cdbccad7541aa3cb43b2a2dac9a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 26 Oct 2019 07:26:30 -0400 Subject: [PATCH 006/231] Add missing build script, make_sunver.pl. --- LICENSE-BUILDTOOLS | 9 +- Makefile.am | 4 +- make_sunver.pl | 333 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 340 insertions(+), 6 deletions(-) create mode 100644 make_sunver.pl diff --git a/LICENSE-BUILDTOOLS b/LICENSE-BUILDTOOLS index 869c70385..d1d626e00 100644 --- a/LICENSE-BUILDTOOLS +++ b/LICENSE-BUILDTOOLS @@ -1,10 +1,11 @@ The libffi source distribution contains certain code that is not part of libffi, and is only used as tooling to assist with the building and testing of libffi. This includes the msvcc.sh script used to wrap the -Microsoft compiler with GNU compatible command-line options, and the -libffi test code distributed in the testsuite/libffi.bhaible -directory. This code is distributed with libffi for the purpose of -convenience only, and libffi is in no way derived from this code. +Microsoft compiler with GNU compatible command-line options, +make_sunver.pl, and the libffi test code distributed in the +testsuite/libffi.bhaible directory. This code is distributed with +libffi for the purpose of convenience only, and libffi is in no way +derived from this code. msvcc.sh an testsuite/libffi.bhaible are both distributed under the terms of the GNU GPL version 2, as below. diff --git a/Makefile.am b/Makefile.am index ff12eeef3..8138879b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -131,9 +131,9 @@ endif if LIBFFI_BUILD_VERSIONED_SHLIB_SUN libffi_version_script = -Wl,-M,libffi.map-sun libffi_version_dep = libffi.map-sun -libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \ +libffi.map-sun : libffi.map $(top_srcdir)/make_sunver.pl \ $(libffi_la_OBJECTS) $(libffi_la_LIBADD) - perl $(top_srcdir)/../contrib/make_sunver.pl libffi.map \ + perl $(top_srcdir)/make_sunver.pl libffi.map \ `echo $(libffi_la_OBJECTS) $(libffi_la_LIBADD) | \ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \ > $@ || (rm -f $@ ; exit 1) diff --git a/make_sunver.pl b/make_sunver.pl new file mode 100644 index 000000000..8a90b1fea --- /dev/null +++ b/make_sunver.pl @@ -0,0 +1,333 @@ +#!/usr/bin/perl -w + +# make_sunver.pl +# +# This script takes at least two arguments, a GNU style version script and +# a list of object and archive files, and generates a corresponding Sun +# style version script as follows: +# +# Each glob pattern, C++ mangled pattern or literal in the input script is +# matched against all global symbols in the input objects, emitting those +# that matched (or nothing if no match was found). +# A comment with the original pattern and its type is left in the output +# file to make it easy to understand the matches. +# +# It uses elfdump when present (native), GNU readelf otherwise. +# It depends on the GNU version of c++filt, since it must understand the +# GNU mangling style. + +use FileHandle; +use IPC::Open2; + +# Enforce C locale. +$ENV{'LC_ALL'} = "C"; +$ENV{'LANG'} = "C"; + +# Input version script, GNU style. +my $symvers = shift; + +########## +# Get all the symbols from the library, match them, and add them to a hash. + +my %sym_hash = (); + +# List of objects and archives to process. +my @OBJECTS = (); + +# List of shared objects to omit from processing. +my @SHAREDOBJS = (); + +# Filter out those input archives that have corresponding shared objects to +# avoid adding all symbols matched in the archive to the output map. +foreach $file (@ARGV) { + if (($so = $file) =~ s/\.a$/.so/ && -e $so) { + printf STDERR "omitted $file -> $so\n"; + push (@SHAREDOBJS, $so); + } else { + push (@OBJECTS, $file); + } +} + +# We need to detect and ignore hidden symbols. Solaris nm can only detect +# this in the harder to parse default output format, and GNU nm not at all, +# so use elfdump -s in the native case and GNU readelf -s otherwise. +# GNU objdump -t cannot be used since it produces a variable number of +# columns. + +# The path to elfdump. +my $elfdump = "/usr/ccs/bin/elfdump"; + +if (-f $elfdump) { + open ELFDUMP,$elfdump.' -s '.(join ' ',@OBJECTS).'|' or die $!; + my $skip_arsym = 0; + + while () { + chomp; + + # Ignore empty lines. + if (/^$/) { + # End of archive symbol table, stop skipping. + $skip_arsym = 0 if $skip_arsym; + next; + } + + # Keep skipping until end of archive symbol table. + next if ($skip_arsym); + + # Ignore object name header for individual objects and archives. + next if (/:$/); + + # Ignore table header lines. + next if (/^Symbol Table Section:/); + next if (/index.*value.*size/); + + # Start of archive symbol table: start skipping. + if (/^Symbol Table: \(archive/) { + $skip_arsym = 1; + next; + } + + # Split table. + (undef, undef, undef, undef, $bind, $oth, undef, $shndx, $name) = split; + + # Error out for unknown input. + die "unknown input line:\n$_" unless defined($bind); + + # Ignore local symbols. + next if ($bind eq "LOCL"); + # Ignore hidden symbols. + next if ($oth eq "H"); + # Ignore undefined symbols. + next if ($shndx eq "UNDEF"); + # Error out for unhandled cases. + if ($bind !~ /^(GLOB|WEAK)/ or $oth ne "D") { + die "unhandled symbol:\n$_"; + } + + # Remember symbol. + $sym_hash{$name}++; + } + close ELFDUMP or die "$elfdump error"; +} else { + open READELF, 'readelf -s -W '.(join ' ',@OBJECTS).'|' or die $!; + # Process each symbol. + while () { + chomp; + + # Ignore empty lines. + next if (/^$/); + + # Ignore object name header. + next if (/^File: .*$/); + + # Ignore table header lines. + next if (/^Symbol table.*contains.*:/); + next if (/Num:.*Value.*Size/); + + # Split table. + (undef, undef, undef, undef, $bind, $vis, $ndx, $name) = split; + + # Error out for unknown input. + die "unknown input line:\n$_" unless defined($bind); + + # Ignore local symbols. + next if ($bind eq "LOCAL"); + # Ignore hidden symbols. + next if ($vis eq "HIDDEN"); + # Ignore undefined symbols. + next if ($ndx eq "UND"); + # Error out for unhandled cases. + if ($bind !~ /^(GLOBAL|WEAK)/ or $vis ne "DEFAULT") { + die "unhandled symbol:\n$_"; + } + + # Remember symbol. + $sym_hash{$name}++; + } + close READELF or die "readelf error"; +} + +########## +# The various types of glob patterns. +# +# A glob pattern that is to be applied to the demangled name: 'cxx'. +# A glob patterns that applies directly to the name in the .o files: 'glob'. +# This pattern is ignored; used for local variables (usually just '*'): 'ign'. + +# The type of the current pattern. +my $glob = 'glob'; + +# We're currently inside `extern "C++"', which Sun ld doesn't understand. +my $in_extern = 0; + +# The c++filt command to use. This *must* be GNU c++filt; the Sun Studio +# c++filt doesn't handle the GNU mangling style. +my $cxxfilt = $ENV{'CXXFILT'} || "c++filt"; + +# The current version name. +my $current_version = ""; + +# Was there any attempt to match a symbol to this version? +my $matches_attempted; + +# The number of versions which matched this symbol. +my $matched_symbols; + +open F,$symvers or die $!; + +# Print information about generating this file +print "# This file was generated by make_sunver.pl. DO NOT EDIT!\n"; +print "# It was generated by:\n"; +printf "# %s %s %s\n", $0, $symvers, (join ' ',@ARGV); +printf "# Omitted archives with corresponding shared libraries: %s\n", + (join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0; +print "#\n\n"; + +while () { + # Lines of the form '};' + if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) { + $glob = 'glob'; + if ($in_extern) { + $in_extern--; + print "$1##$2\n"; + } else { + print; + } + next; + } + + # Lines of the form '} SOME_VERSION_NAME_1.0;' + if (/^[ \t]*\}[ \tA-Z0-9_.a-z]+;[ \t]*$/) { + $glob = 'glob'; + # We tried to match symbols agains this version, but none matched. + # Emit dummy hidden symbol to avoid marking this version WEAK. + if ($matches_attempted && $matched_symbols == 0) { + print " hidden:\n"; + print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n"; + } + print; next; + } + + # Comment and blank lines + if (/^[ \t]*\#/) { print; next; } + if (/^[ \t]*$/) { print; next; } + + # Lines of the form '{' + if (/^([ \t]*){$/) { + if ($in_extern) { + print "$1##{\n"; + } else { + print; + } + next; + } + + # Lines of the form 'SOME_VERSION_NAME_1.1 {' + if (/^([A-Z0-9_.]+)[ \t]+{$/) { + # Record version name. + $current_version = $1; + # Reset match attempts, #matched symbols for this version. + $matches_attempted = 0; + $matched_symbols = 0; + print; + next; + } + + # Ignore 'global:' + if (/^[ \t]*global:$/) { print; next; } + + # After 'local:', globs should be ignored, they won't be exported. + if (/^[ \t]*local:$/) { + $glob = 'ign'; + print; + next; + } + + # After 'extern "C++"', globs are C++ patterns + if (/^([ \t]*)(extern \"C\+\+\"[ \t]*)$/) { + $in_extern++; + $glob = 'cxx'; + # Need to comment, Sun ld cannot handle this. + print "$1##$2\n"; next; + } + + # Chomp newline now we're done with passing through the input file. + chomp; + + # Catch globs. Note that '{}' is not allowed in globs by this script, + # so only '*' and '[]' are available. + if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) { + my $ws = $1; + my $ptn = $2; + # Turn the glob into a regex by replacing '*' with '.*', '?' with '.'. + # Keep $ptn so we can still print the original form. + ($pattern = $ptn) =~ s/\*/\.\*/g; + $pattern =~ s/\?/\./g; + + if ($glob eq 'ign') { + # We're in a local: * section; just continue. + print "$_\n"; + next; + } + + # Print the glob commented for human readers. + print "$ws##$ptn ($glob)\n"; + # We tried to match a symbol to this version. + $matches_attempted++; + + if ($glob eq 'glob') { + my %ptn_syms = (); + + # Match ptn against symbols in %sym_hash. + foreach my $sym (keys %sym_hash) { + # Maybe it matches one of the patterns based on the symbol in + # the .o file. + $ptn_syms{$sym}++ if ($sym =~ /^$pattern$/); + } + + foreach my $sym (sort keys(%ptn_syms)) { + $matched_symbols++; + print "$ws$sym;\n"; + } + } elsif ($glob eq 'cxx') { + my %dem_syms = (); + + # Verify that we're actually using GNU c++filt. Other versions + # most likely cannot handle GNU style symbol mangling. + my $cxxout = `$cxxfilt --version 2>&1`; + $cxxout =~ m/GNU/ or die "$0 requires GNU c++filt to function"; + + # Talk to c++filt through a pair of file descriptors. + # Need to start a fresh instance per pattern, otherwise the + # process grows to 500+ MB. + my $pid = open2(*FILTIN, *FILTOUT, $cxxfilt) or die $!; + + # Match ptn against symbols in %sym_hash. + foreach my $sym (keys %sym_hash) { + # No? Well, maybe its demangled form matches one of those + # patterns. + printf FILTOUT "%s\n",$sym; + my $dem = ; + chomp $dem; + $dem_syms{$sym}++ if ($dem =~ /^$pattern$/); + } + + close FILTOUT or die "c++filt error"; + close FILTIN or die "c++filt error"; + # Need to wait for the c++filt process to avoid lots of zombies. + waitpid $pid, 0; + + foreach my $sym (sort keys(%dem_syms)) { + $matched_symbols++; + print "$ws$sym;\n"; + } + } else { + # No? Well, then ignore it. + } + next; + } + # Important sanity check. This script can't handle lots of formats + # that GNU ld can, so be sure to error out if one is seen! + die "strange line `$_'"; +} +close F; From a8efc2f7897b439fdf2144329d35fea820498dc7 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sat, 26 Oct 2019 14:57:05 +0200 Subject: [PATCH 007/231] Fix FFI_STDCALL ABI (#514) Even for a stdcall function, the stack alignment is still the responsibility of the caller. Remember the original, not stack-aligned argument size, but align when setting up a stack frame. In ffi_closure_inner, return the true argument size, so that ffi_[go_]closure_STDCALL doesn't adjust too much. --- src/x86/ffi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 883cc4a58..9a592185a 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -51,6 +51,13 @@ # define __declspec(x) __attribute__((x)) #endif +#if defined(_MSC_VER) && defined(_M_IX86) +/* Stack is not 16-byte aligned on Windows. */ +#define STACK_ALIGN(bytes) (bytes) +#else +#define STACK_ALIGN(bytes) FFI_ALIGN (bytes, 16) +#endif + /* Perform machine dependent cif processing. */ ffi_status FFI_HIDDEN ffi_prep_cif_machdep(ffi_cif *cif) @@ -177,12 +184,7 @@ ffi_prep_cif_machdep(ffi_cif *cif) bytes = FFI_ALIGN (bytes, t->alignment); bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG); } -#if defined(_MSC_VER) && defined(_M_IX86) - // stack is not 16-bit aligned on Windows cif->bytes = bytes; -#else - cif->bytes = FFI_ALIGN (bytes, 16); -#endif return FFI_OK; } @@ -290,7 +292,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, } } - bytes = cif->bytes; + bytes = STACK_ALIGN (cif->bytes); stack = alloca(bytes + sizeof(*frame) + rsize); argp = (dir < 0 ? stack + bytes : stack); frame = (struct call_frame *)(stack + bytes); @@ -434,7 +436,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack) rvalue = frame->rettemp; pabi = &abi_params[cabi]; dir = pabi->dir; - argp = (dir < 0 ? stack + cif->bytes : stack); + argp = (dir < 0 ? stack + STACK_ALIGN (cif->bytes) : stack); switch (flags) { @@ -698,7 +700,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue) } } - bytes = cif->bytes; + bytes = STACK_ALIGN (cif->bytes); argp = stack = (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16); frame = (struct call_frame *)(stack + bytes); From 290bc3164bb0e0b3fb912c457b49e61f9a728eef Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 26 Oct 2019 10:13:20 -0400 Subject: [PATCH 008/231] Add make_sunver.pl to distribution. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 8138879b7..ea3d3832d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ generate-darwin-source-and-headers.py \ libffi.xcodeproj/project.pbxproj \ libtool-ldflags libtool-version configure.host README.md \ - libffi.map.in LICENSE-BUILDTOOLS msvc_build + libffi.map.in LICENSE-BUILDTOOLS msvc_build make_sunver.pl # local.exp is generated by configure DISTCLEANFILES = local.exp From 0348d0e4fa585d9a3d9762132a3eee94f918fe3b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 10:53:37 -0400 Subject: [PATCH 009/231] Try new cfarm build for power --- .travis.yml | 2 ++ .travis/build.sh | 9 +++++++-- .travis/install.sh | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c44f9582..e5941b0cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,8 @@ matrix: env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" + - os: linux + env: HOST=powerpc64le-unknown-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/build.sh b/.travis/build.sh index 8e0cf4211..aeab2c63a 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -1,5 +1,10 @@ #!/bin/bash +function build_cfarm() +{ + curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} +} + function build_linux() { ./autogen.sh @@ -50,8 +55,8 @@ case "$HOST" in aarch64-linux-gnu) build_foreign_linux aarch64 moxielogic/aarch64-ci-build-container:latest ;; - ppc64le-linux-gnu) - build_foreign_linux ppc64le moxielogic/ppc64le-ci-build-container:latest + powerpc64le-unknown-linux-gnu) + build_cfarm ;; s390x-linux-gnu) build_foreign_linux s390x s390x/ubuntu diff --git a/.travis/install.sh b/.travis/install.sh index b0b05bdcb..e0d64d6db 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -10,7 +10,9 @@ else sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - arm32v7-linux-gnu | aarch64-linux-gnu | ppc64le-linux-gnu | s390x-linux-gnu) + powerpc64le-unknown-linux-gnu) + ;; + arm32v7-linux-gnu | aarch64-linux-gnu | s390x-linux-gnu) sudo apt-get install qemu-user-static ;; i386-pc-linux-gnu) From 82719cbba06c2fc527df156d728341867d86f82c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 12:23:11 -0400 Subject: [PATCH 010/231] Test sparc64-linux-gnu on travis --- .travis.yml | 2 ++ .travis/build.sh | 2 +- .travis/install.sh | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5941b0cf..3b71f9c0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ matrix: env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" - os: linux env: HOST=powerpc64le-unknown-linux-gnu + - os: linux + env: HOST=sparc64-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/build.sh b/.travis/build.sh index aeab2c63a..217f4e75b 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -55,7 +55,7 @@ case "$HOST" in aarch64-linux-gnu) build_foreign_linux aarch64 moxielogic/aarch64-ci-build-container:latest ;; - powerpc64le-unknown-linux-gnu) + powerpc64le-unknown-linux-gnu | sparc64-linux-gnu) build_cfarm ;; s390x-linux-gnu) diff --git a/.travis/install.sh b/.travis/install.sh index e0d64d6db..405395cd9 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -10,7 +10,7 @@ else sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - powerpc64le-unknown-linux-gnu) + powerpc64le-unknown-linux-gnu | sparc64-linux-gnu) ;; arm32v7-linux-gnu | aarch64-linux-gnu | s390x-linux-gnu) sudo apt-get install qemu-user-static From 39bad2f396de7885c9569144b5bb6e8a639ac011 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 12:33:22 -0400 Subject: [PATCH 011/231] Don't run autogen.sh all the time. --- .travis/build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 217f4e75b..809c336bf 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -44,24 +44,28 @@ function build_ios() exit $? } -./autogen.sh case "$HOST" in arm-apple-darwin*) + ./autogen.sh build_ios ;; arm32v7-linux-gnu) + ./autogen.sh build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest ;; aarch64-linux-gnu) + ./autogen.sh build_foreign_linux aarch64 moxielogic/aarch64-ci-build-container:latest ;; powerpc64le-unknown-linux-gnu | sparc64-linux-gnu) build_cfarm ;; s390x-linux-gnu) + ./autogen.sh build_foreign_linux s390x s390x/ubuntu ;; *) + ./autogen.sh build_linux ;; esac From f325324818a6aaa9e8a75782d75c412872e6b21c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 14:35:43 -0400 Subject: [PATCH 012/231] Test mips64el-linux-gnu --- .travis.yml | 2 ++ .travis/build.sh | 2 +- .travis/install.sh | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b71f9c0d..b2f8eba99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ matrix: env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" - os: linux env: HOST=powerpc64le-unknown-linux-gnu + - os: linux + env: HOST=misp64el-linux-gnu - os: linux env: HOST=sparc64-linux-gnu - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index 809c336bf..87ff5acd6 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -57,7 +57,7 @@ case "$HOST" in ./autogen.sh build_foreign_linux aarch64 moxielogic/aarch64-ci-build-container:latest ;; - powerpc64le-unknown-linux-gnu | sparc64-linux-gnu) + powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; s390x-linux-gnu) diff --git a/.travis/install.sh b/.travis/install.sh index 405395cd9..34318a6d5 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -10,7 +10,7 @@ else sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - powerpc64le-unknown-linux-gnu | sparc64-linux-gnu) + powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; arm32v7-linux-gnu | aarch64-linux-gnu | s390x-linux-gnu) sudo apt-get install qemu-user-static From a26323b7e0824f0becaeaffc8d3b700dc09f741c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 15:32:48 -0400 Subject: [PATCH 013/231] Don't build sparc. Build mips. --- .travis.yml | 10 ++-------- .travis/build.sh | 6 +----- .travis/install.sh | 4 ++-- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2f8eba99..f804d014e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,17 +15,11 @@ matrix: - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" - os: linux - env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - - os: linux - env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - - os: linux - env: HOST=aarch64-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" + env: HOST=aarch64-linux-gnu - os: linux env: HOST=powerpc64le-unknown-linux-gnu - os: linux - env: HOST=misp64el-linux-gnu - - os: linux - env: HOST=sparc64-linux-gnu + env: HOST=mips64el-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/build.sh b/.travis/build.sh index 87ff5acd6..ac567550c 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -53,11 +53,7 @@ case "$HOST" in ./autogen.sh build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest ;; - aarch64-linux-gnu) - ./autogen.sh - build_foreign_linux aarch64 moxielogic/aarch64-ci-build-container:latest - ;; - powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; s390x-linux-gnu) diff --git a/.travis/install.sh b/.travis/install.sh index 34318a6d5..c737a5402 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -10,9 +10,9 @@ else sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; - arm32v7-linux-gnu | aarch64-linux-gnu | s390x-linux-gnu) + arm32v7-linux-gnu | s390x-linux-gnu) sudo apt-get install qemu-user-static ;; i386-pc-linux-gnu) From 45ba4aefed15be24fdbaaffec805fb02b1343e0f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 31 Oct 2019 19:07:04 -0400 Subject: [PATCH 014/231] Add sparc64-linux-gnu testing back --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f804d014e..7bfdea0d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ matrix: env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" + - os: linux + env: HOST=sparc64-linux-gnu - os: linux env: HOST=aarch64-linux-gnu - os: linux @@ -44,4 +46,4 @@ install: script: - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi - - ./.travis/build.sh + - travis_wait 45 ./.travis/build.sh From 88a76477debe83ed6a75f96394853c891fb1dac4 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 3 Nov 2019 06:28:51 -0500 Subject: [PATCH 015/231] rc2. hack as per: https://github.com/travis-ci/travis-ci/issues/6934 --- .travis.yml | 3 ++- README.md | 2 +- configure.ac | 2 +- doc/version.texi | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bfdea0d2..c3c8f163a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,4 +46,5 @@ install: script: - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi - - travis_wait 45 ./.travis/build.sh + - travis_wait 45 sleep infinity & + - ./.travis/build.sh diff --git a/README.md b/README.md index e988d80d3..b4e58f6f7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.3-rc1 was released on October 24, 2019. Check the libffi web +libffi-3.3-rc2 was released on November 2, 2019. Check the libffi web page for updates: . diff --git a/configure.ac b/configure.ac index edbfdece7..a98ec176d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.3-rc1], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.3-rc2], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index f52bc68b1..d6383370e 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 24 October 2019 +@set UPDATED 31 October 2019 @set UPDATED-MONTH October 2019 -@set EDITION 3.3-rc1 -@set VERSION 3.3-rc1 +@set EDITION 3.3-rc2 +@set VERSION 3.3-rc2 From c95cc4b354f24dbbf5776eb297fa036bcbfed252 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 06:30:20 -0500 Subject: [PATCH 016/231] Reference FFI_BUILDING_DLL --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b4e58f6f7..3d89f7beb 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ It's also possible to build libffi on Windows platforms with Microsoft's Visual C++ compiler. In this case, use the msvcc.sh wrapper script during configuration like so: - path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" + path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL" For 64-bit Windows builds, use ``CC="path/to/msvcc.sh -m64"`` and ``CXX="path/to/msvcc.sh -m64"``. You may also need to specify @@ -163,7 +163,7 @@ For 64-bit Windows builds, use ``CC="path/to/msvcc.sh -m64"`` and It is also possible to build libffi on Windows platforms with the LLVM project's clang-cl compiler, like below: - path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" + path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" When building with MSVC under a MingW environment, you may need to remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath' From 36d281ab70daf7dcf890df9c3f5bdd76f665bb68 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 06:30:52 -0500 Subject: [PATCH 017/231] Test cross-builds for hppa-linux-gnu --- .travis.yml | 3 ++- .travis/install.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c3c8f163a..2af5feb10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ matrix: include: - os: osx env: HOST=arm-apple-darwin - - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux @@ -22,6 +21,8 @@ matrix: env: HOST=powerpc64le-unknown-linux-gnu - os: linux env: HOST=mips64el-linux-gnu + - os: linux + env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-8" && CXX="hppa-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/install.sh b/.travis/install.sh index c737a5402..2fdbdc518 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -15,6 +15,9 @@ else arm32v7-linux-gnu | s390x-linux-gnu) sudo apt-get install qemu-user-static ;; + hppa-linux-gnu ) + sudo apt-get install qemu-user-static g++-8-hppa-linux-gnu + ;; i386-pc-linux-gnu) sudo apt-get install gcc-multilib g++-multilib; ;; From 0fb9ee21e68ca3e70cf236a63ba00b5ca32031ff Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 06:44:19 -0500 Subject: [PATCH 018/231] Use older test compiler. Enable s390x testing. --- .travis.yml | 6 ++++-- .travis/build.sh | 4 ---- .travis/install.sh | 7 +++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2af5feb10..9b5711fc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ matrix: include: - os: osx env: HOST=arm-apple-darwin + - os: linux + env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-7" && CXX="hppa-linux-gnu-g++-7"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu + - os: linux + env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-7" && CXX="s390x-linux-gnu-g++-7"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux @@ -21,8 +25,6 @@ matrix: env: HOST=powerpc64le-unknown-linux-gnu - os: linux env: HOST=mips64el-linux-gnu - - os: linux - env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-8" && CXX="hppa-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/build.sh b/.travis/build.sh index ac567550c..7baa81fc9 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -56,10 +56,6 @@ case "$HOST" in aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; - s390x-linux-gnu) - ./autogen.sh - build_foreign_linux s390x s390x/ubuntu - ;; *) ./autogen.sh build_linux diff --git a/.travis/install.sh b/.travis/install.sh index 2fdbdc518..4d344de81 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -12,11 +12,14 @@ else case $HOST in aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; - arm32v7-linux-gnu | s390x-linux-gnu) + arm32v7-linux-gnu ) sudo apt-get install qemu-user-static ;; hppa-linux-gnu ) - sudo apt-get install qemu-user-static g++-8-hppa-linux-gnu + sudo apt-get install -y qemu-user-static g++-7-hppa-linux-gnu + ;; + s390x-linux-gnu ) + sudo apt-get install -y qemu-user-static g++-7-s390x-linux-gnu ;; i386-pc-linux-gnu) sudo apt-get install gcc-multilib g++-multilib; From d4a28fee720c8f389b138b3f7726157fbcb7eaaf Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 06:47:05 -0500 Subject: [PATCH 019/231] Revert to older test cross compilers --- .travis.yml | 4 ++-- .travis/install.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b5711fc3..b11dbc934 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,9 @@ matrix: - os: osx env: HOST=arm-apple-darwin - os: linux - env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-7" && CXX="hppa-linux-gnu-g++-7"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu + env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-5" && CXX="hppa-linux-gnu-g++-5"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu - os: linux - env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-7" && CXX="s390x-linux-gnu-g++-7"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu + env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-5" && CXX="s390x-linux-gnu-g++-5"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux diff --git a/.travis/install.sh b/.travis/install.sh index 4d344de81..fec9dbae3 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -16,10 +16,10 @@ else sudo apt-get install qemu-user-static ;; hppa-linux-gnu ) - sudo apt-get install -y qemu-user-static g++-7-hppa-linux-gnu + sudo apt-get install -y qemu-user-static g++-5-hppa-linux-gnu ;; s390x-linux-gnu ) - sudo apt-get install -y qemu-user-static g++-7-s390x-linux-gnu + sudo apt-get install -y qemu-user-static g++-5-s390x-linux-gnu ;; i386-pc-linux-gnu) sudo apt-get install gcc-multilib g++-multilib; From 92f5309def05c66e6c5034c10d620d6fbc7a1018 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 10:49:04 -0500 Subject: [PATCH 020/231] Try s390x and sh4 cross builds/tests --- .travis.yml | 4 ++++ .travis/build-in-container.sh | 8 +++++++- .travis/build.sh | 9 +++++++++ .travis/install.sh | 5 +---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b11dbc934..ba96cf452 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ matrix: include: - os: osx env: HOST=arm-apple-darwin + - os: linux + env: HOST=sh4-linux-gnu MEVAL='export CC="sh4-linux-gnu-gcc-8" && CXX="sh4-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu + - os: linux + env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-5" && CXX="hppa-linux-gnu-g++-5"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu - os: linux diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index dc412c2b2..85624bff8 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -2,7 +2,13 @@ cd /opt -./configure +export QEMU_LD_PREFIX=/usr/${HOST} + +if ! test "x$HOST" == "x"; then + ./configure --host=${HOST} --disable-shared; +else + ./configure +fi make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" diff --git a/.travis/build.sh b/.travis/build.sh index 7baa81fc9..50cc9a4ff 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -34,6 +34,12 @@ function build_foreign_linux() exit $? } +function build_cross_linux() +{ + docker run --rm -t -i -v `pwd`:/opt --rm -ti -e HOST="${HOST}" LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + exit $? +} + function build_ios() { which python @@ -56,6 +62,9 @@ case "$HOST" in aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; + sh4-linux-gnu | s390x-linux-gnu ) + build_cross_linux + ;; *) ./autogen.sh build_linux diff --git a/.travis/install.sh b/.travis/install.sh index fec9dbae3..abe5d88f4 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -12,15 +12,12 @@ else case $HOST in aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; - arm32v7-linux-gnu ) + arm32v7-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) sudo apt-get install qemu-user-static ;; hppa-linux-gnu ) sudo apt-get install -y qemu-user-static g++-5-hppa-linux-gnu ;; - s390x-linux-gnu ) - sudo apt-get install -y qemu-user-static g++-5-s390x-linux-gnu - ;; i386-pc-linux-gnu) sudo apt-get install gcc-multilib g++-multilib; ;; From 136a235d3f36408628c0459d8740546acad0ca5a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 10:51:33 -0500 Subject: [PATCH 021/231] Use the right cross build container image --- .travis/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 50cc9a4ff..987e6e608 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -30,13 +30,13 @@ function build_linux() function build_foreign_linux() { - docker run --rm -t -i -v `pwd`:/opt --rm -ti -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh exit $? } function build_cross_linux() { - docker run --rm -t -i -v `pwd`:/opt --rm -ti -e HOST="${HOST}" LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } From a6dc8ef270c1f022720aedadb6b0d2678d1bc39e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 11:10:59 -0500 Subject: [PATCH 022/231] Fix typo. Don't double test. --- .travis.yml | 4 ---- .travis/build.sh | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba96cf452..5c0baef1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,6 @@ matrix: env: HOST=sh4-linux-gnu MEVAL='export CC="sh4-linux-gnu-gcc-8" && CXX="sh4-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - - os: linux - env: HOST=hppa-linux-gnu MEVAL='export CC="hppa-linux-gnu-gcc-5" && CXX="hppa-linux-gnu-g++-5"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/hppa-linux-gnu - - os: linux - env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-5" && CXX="s390x-linux-gnu-g++-5"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index 987e6e608..d9d3321e2 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -36,7 +36,7 @@ function build_foreign_linux() function build_cross_linux() { - docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } From d23d3959fdb764984cfb888c5d6aed910926dd5f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 11:21:46 -0500 Subject: [PATCH 023/231] autogen before cross building --- .travis/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis/build.sh b/.travis/build.sh index d9d3321e2..f8f78a244 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -63,6 +63,7 @@ case "$HOST" in build_cfarm ;; sh4-linux-gnu | s390x-linux-gnu ) + ./autogen.sh build_cross_linux ;; *) From 259c497a2f326cc89344766e106cf73e62485a2a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 11:31:17 -0500 Subject: [PATCH 024/231] Sett CC and CXX for cross builds --- .travis/build-in-container.sh | 6 +----- .travis/build.sh | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index 85624bff8..6aa302e20 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -4,11 +4,7 @@ cd /opt export QEMU_LD_PREFIX=/usr/${HOST} -if ! test "x$HOST" == "x"; then - ./configure --host=${HOST} --disable-shared; -else - ./configure -fi +./configure ${HOST+--host=$HOST --disable-shared} make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" diff --git a/.travis/build.sh b/.travis/build.sh index f8f78a244..61d92d076 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -36,7 +36,7 @@ function build_foreign_linux() function build_cross_linux() { - docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } From 75464caf658f176848db6f48325c5067cdf94a9b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 6 Nov 2019 22:02:11 -0500 Subject: [PATCH 025/231] Add alpha and m68k testing --- .travis.yml | 4 ++++ .travis/build.sh | 2 +- .travis/install.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c0baef1f..3ca9e0640 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ matrix: env: HOST=arm-apple-darwin - os: linux env: HOST=sh4-linux-gnu MEVAL='export CC="sh4-linux-gnu-gcc-8" && CXX="sh4-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu + - os: linux + env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu + - os: linux + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index 61d92d076..df29156ed 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -62,7 +62,7 @@ case "$HOST" in aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; - sh4-linux-gnu | s390x-linux-gnu ) + alpha-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) ./autogen.sh build_cross_linux ;; diff --git a/.travis/install.sh b/.travis/install.sh index abe5d88f4..751d1523a 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -12,7 +12,7 @@ else case $HOST in aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; - arm32v7-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) + alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) sudo apt-get install qemu-user-static ;; hppa-linux-gnu ) From 28d9c019dbbf6dea1ed127e1a7de829cece86639 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 07:36:11 -0500 Subject: [PATCH 026/231] Set QEMU_CPU for m68k --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3ca9e0640..906e96016 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: - os: linux env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=m68020 - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux From 04d14a66ff807a0ac2578ce886ef338aa2066b4d Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 09:23:10 -0500 Subject: [PATCH 027/231] Set QEMU_CPU within the build containers --- .travis/build.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index df29156ed..ed0e4955c 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -1,5 +1,11 @@ #!/bin/bash +if [ -z ${QEMU_CPU+x} ]; then + export SET_QEMU_CPU= +else + export SET_QEMU_CPU=-e QEMU_CPU=${QEMU_CPU} +fi + function build_cfarm() { curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} @@ -30,13 +36,13 @@ function build_linux() function build_foreign_linux() { - docker run --rm -t -i -v `pwd`:/opt -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh exit $? } function build_cross_linux() { - docker run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + docker run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } From 588e87461fe48441806be4bb5654f058e1c37649 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 10:56:40 -0500 Subject: [PATCH 028/231] Print debug output. Use podman when available. --- .travis/build.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index ed0e4955c..4d1659300 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -1,11 +1,24 @@ #!/bin/bash +set -x + if [ -z ${QEMU_CPU+x} ]; then export SET_QEMU_CPU= else export SET_QEMU_CPU=-e QEMU_CPU=${QEMU_CPU} fi +# Default to podman where available, docker otherwise. +# Override by setting the DOCKER environment variable. +if test -z "$DOCKER"; then + which podman > /dev/null 2>&1 + if [ $? != 0 ]; then + export DOCKER=docker + else + export DOCKER=podman + fi +fi + function build_cfarm() { curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} @@ -36,13 +49,13 @@ function build_linux() function build_foreign_linux() { - docker run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh exit $? } function build_cross_linux() { - docker run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } From 16c935000d459b1aba9e1f7b48e2c1d7dadc8cf1 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 11:00:09 -0500 Subject: [PATCH 029/231] Fix shell script --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 4d1659300..46fcdc6a1 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -5,7 +5,7 @@ set -x if [ -z ${QEMU_CPU+x} ]; then export SET_QEMU_CPU= else - export SET_QEMU_CPU=-e QEMU_CPU=${QEMU_CPU} + export SET_QEMU_CPU="-e QEMU_CPU=${QEMU_CPU}" fi # Default to podman where available, docker otherwise. From 08cb33ff5824b2ea24b2b62841cca1934a27f36f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 11:15:13 -0500 Subject: [PATCH 030/231] Dump supported CPUs --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 906e96016..38898005a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: - os: linux env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=m68020 + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=help - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux From eebcbb1113742df7d41fc3d39eca970a026ad1d1 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 11:26:53 -0500 Subject: [PATCH 031/231] Compile m68k target for m5208 --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38898005a..c44b3b088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,10 @@ sudo: required language: cpp +# For qemu-powered targets, get the list of supported processors from +# travis by setting QEMU_CPU=help, then set -mcpu= for the compilers +# accordingly. + matrix: include: - os: osx @@ -12,7 +16,7 @@ matrix: - os: linux env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8" && CXX="m68k-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=help + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=5208" && CXX="m68k-linux-gnu-g++-8 -mcpu=5208"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=m5208 - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux From 6a9fa770a436bbb71dbe8311e75123353e6836cc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 11:37:25 -0500 Subject: [PATCH 032/231] Add GCC_OPTIONS flag --- .travis/build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 46fcdc6a1..9f0946fff 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -55,7 +55,7 @@ function build_foreign_linux() function build_cross_linux() { - ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8" -e CXX="${HOST}-g++-8" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh exit $? } @@ -81,7 +81,11 @@ case "$HOST" in aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; - alpha-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) + m68k-linux-gnu ) + ./autogen.sh + GCC_OPTIONS=-mcpu=5208 build_cross_linux + ;; + alpha-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) ./autogen.sh build_cross_linux ;; From 7e0fbf41934020c9ff76816fde5000482c7e6a6c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 11:50:08 -0500 Subject: [PATCH 033/231] Try coldfire for m68k builds --- .travis.yml | 2 +- .travis/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c44b3b088..d923fae29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: - os: linux env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=5208" && CXX="m68k-linux-gnu-g++-8 -mcpu=5208"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=m5208 + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=5208" && CXX="m68k-linux-gnu-g++-8 -mcpu=5208"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index 9f0946fff..ab773fb3b 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -83,7 +83,7 @@ case "$HOST" in ;; m68k-linux-gnu ) ./autogen.sh - GCC_OPTIONS=-mcpu=5208 build_cross_linux + GCC_OPTIONS=-mcpu=547x build_cross_linux ;; alpha-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) ./autogen.sh From 0da221f8094ec504d91b5f88c74e98b8b9aa9eda Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 12:03:01 -0500 Subject: [PATCH 034/231] Clean up. Debug s390x cpu support. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d923fae29..d0cde4bf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,13 @@ matrix: - os: osx env: HOST=arm-apple-darwin - os: linux - env: HOST=sh4-linux-gnu MEVAL='export CC="sh4-linux-gnu-gcc-8" && CXX="sh4-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu + env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux - env: HOST=alpha-linux-gnu MEVAL='export CC="alpha-linux-gnu-gcc-8" && CXX="alpha-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu + env: HOST=alpha-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=5208" && CXX="m68k-linux-gnu-g++-8 -mcpu=5208"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e + env: HOST=m68k-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux - env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu + env: HOST=s390x-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=help - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux From 188de63c597f23b0ccdb953b076c8cb0711fbcf0 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 12:03:19 -0500 Subject: [PATCH 035/231] Mark xfail for m68k and alpha. --- testsuite/libffi.call/va_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/va_1.c b/testsuite/libffi.call/va_1.c index 7f96809ea..59d085c83 100644 --- a/testsuite/libffi.call/va_1.c +++ b/testsuite/libffi.call/va_1.c @@ -5,7 +5,7 @@ Originator: ARM Ltd. */ /* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* } } */ +/* { dg-output "" { xfail avr32*-*-* m68k-*-* alpha-*-* } } */ #include "ffitest.h" #include From f764f278160831f7e4d8ee8a48d18f5a7937f742 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 12:17:29 -0500 Subject: [PATCH 036/231] Change s390x options --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0cde4bf4..2094d92dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ matrix: - os: linux env: HOST=alpha-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux - env: HOST=m68k-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e + env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux - env: HOST=s390x-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=help + env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=max - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux From 4e3e0586efbbc7828c15fb48e49401840beefcdd Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 7 Nov 2019 12:35:27 -0500 Subject: [PATCH 037/231] Fix tpyo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2094d92dc..f744bce05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: - os: linux env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux - env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=max + env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=max - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux From 0de0c6a28006902c203e8dc6629cd9ef35d61e09 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 10 Nov 2019 08:20:46 -0500 Subject: [PATCH 038/231] Build both iOS and Macosx --- .travis.yml | 4 +++- .travis/build.sh | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f744bce05..6c0ca8f52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,9 @@ language: cpp matrix: include: - os: osx - env: HOST=arm-apple-darwin + env: HOST=aarch64-apple-darwin13 + - os: osx + env: HOST=x86_64-apple-darwin10 - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index ab773fb3b..92e808c2f 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -63,17 +63,31 @@ function build_ios() { which python # export PYTHON_BIN=/usr/local/bin/python - ./generate-darwin-source-and-headers.py + ./generate-darwin-source-and-headers.py --only-ios xcodebuild -showsdks xcodebuild -project libffi.xcodeproj -target "libffi-iOS" -configuration Release -sdk iphoneos11.4 exit $? } +function build_macosx() +{ + which python +# export PYTHON_BIN=/usr/local/bin/python + ./generate-darwin-source-and-headers.py --only-osx + xcodebuild -showsdks + xcodebuild -project libffi.xcodeproj -target "libffi-Mac" -configuration Release -sdk macosx10.13 + exit $? +} + case "$HOST" in arm-apple-darwin*) ./autogen.sh build_ios ;; + x86_64-apple-darwin*) + ./autogen.sh + build_macosx + ;; arm32v7-linux-gnu) ./autogen.sh build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest From 2cc11720be0c4d3bbe906be5a4aad3b2dc167072 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 11 Nov 2019 16:19:45 -0500 Subject: [PATCH 039/231] Debug in-container builds --- .travis.yml | 2 ++ .travis/build-in-container.sh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6c0ca8f52..c573ffebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ matrix: env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 + - os: linux + env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index 6aa302e20..bc027648e 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -1,5 +1,11 @@ #!/bin/bash +set -x + +echo =============================================================== +env +echo =============================================================== + cd /opt export QEMU_LD_PREFIX=/usr/${HOST} From 3c2b810e99a10f97d1eb6ba485eb09bfdb158084 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 11 Nov 2019 21:11:59 -0500 Subject: [PATCH 040/231] Test rlgl --- .travis/build-in-container.sh | 7 ++- .travis/build.sh | 5 ++- .travis/install.sh | 85 ++++++++++++++++++++--------------- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index bc027648e..02b1e56d4 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -14,7 +14,7 @@ export QEMU_LD_PREFIX=/usr/${HOST} make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" -EXITCODE=$? + gzip -c -9 */testsuite/libffi.log > libffi.log.gz echo ================================================================ echo The logs are too long for travis to handle, so we compress and @@ -24,5 +24,8 @@ echo ================================================================ uuencode libffi.log.gz - echo ================================================================ echo ================================================================ -exit $EXITCODE + +ID=$(./rlgl start) +./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log +exit $? diff --git a/.travis/build.sh b/.travis/build.sh index 92e808c2f..0ff1bc231 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -31,7 +31,6 @@ function build_linux() make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" - EXITCODE=$? gzip -c -9 */testsuite/libffi.log > libffi.log.gz echo ================================================================ @@ -44,7 +43,9 @@ function build_linux() echo ================================================================ echo ================================================================ - exit $EXITCODE + ID=$(./rlgl start) + ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log + exit $? } function build_foreign_linux() diff --git a/.travis/install.sh b/.travis/install.sh index 751d1523a..e6a186517 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -2,42 +2,53 @@ set -x if [[ $TRAVIS_OS_NAME != 'linux' ]]; then - brew update > brew-update.log 2>&1 - # fix an issue with libtool on travis by reinstalling it - brew uninstall libtool; - brew install libtool dejagnu; + brew update > brew-update.log 2>&1 + # fix an issue with libtool on travis by reinstalling it + brew uninstall libtool; + brew install libtool dejagnu; else - sudo apt-get clean # clear the cache - sudo apt-get update - case $HOST in - aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) - ;; - alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) - sudo apt-get install qemu-user-static - ;; - hppa-linux-gnu ) - sudo apt-get install -y qemu-user-static g++-5-hppa-linux-gnu - ;; - i386-pc-linux-gnu) - sudo apt-get install gcc-multilib g++-multilib; - ;; - moxie-elf) - echo 'deb https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list - sudo apt-get clean # clear the cache - sudo apt-get update ## -qq - sudo apt-get update - sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim - ;; - i686-w64-mingw32) - sudo apt-get install gcc-mingw-w64-i686 binutils-mingw-w64-i686 wine; - ;; - esac - case $HOST in - arm32v7-linux-gnu | aarch64-linux-gnu | ppc64le-linux-gnu | s390x-linux-gnu) - # don't install host tools - ;; - *) - sudo apt-get install dejagnu texinfo sharutils - ;; - esac + + # Configure the rlgl cli. + # Download and extract the client + wget -qO - http://rl.gl/cli/rlgl-linux-amd64.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl + # Log into the server + ./rlgl login https://rl.gl + + sudo apt-get clean # clear the cache + sudo apt-get update + case $HOST in + aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + ;; + alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) + sudo apt-get install qemu-user-static + ;; + hppa-linux-gnu ) + sudo apt-get install -y qemu-user-static g++-5-hppa-linux-gnu + ;; + i386-pc-linux-gnu) + sudo apt-get install gcc-multilib g++-multilib; + ;; + moxie-elf) + echo 'deb https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list + sudo apt-get clean # clear the cache + sudo apt-get update ## -qq + sudo apt-get update + sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim + ;; + x86_64-w64-mingw32) + sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 wine; + ;; + i686-w32-mingw32) + sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 wine; + ;; + esac + case $HOST in + arm32v7-linux-gnu | aarch64-linux-gnu | ppc64le-linux-gnu | s390x-linux-gnu) + # don't install host tools + ;; + *) + sudo apt-get install dejagnu texinfo sharutils + ;; + esac fi From 2a8d88d92d56747101078c5592ab2473e6c5cb29 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 11 Nov 2019 21:24:58 -0500 Subject: [PATCH 041/231] Fix rlgl usage --- .travis/build-in-container.sh | 1 + .travis/build.sh | 1 + .travis/install.sh | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index 02b1e56d4..4baf479fe 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -25,6 +25,7 @@ uuencode libffi.log.gz - echo ================================================================ echo ================================================================ +./rlgl l https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? diff --git a/.travis/build.sh b/.travis/build.sh index 0ff1bc231..65449cc4b 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -43,6 +43,7 @@ function build_linux() echo ================================================================ echo ================================================================ + ./rlgl l https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? diff --git a/.travis/install.sh b/.travis/install.sh index e6a186517..87467539f 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -12,8 +12,6 @@ else # Download and extract the client wget -qO - http://rl.gl/cli/rlgl-linux-amd64.tgz | \ tar --strip-components=2 -xvzf - ./rlgl/rlgl - # Log into the server - ./rlgl login https://rl.gl sudo apt-get clean # clear the cache sudo apt-get update From 5b297e036e61ad1ecac9c8a3e57895737c55feb7 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 05:51:09 -0500 Subject: [PATCH 042/231] Don't bother dumping logs. Use rlgl instead. --- .travis/build-in-container.sh | 16 ---------------- .travis/build.sh | 11 ----------- 2 files changed, 27 deletions(-) diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index 4baf479fe..af8e2b67d 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -1,11 +1,5 @@ #!/bin/bash -set -x - -echo =============================================================== -env -echo =============================================================== - cd /opt export QEMU_LD_PREFIX=/usr/${HOST} @@ -15,16 +9,6 @@ make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" -gzip -c -9 */testsuite/libffi.log > libffi.log.gz -echo ================================================================ -echo The logs are too long for travis to handle, so we compress and -echo uuencode them. Download, decode and uncompress if you need to -echo read them. -echo ================================================================ -uuencode libffi.log.gz - -echo ================================================================ -echo ================================================================ - ./rlgl l https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log diff --git a/.travis/build.sh b/.travis/build.sh index 65449cc4b..502dce71c 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -32,17 +32,6 @@ function build_linux() make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" - gzip -c -9 */testsuite/libffi.log > libffi.log.gz - echo ================================================================ - echo The logs are too long for travis to handle, so we compress and - echo uuencode them. Download, decode and uncompress if you need to - echo read them. For example, if you select and save this text - echo as libffi.uu, run: 'cat libffi.uu | uudecode | gzip -d | less'. - echo ================================================================ - uuencode libffi.log.gz - - echo ================================================================ - echo ================================================================ - ./rlgl l https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log From 82f7f80aa9ac3cd753bcb6d2b88cc930aee72bcc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 08:58:52 -0500 Subject: [PATCH 043/231] Run rlgl outside of the build container. --- .travis/build-in-container.sh | 4 ---- .travis/build.sh | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index af8e2b67d..3f7bd42b9 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -9,8 +9,4 @@ make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" -./rlgl l https://rl.gl -ID=$(./rlgl start) -./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log -exit $? diff --git a/.travis/build.sh b/.travis/build.sh index 502dce71c..3d500529d 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -41,6 +41,10 @@ function build_linux() function build_foreign_linux() { ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + + ./rlgl l https://rl.gl + ID=$(./rlgl start) + ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? } From 042c6671b0456d17af24d61b79cbd3f9261c3f2b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 09:14:20 -0500 Subject: [PATCH 044/231] Always exit build container successfully. Don't test mingw. --- .travis.yml | 4 ++-- .travis/build-in-container.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c573ffebf..86b16b9d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,8 @@ matrix: env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 - - os: linux - env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" +# - os: linux +# env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux diff --git a/.travis/build-in-container.sh b/.travis/build-in-container.sh index 3f7bd42b9..1a7fa76b8 100755 --- a/.travis/build-in-container.sh +++ b/.travis/build-in-container.sh @@ -7,6 +7,6 @@ export QEMU_LD_PREFIX=/usr/${HOST} ./configure ${HOST+--host=$HOST --disable-shared} make make dist -make check RUNTESTFLAGS="-a $RUNTESTFLAGS" +make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true From 486f88f985affa215a9daaadcdc703c8baea9020 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 09:20:21 -0500 Subject: [PATCH 045/231] Use rlgl for cross builds. --- .travis/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index 3d500529d..6a388dcee 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -51,6 +51,10 @@ function build_foreign_linux() function build_cross_linux() { ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + + ./rlgl l https://rl.gl + ID=$(./rlgl start) + ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? } From 5123e9cf0193031bdc580cb221427cbd29ba3677 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 09:21:57 -0500 Subject: [PATCH 046/231] Use rlgl for cfarm test results --- .travis/build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 6a388dcee..3d6272824 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -21,7 +21,12 @@ fi function build_cfarm() { - curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} + curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee libffi.log + + ./rlgl l https://rl.gl + ID=$(./rlgl start) + ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git libffi.log + exit $? } function build_linux() From 7e318cf50d8c481957b3be76e508054c70cbdf9b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 17:55:35 -0500 Subject: [PATCH 047/231] Pull test logs from cfarm --- .travis/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 3d6272824..59fd536fc 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -21,7 +21,8 @@ fi function build_cfarm() { - curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee libffi.log + curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log + curl -u ${CFARM_AUTH} "$(grep '== LOGFILE ==' build.log | cut -b15-)" > libffi.log ./rlgl l https://rl.gl ID=$(./rlgl start) From 6dd88bc5b3f3d3d975409b7336f4127ae18da4b3 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 18:44:27 -0500 Subject: [PATCH 048/231] Debug --- .travis/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index 59fd536fc..73c66f72f 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -22,6 +22,10 @@ fi function build_cfarm() { curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log + echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + echo $(grep '== LOGFILE ==' build.log) + echo $(grep '== LOGFILE ==' build.log | cut -b15-) + echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: curl -u ${CFARM_AUTH} "$(grep '== LOGFILE ==' build.log | cut -b15-)" > libffi.log ./rlgl l https://rl.gl From aa975ec3e4ac07bd7dacec18f1c8282baeb7c398 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 22:35:47 -0500 Subject: [PATCH 049/231] Fix grep matcher --- .travis/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 73c66f72f..e92cf11c3 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -23,8 +23,8 @@ function build_cfarm() { curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - echo $(grep '== LOGFILE ==' build.log) - echo $(grep '== LOGFILE ==' build.log | cut -b15-) + echo $(grep '==LOGFILE==' build.log) + echo $(grep '==LOGFILE==' build.log | cut -b15-) echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: curl -u ${CFARM_AUTH} "$(grep '== LOGFILE ==' build.log | cut -b15-)" > libffi.log From 6630764d244aeb3bc0797d0c3c7ccc79084061a8 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 12 Nov 2019 22:56:37 -0500 Subject: [PATCH 050/231] Account for shorter ==LOGFILE== string --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index e92cf11c3..ba0412c1e 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -24,7 +24,7 @@ function build_cfarm() curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: echo $(grep '==LOGFILE==' build.log) - echo $(grep '==LOGFILE==' build.log | cut -b15-) + echo $(grep '==LOGFILE==' build.log | cut -b13-) echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: curl -u ${CFARM_AUTH} "$(grep '== LOGFILE ==' build.log | cut -b15-)" > libffi.log From c8986e871f82b497493d28c36be1a755c2ea6b8d Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 06:01:43 -0500 Subject: [PATCH 051/231] Fix log name extraction --- .travis/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index ba0412c1e..ad8163e0c 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -23,10 +23,10 @@ function build_cfarm() { curl -u ${CFARM_AUTH} https://cfarm-test-libffi-libffi.apps.home.labdroid.net/test?host=${HOST}\&commit=${TRAVIS_COMMIT} | tee build.log echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - echo $(grep '==LOGFILE==' build.log) - echo $(grep '==LOGFILE==' build.log | cut -b13-) + echo $(tail build.log | grep '^==LOGFILE==') + echo $(tail build.log | grep '^==LOGFILE==' | cut -b13-) echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - curl -u ${CFARM_AUTH} "$(grep '== LOGFILE ==' build.log | cut -b15-)" > libffi.log + curl -u ${CFARM_AUTH} "$(tail build.log | grep '^== LOGFILE ==' | cut -b15-)" > libffi.log ./rlgl l https://rl.gl ID=$(./rlgl start) From de6df6dce6420d4643598c228b72da4e455a0da7 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 06:32:46 -0500 Subject: [PATCH 052/231] Fix log file URL extraction. Grab rlgl cli for OSX --- .travis.yml | 6 ++++-- .travis/build.sh | 2 +- .travis/install.sh | 8 ++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86b16b9d8..0410688a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ matrix: env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 +# Wine emulation is still a little too slow # - os: linux # env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - os: linux @@ -29,8 +30,9 @@ matrix: env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" - - os: linux - env: HOST=sparc64-linux-gnu +# The sparc64 linux system in the GCC compile farm is non-responsive. +# - os: linux +# env: HOST=sparc64-linux-gnu - os: linux env: HOST=aarch64-linux-gnu - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index ad8163e0c..bfd8b7493 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -26,7 +26,7 @@ function build_cfarm() echo $(tail build.log | grep '^==LOGFILE==') echo $(tail build.log | grep '^==LOGFILE==' | cut -b13-) echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - curl -u ${CFARM_AUTH} "$(tail build.log | grep '^== LOGFILE ==' | cut -b15-)" > libffi.log + curl -u ${CFARM_AUTH} "$(tail build.log | grep '^== LOGFILE ==' | cut -b13-)" > libffi.log ./rlgl l https://rl.gl ID=$(./rlgl start) diff --git a/.travis/install.sh b/.travis/install.sh index 87467539f..eb7f80f32 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -6,10 +6,14 @@ if [[ $TRAVIS_OS_NAME != 'linux' ]]; then # fix an issue with libtool on travis by reinstalling it brew uninstall libtool; brew install libtool dejagnu; + + # Download and extract the rlgl client + wget -qO - https://rl.gl/cli/rlgl-darwin-amd64.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl + else - # Configure the rlgl cli. - # Download and extract the client + # Download and extract the rlgl client wget -qO - http://rl.gl/cli/rlgl-linux-amd64.tgz | \ tar --strip-components=2 -xvzf - ./rlgl/rlgl From 9bd3a9742c04d2fac489f236163d7e7fbb1b7568 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 06:35:40 -0500 Subject: [PATCH 053/231] Add wine-sim.exp for wine-based testing --- .travis/wine-sim.exp | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .travis/wine-sim.exp diff --git a/.travis/wine-sim.exp b/.travis/wine-sim.exp new file mode 100644 index 000000000..8bdab6719 --- /dev/null +++ b/.travis/wine-sim.exp @@ -0,0 +1,55 @@ +# Copyright (C) 2010, 2019 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This is a list of toolchains that are supported on this board. +set_board_info target_install {i686-w64-mingw32} + +# Load the generic configuration for this board. This will define a basic set +# of routines needed by the tool to communicate with the board. +load_generic_config "sim" + +set_board_info sim "wineconsole --backend=curses" +set_board_info is_simulator 1 + +# No multilib options needed by default. +process_multilib_options "" + +# We only support newlib on this target. We assume that all multilib +# options have been specified before we get here. + +set_board_info compiler "[find_gcc]" +set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]" +set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]" + +# Configuration settings for testsuites +set_board_info noargs 1 +set_board_info gdb,nosignals 1 +set_board_info gdb,noresults 1 +set_board_info gdb,cannot_call_functions 1 +set_board_info gdb,skip_float_tests 1 +set_board_info gdb,can_reverse 1 +set_board_info gdb,use_precord 1 + +# More time is needed +set_board_info gcc,timeout 800 +set_board_info gdb,timeout 60 + +# Used by a few gcc.c-torture testcases to delimit how large the stack can +# be. +set_board_info gcc,stack_size 5000 + From a34254bdc1dee2857b759a22e657f92aadfa85dc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 06:37:26 -0500 Subject: [PATCH 054/231] Re-add wine based testing --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0410688a4..7bfddce35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,8 @@ matrix: env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 -# Wine emulation is still a little too slow -# - os: linux -# env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" + - os: linux + env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux From cda60c1a8aec070a7a822c047d89d0f18cf7c5fc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 06:51:44 -0500 Subject: [PATCH 055/231] Disable mips64 tests. Fix log grabbing. --- .travis.yml | 5 +++-- .travis/build.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bfddce35..4bac20ab6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,9 @@ matrix: env: HOST=aarch64-linux-gnu - os: linux env: HOST=powerpc64le-unknown-linux-gnu - - os: linux - env: HOST=mips64el-linux-gnu +# The mips64 linux system in the GCC compile farm is not allowing logins +# - os: linux +# env: HOST=mips64el-linux-gnu - os: linux compiler: gcc env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' diff --git a/.travis/build.sh b/.travis/build.sh index bfd8b7493..ab334e5ea 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -26,7 +26,7 @@ function build_cfarm() echo $(tail build.log | grep '^==LOGFILE==') echo $(tail build.log | grep '^==LOGFILE==' | cut -b13-) echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - curl -u ${CFARM_AUTH} "$(tail build.log | grep '^== LOGFILE ==' | cut -b13-)" > libffi.log + curl -u ${CFARM_AUTH} "$(tail build.log | grep '^==LOGFILE==' | cut -b13-)" > libffi.log ./rlgl l https://rl.gl ID=$(./rlgl start) From 3a7580da73b7f16f275277316d00e3497cbb5a8c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 07:59:18 -0500 Subject: [PATCH 056/231] Mark java raw APIs as deprecated. --- include/ffi.h.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/ffi.h.in b/include/ffi.h.in index f6b402483..71cc05c9d 100644 --- a/include/ffi.h.in +++ b/include/ffi.h.in @@ -1,5 +1,5 @@ /* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 2011, 2014 Anthony Green + libffi @VERSION@ - Copyright (c) 2011, 2014, 2019 Anthony Green - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. Permission is hereby granted, free of charge, to any person @@ -288,15 +288,15 @@ FFI_API void ffi_java_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, - ffi_java_raw *avalue); + ffi_java_raw *avalue) __attribute__((deprecated)); #endif FFI_API -void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); +void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated)); FFI_API -void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); +void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __attribute__((deprecated)); FFI_API -size_t ffi_java_raw_size (ffi_cif *cif); +size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated)); /* ---- Definitions for closures ----------------------------------------- */ @@ -421,14 +421,14 @@ FFI_API ffi_status ffi_prep_java_raw_closure (ffi_java_raw_closure*, ffi_cif *cif, void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); + void *user_data) __attribute__((deprecated)); FFI_API ffi_status ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, ffi_cif *cif, void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), void *user_data, - void *codeloc); + void *codeloc) __attribute__((deprecated)); #endif #endif /* FFI_CLOSURES */ From 54af0256a00a40b2218950f93e5415c60f675714 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 09:15:05 -0500 Subject: [PATCH 057/231] Platform test tweaks --- .travis.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bac20ab6..74ee71f02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,9 @@ language: cpp matrix: include: - - os: osx - env: HOST=aarch64-apple-darwin13 +# This configuration is still using the native x86 toolchain? +# - os: osx +# env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 - os: linux @@ -29,13 +30,14 @@ matrix: env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" + - os: linux + env: HOST=aarch64-linux-gnu # The sparc64 linux system in the GCC compile farm is non-responsive. # - os: linux # env: HOST=sparc64-linux-gnu - - os: linux - env: HOST=aarch64-linux-gnu - - os: linux - env: HOST=powerpc64le-unknown-linux-gnu +# Having problems getting logs for this one... +# - os: linux +# env: HOST=powerpc64le-unknown-linux-gnu # The mips64 linux system in the GCC compile farm is not allowing logins # - os: linux # env: HOST=mips64el-linux-gnu From db198a19375858879dbcc51a443c193efa0b6c0a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 10:05:36 -0500 Subject: [PATCH 058/231] Extend timeout for builds. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 74ee71f02..36e3ad570 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,5 +65,5 @@ install: script: - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi - - travis_wait 45 sleep infinity & + - travis_wait 59 sleep infinity & - ./.travis/build.sh From 86d3d3767a40fe1cae10c419a913dd97e7e6cd23 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 13 Nov 2019 10:07:00 -0500 Subject: [PATCH 059/231] Don't build aarch64-linux-gnu --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e3ad570..a70a17e1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,14 +30,14 @@ matrix: env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" - - os: linux - env: HOST=aarch64-linux-gnu # The sparc64 linux system in the GCC compile farm is non-responsive. # - os: linux # env: HOST=sparc64-linux-gnu # Having problems getting logs for this one... # - os: linux # env: HOST=powerpc64le-unknown-linux-gnu +# - os: linux +# env: HOST=aarch64-linux-gnu # The mips64 linux system in the GCC compile farm is not allowing logins # - os: linux # env: HOST=mips64el-linux-gnu From 28a7cc464c21b4955fba28cc55a6f095ddf5838b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 15 Nov 2019 06:07:51 -0500 Subject: [PATCH 060/231] Consolidate all of the old ChangeLog files into ChangeLog.old. --- ChangeLog.libffi | 584 ---------- ChangeLog.libgcj | 40 - ChangeLog.libffi-3.1 => ChangeLog.old | 1407 +++++++++++++++++++++++++ ChangeLog.v1 | 764 -------------- 4 files changed, 1407 insertions(+), 1388 deletions(-) delete mode 100644 ChangeLog.libffi delete mode 100644 ChangeLog.libgcj rename ChangeLog.libffi-3.1 => ChangeLog.old (82%) delete mode 100644 ChangeLog.v1 diff --git a/ChangeLog.libffi b/ChangeLog.libffi deleted file mode 100644 index 49ba8dad3..000000000 --- a/ChangeLog.libffi +++ /dev/null @@ -1,584 +0,0 @@ -2011-02-08 Andreas Tobler - - * testsuite/lib/libffi.exp: Tweak for stand-alone mode. - -2009-12-25 Samuli Suominen - - * configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64. - * configure: Rebuilt. - * fficonfig.h.in: Rebuilt. - -2009-06-16 Andrew Haley - - * testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs. - * testsuite/libffi.call/float2.c: Fix dg-excess-errors. - * testsuite/libffi.call/ffitest.h, - testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. - -2009-06-12 Andrew Haley - - * testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_medium2.c: Fix printf format - specifiers. - testsuite/libffi.special/unwindtest.cc: include stdint.h. - -2009-06-11 Timothy Wall - - * Makefile.am, - configure.ac, - include/ffi.h.in, - include/ffi_common.h, - src/closures.c, - src/dlmalloc.c, - src/x86/ffi.c, - src/x86/ffitarget.h, - src/x86/win64.S (new), - README: Added win64 support (mingw or MSVC) - * Makefile.in, - include/Makefile.in, - man/Makefile.in, - testsuite/Makefile.in, - configure, - aclocal.m4: Regenerated - * ltcf-c.sh: properly escape cygwin/w32 path - * man/ffi_call.3: Clarify size requirements for return value. - * src/x86/ffi64.c: Fix filename in comment. - * src/x86/win32.S: Remove unused extern. - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_12byte.c, - testsuite/libffi.call/cls_16byte.c, - testsuite/libffi.call/cls_18byte.c, - testsuite/libffi.call/cls_19byte.c, - testsuite/libffi.call/cls_1_1byte.c, - testsuite/libffi.call/cls_20byte.c, - testsuite/libffi.call/cls_20byte1.c, - testsuite/libffi.call/cls_24byte.c, - testsuite/libffi.call/cls_2byte.c, - testsuite/libffi.call/cls_3_1byte.c, - testsuite/libffi.call/cls_3byte1.c, - testsuite/libffi.call/cls_3byte2.c, - testsuite/libffi.call/cls_4_1byte.c, - testsuite/libffi.call/cls_4byte.c, - testsuite/libffi.call/cls_5_1_byte.c, - testsuite/libffi.call/cls_5byte.c, - testsuite/libffi.call/cls_64byte.c, - testsuite/libffi.call/cls_6_1_byte.c, - testsuite/libffi.call/cls_6byte.c, - testsuite/libffi.call/cls_7_1_byte.c, - testsuite/libffi.call/cls_7byte.c, - testsuite/libffi.call/cls_8byte.c, - testsuite/libffi.call/cls_9byte1.c, - testsuite/libffi.call/cls_9byte2.c, - testsuite/libffi.call/cls_align_double.c, - testsuite/libffi.call/cls_align_float.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_align_sint16.c, - testsuite/libffi.call/cls_align_sint32.c, - testsuite/libffi.call/cls_align_sint64.c, - testsuite/libffi.call/cls_align_uint16.c, - testsuite/libffi.call/cls_align_uint32.c, - testsuite/libffi.call/cls_align_uint64.c, - testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_float.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_multi_schar.c, - testsuite/libffi.call/cls_multi_sshort.c, - testsuite/libffi.call/cls_multi_sshortchar.c, - testsuite/libffi.call/cls_multi_uchar.c, - testsuite/libffi.call/cls_multi_ushort.c, - testsuite/libffi.call/cls_multi_ushortchar.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/cls_schar.c, - testsuite/libffi.call/cls_sint.c, - testsuite/libffi.call/cls_sshort.c, - testsuite/libffi.call/cls_uchar.c, - testsuite/libffi.call/cls_uint.c, - testsuite/libffi.call/cls_ulonglong.c, - testsuite/libffi.call/cls_ushort.c, - testsuite/libffi.call/err_bad_abi.c, - testsuite/libffi.call/err_bad_typedef.c, - testsuite/libffi.call/float2.c, - testsuite/libffi.call/huge_struct.c, - testsuite/libffi.call/nested_struct.c, - testsuite/libffi.call/nested_struct1.c, - testsuite/libffi.call/nested_struct10.c, - testsuite/libffi.call/nested_struct2.c, - testsuite/libffi.call/nested_struct3.c, - testsuite/libffi.call/nested_struct4.c, - testsuite/libffi.call/nested_struct5.c, - testsuite/libffi.call/nested_struct6.c, - testsuite/libffi.call/nested_struct7.c, - testsuite/libffi.call/nested_struct8.c, - testsuite/libffi.call/nested_struct9.c, - testsuite/libffi.call/problem1.c, - testsuite/libffi.call/return_ldl.c, - testsuite/libffi.call/return_ll1.c, - testsuite/libffi.call/stret_large.c, - testsuite/libffi.call/stret_large2.c, - testsuite/libffi.call/stret_medium.c, - testsuite/libffi.call/stret_medium2.c, - testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead - of checking for MMAP. Use intptr_t instead of long casts. - -2009-06-04 Andrew Haley - - * src/powerpc/ffitarget.h: Fix misapplied merge from gcc. - -2009-06-04 Andrew Haley - - * src/mips/o32.S, - src/mips/n32.S: Fix licence formatting. - -2009-06-04 Andrew Haley - - * src/x86/darwin.S: Fix licence formatting. - src/x86/win32.S: Likewise. - src/sh64/sysv.S: Likewise. - src/sh/sysv.S: Likewise. - -2009-06-04 Andrew Haley - - * src/sh64/ffi.c: Remove lint directives. Was missing from merge - of Andreas Tobler's patch from 2006-04-22. - -2009-06-04 Andrew Haley - - * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of - 2007-03-07. - -2008-12-26 Timothy Wall - - * testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_align_longdouble.c, - testsuite/libffi.call/cls_align_longdouble_split.c, - testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected - failures on x86_64 cygwin/mingw. - -2008-12-22 Timothy Wall - - * testsuite/libffi.call/closure_fn0.c, - testsuite/libffi.call/closure_fn1.c, - testsuite/libffi.call/closure_fn2.c, - testsuite/libffi.call/closure_fn3.c, - testsuite/libffi.call/closure_fn4.c, - testsuite/libffi.call/closure_fn5.c, - testsuite/libffi.call/closure_fn6.c, - testsuite/libffi.call/closure_loc_fn0.c, - testsuite/libffi.call/closure_stdcall.c, - testsuite/libffi.call/cls_align_pointer.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c: use portable cast from - pointer to integer (intptr_t). - * testsuite/libffi.call/cls_longdouble.c: disable for win64. - -2008-12-19 Anthony Green - - * configure.ac: Bump version to 3.0.8. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-11-11 Anthony Green - - * configure.ac: Bump version to 3.0.7. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-08-25 Andreas Tobler - - * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and - FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. - Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. - Adjust copyright notice. - * src/powerpc/ffi.c: Add two new flags to indicate if we have one - register or two register to use for FFI_SYSV structs. - (ffi_prep_cif_machdep): Pass the right register flag introduced above. - (ffi_closure_helper_SYSV): Fix the return type for - FFI_SYSV_TYPE_SMALL_STRUCT. Comment. - Adjust copyright notice. - -2008-07-24 Anthony Green - - * testsuite/libffi.call/cls_dbls_struct.c, - testsuite/libffi.call/cls_double_va.c, - testsuite/libffi.call/cls_longdouble.c, - testsuite/libffi.call/cls_longdouble_va.c, - testsuite/libffi.call/cls_pointer.c, - testsuite/libffi.call/cls_pointer_stack.c, - testsuite/libffi.call/err_bad_abi.c: Clean up failures from - compiler warnings. - -2008-07-17 Anthony Green - - * configure.ac: Bump version to 3.0.6. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. Add documentation. - * README: Update for new release. - -2008-07-16 Kaz Kojima - - * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned - int. - -2008-07-16 Kaz Kojima - - * src/sh/sysv.S: Add .note.GNU-stack on Linux. - * src/sh64/sysv.S: Likewise. - -2008-04-03 Anthony Green - - * libffi.pc.in (Libs): Add -L${libdir}. - * configure.ac: Bump version to 3.0.5. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-04-03 Anthony Green - Xerces Ranby - - * include/ffi.h.in: Wrap definition of target architecture to - protect from double definitions. - -2008-03-22 Moriyoshi Koizumi - - * src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in - closure_loc_fn0.c. - * testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0): - New test. - -2008-03-04 Anthony Green - Blake Chaffin - hos@tamanegi.org - - * testsuite/libffi.call/cls_align_longdouble_split2.c - testsuite/libffi.call/cls_align_longdouble_split.c - testsuite/libffi.call/cls_dbls_struct.c - testsuite/libffi.call/cls_double_va.c - testsuite/libffi.call/cls_longdouble.c - testsuite/libffi.call/cls_longdouble_va.c - testsuite/libffi.call/cls_pointer.c - testsuite/libffi.call/cls_pointer_stack.c - testsuite/libffi.call/err_bad_abi.c - testsuite/libffi.call/err_bad_typedef.c - testsuite/libffi.call/huge_struct.c - testsuite/libffi.call/stret_large2.c - testsuite/libffi.call/stret_large.c - testsuite/libffi.call/stret_medium2.c - testsuite/libffi.call/stret_medium.c: New tests from Apple. - -2008-02-26 Jakub Jelinek - Anthony Green - - * src/alpha/osf.S: Add .note.GNU-stack on Linux. - * src/s390/sysv.S: Likewise. - * src/powerpc/linux64.S: Likewise. - * src/powerpc/linux64_closure.S: Likewise. - * src/powerpc/ppc_closure.S: Likewise. - * src/powerpc/sysv.S: Likewise. - * src/x86/unix64.S: Likewise. - * src/x86/sysv.S: Likewise. - * src/sparc/v8.S: Likewise. - * src/sparc/v9.S: Likewise. - * src/m68k/sysv.S: Likewise. - * src/ia64/unix.S: Likewise. - * src/arm/sysv.S: Likewise. - -2008-02-26 Anthony Green - Thomas Heller - - * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C - comment. - -2008-02-26 Anthony Green - Thomas Heller - - * include/ffi.h.in: Change void (*)() to void (*)(void). - -2008-02-26 Anthony Green - Thomas Heller - - * src/alpha/ffi.c: Change void (*)() to void (*)(void). - src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c, - src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c, - src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S, - src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c, - src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c, - src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S, - src/x86/ffi64.c: Ditto. - -2008-02-24 Anthony Green - - * configure.ac: Accept openbsd*, not just openbsd. - Bump version to 3.0.4. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-22 Anthony Green - - * README: Clean up list of tested platforms. - -2008-02-22 Anthony Green - - * configure.ac: Bump version to 3.0.3. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. Clean up test docs. - -2008-02-22 Bjoern Koenig - Andreas Tobler - - * configure.ac: Add amd64-*-freebsd* target. - * configure: Regenerate. - -2008-02-22 Thomas Heller - - * configure.ac: Add x86 OpenBSD support. - * configure: Rebuilt. - -2008-02-21 Thomas Heller - - * README: Change "make test" to "make check". - -2008-02-21 Anthony Green - - * configure.ac: Bump version to 3.0.2. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-21 Björn König - - * src/x86/freebsd.S: New file. - * configure.ac: Add x86 FreeBSD support. - * Makefile.am: Ditto. - -2008-02-15 Anthony Green - - * configure.ac: Bump version to 3.0.1. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * libtool-version: Increment revision. - * README: Update for new release. - -2008-02-15 David Daney - - * src/mips/ffi.c: Remove extra '>' from include directive. - (ffi_prep_closure_loc): Use clear_location instead of tramp. - -2008-02-15 Anthony Green - - * configure.ac: Bump version to 3.0.0. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-15 David Daney - - * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): - Define (conditionally), and use it to include cachectl.h. - (ffi_prep_closure_loc): Fix cache flushing. - * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. - -2008-02-15 Anthony Green - - * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3: - Update dates and remove all references to ffi_prep_closure. - * configure.ac: Bump version to 2.99.9. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-15 Anthony Green - - * man/ffi_prep_closure.3: Delete. - * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3. - (man_MANS): Ditto. - * man/Makefile.in: Rebuilt. - * configure.ac: Bump version to 2.99.8. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - -2008-02-14 Anthony Green - - * configure.ac: Bump version to 2.99.7. - * configure, doc/stamp-vti, doc/version.texi: Rebuilt. - * include/ffi.h.in LICENSE src/debug.c src/closures.c - src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h - src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c - src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S - src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c - src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c - src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S - src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h - src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c - src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S - src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h - src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h - src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S - src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h - src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S - src/arm/ffitarget.h src/prep_cif.c: Update license text. - -2008-02-14 Anthony Green - - * README: Update tested platforms. - * configure.ac: Bump version to 2.99.6. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * configure.ac: Bump version to 2.99.5. - * configure: Rebuilt. - * Makefile.am (EXTRA_DIST): Add darwin64.S - * Makefile.in: Rebuilt. - * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree. - * LICENSE: Update WARRANTY. - -2008-02-14 Anthony Green - - * libffi.pc.in (libdir): Fix libdir definition. - * configure.ac: Bump version to 2.99.4. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * README: Update. - * libffi.info: New file. - * doc/stamp-vti: New file. - * configure.ac: Bump version to 2.99.3. - * configure: Rebuilt. - -2008-02-14 Anthony Green - - * Makefile.am (SUBDIRS): Add man dir. - * Makefile.in: Rebuilt. - * configure.ac: Create Makefile. - * configure: Rebuilt. - * man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3 - man/Makefile.am man/Makefile.in: New files. - -2008-02-14 Tom Tromey - - * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt. - * mdate-sh, texinfo.tex: New files. - * Makefile.am (info_TEXINFOS): New variable. - * doc/libffi.texi: New file. - * doc/version.texi: Likewise. - -2008-02-14 Anthony Green - - * Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET). - (lib_LTLIBRARIES): Define. - (toolexeclib_LIBRARIES): Undefine. - * Makefile.in: Rebuilt. - * configure.ac: Reset version to 2.99.1. - * configure.in: Rebuilt. - -2008-02-14 Anthony Green - - * libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@. - * configure.ac: Reset version to 2.99.1. - * configure.in: Rebuilt. - * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi. - * Makefile.in: Rebuilt. - * LICENSE: Update copyright notice. - -2008-02-14 Anthony Green - - * include/Makefile.am (nodist_includes_HEADERS): Define. Don't - distribute ffitarget.h or ffi.h from the build include dir. - * Makefile.in: Rebuilt. - -2008-02-14 Anthony Green - - * include/Makefile.am (includesdir): Install headers under libdir. - (pkgconfigdir): Define. Install libffi.pc. - * include/Makefile.in: Rebuilt. - * libffi.pc.in: Create. - * libtool-version: Increment CURRENT - * configure.ac: Add libffi.pc.in - * configure: Rebuilt. - -2008-02-03 Anthony Green - - * include/Makefile.am (includesdir): Fix header install with - DESTDIR. - * include/Makefile.in: Rebuilt. - -2008-02-03 Timothy Wall - - * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return - offset based on code pointer, not data pointer. - -2008-02-01 Anthony Green - - * include/Makefile.am: Fix header installs. - * Makefile.am: Ditto. - * include/Makefile.in: Rebuilt. - * Makefile.in: Ditto. - -2008-02-01 Anthony Green - - * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL, - FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last - patch. - -2008-01-31 Anthony Green - - * Makefile.am (EXTRA_DIST): Add missing files. - * testsuite/Makefile.am: Ditto. - * Makefile.in, testsuite/Makefile.in: Rebuilt. - -2008-01-31 Timothy Wall - - * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall - closures. - * src/x86/ffitarget.h: Increase size of trampoline for stdcall - closures. - * src/x86/win32.S: Add assembly for stdcall closure. - * src/x86/ffi.c: Initialize stdcall closure trampoline. - -2008-01-30 H.J. Lu - - PR libffi/34612 - * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when - returning struct. - - * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" - tests. - -2008-01-30 Anthony Green - - * Makefile.am, include/Makefile.am: Move headers to - libffi_la_SOURCES for new automake. - * Makefile.in, include/Makefile.in: Rebuilt. - - * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for - execution outside of gcc tree. - * testsuite/lib/target-libpath.exp: Ditto. - - * testsuite/lib/libffi-dg.exp: Many changes to allow for execution - outside of gcc tree. - diff --git a/ChangeLog.libgcj b/ChangeLog.libgcj deleted file mode 100644 index ea5d02f19..000000000 --- a/ChangeLog.libgcj +++ /dev/null @@ -1,40 +0,0 @@ -2004-01-14 Kelley Cook - - * configure.in: Add in AC_PREREQ(2.13) - -2003-02-20 Alexandre Oliva - - * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to - config.status. - * configure: Rebuilt. - -2002-01-27 Alexandre Oliva - - * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. - Remove USE_LIBDIR conditional. - * Makefile.am (toolexecdir, toolexeclibdir): Don't override. - * Makefile.in, configure: Rebuilt. - -Mon Aug 9 18:33:38 1999 Rainer Orth - - * include/Makefile.in: Rebuilt. - * Makefile.in: Rebuilt - * Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native - builds. - Use USE_LIBDIR. - - * configure: Rebuilt. - * configure.in (USE_LIBDIR): Define for native builds. - Use lowercase in configure --help explanations. - -1999-08-08 Anthony Green - - * include/ffi.h.in (FFI_FN): Remove `...'. - -1999-08-08 Anthony Green - - * Makefile.in: Rebuilt. - * Makefile.am (AM_CFLAGS): Compile with -fexceptions. - - * src/x86/sysv.S: Add exception handling metadata. - diff --git a/ChangeLog.libffi-3.1 b/ChangeLog.old similarity index 82% rename from ChangeLog.libffi-3.1 rename to ChangeLog.old index 8f7f50d6f..8de1ca75f 100644 --- a/ChangeLog.libffi-3.1 +++ b/ChangeLog.old @@ -1,3 +1,11 @@ +Libffi change logs used to be maintained in separate ChangeLog files. +These days we generate them directly from the git commit messages. +The old ChangeLog files are saved here in order to maintain the historical +record. + +============================================================================= +From the old ChangeLog.libffi-3.1 file... + 2014-03-16 Josh Triplett * ChangeLog: Archive to ChangeLog.libffi-3.1 and delete. Future @@ -5998,3 +6006,1402 @@ Thu Jul 8 14:28:42 1999 Anthony Green * src/x86/ChangeLog: Removed. * ChangeLog.v1: Created. + +============================================================================= +From the old ChangeLog.libffi file.... + +2011-02-08 Andreas Tobler + + * testsuite/lib/libffi.exp: Tweak for stand-alone mode. + +2009-12-25 Samuli Suominen + + * configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64. + * configure: Rebuilt. + * fficonfig.h.in: Rebuilt. + +2009-06-16 Andrew Haley + + * testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs. + * testsuite/libffi.call/float2.c: Fix dg-excess-errors. + * testsuite/libffi.call/ffitest.h, + testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define. + +2009-06-12 Andrew Haley + + * testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_medium2.c: Fix printf format + specifiers. + testsuite/libffi.special/unwindtest.cc: include stdint.h. + +2009-06-11 Timothy Wall + + * Makefile.am, + configure.ac, + include/ffi.h.in, + include/ffi_common.h, + src/closures.c, + src/dlmalloc.c, + src/x86/ffi.c, + src/x86/ffitarget.h, + src/x86/win64.S (new), + README: Added win64 support (mingw or MSVC) + * Makefile.in, + include/Makefile.in, + man/Makefile.in, + testsuite/Makefile.in, + configure, + aclocal.m4: Regenerated + * ltcf-c.sh: properly escape cygwin/w32 path + * man/ffi_call.3: Clarify size requirements for return value. + * src/x86/ffi64.c: Fix filename in comment. + * src/x86/win32.S: Remove unused extern. + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_12byte.c, + testsuite/libffi.call/cls_16byte.c, + testsuite/libffi.call/cls_18byte.c, + testsuite/libffi.call/cls_19byte.c, + testsuite/libffi.call/cls_1_1byte.c, + testsuite/libffi.call/cls_20byte.c, + testsuite/libffi.call/cls_20byte1.c, + testsuite/libffi.call/cls_24byte.c, + testsuite/libffi.call/cls_2byte.c, + testsuite/libffi.call/cls_3_1byte.c, + testsuite/libffi.call/cls_3byte1.c, + testsuite/libffi.call/cls_3byte2.c, + testsuite/libffi.call/cls_4_1byte.c, + testsuite/libffi.call/cls_4byte.c, + testsuite/libffi.call/cls_5_1_byte.c, + testsuite/libffi.call/cls_5byte.c, + testsuite/libffi.call/cls_64byte.c, + testsuite/libffi.call/cls_6_1_byte.c, + testsuite/libffi.call/cls_6byte.c, + testsuite/libffi.call/cls_7_1_byte.c, + testsuite/libffi.call/cls_7byte.c, + testsuite/libffi.call/cls_8byte.c, + testsuite/libffi.call/cls_9byte1.c, + testsuite/libffi.call/cls_9byte2.c, + testsuite/libffi.call/cls_align_double.c, + testsuite/libffi.call/cls_align_float.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_align_sint16.c, + testsuite/libffi.call/cls_align_sint32.c, + testsuite/libffi.call/cls_align_sint64.c, + testsuite/libffi.call/cls_align_uint16.c, + testsuite/libffi.call/cls_align_uint32.c, + testsuite/libffi.call/cls_align_uint64.c, + testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_float.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_multi_schar.c, + testsuite/libffi.call/cls_multi_sshort.c, + testsuite/libffi.call/cls_multi_sshortchar.c, + testsuite/libffi.call/cls_multi_uchar.c, + testsuite/libffi.call/cls_multi_ushort.c, + testsuite/libffi.call/cls_multi_ushortchar.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/cls_schar.c, + testsuite/libffi.call/cls_sint.c, + testsuite/libffi.call/cls_sshort.c, + testsuite/libffi.call/cls_uchar.c, + testsuite/libffi.call/cls_uint.c, + testsuite/libffi.call/cls_ulonglong.c, + testsuite/libffi.call/cls_ushort.c, + testsuite/libffi.call/err_bad_abi.c, + testsuite/libffi.call/err_bad_typedef.c, + testsuite/libffi.call/float2.c, + testsuite/libffi.call/huge_struct.c, + testsuite/libffi.call/nested_struct.c, + testsuite/libffi.call/nested_struct1.c, + testsuite/libffi.call/nested_struct10.c, + testsuite/libffi.call/nested_struct2.c, + testsuite/libffi.call/nested_struct3.c, + testsuite/libffi.call/nested_struct4.c, + testsuite/libffi.call/nested_struct5.c, + testsuite/libffi.call/nested_struct6.c, + testsuite/libffi.call/nested_struct7.c, + testsuite/libffi.call/nested_struct8.c, + testsuite/libffi.call/nested_struct9.c, + testsuite/libffi.call/problem1.c, + testsuite/libffi.call/return_ldl.c, + testsuite/libffi.call/return_ll1.c, + testsuite/libffi.call/stret_large.c, + testsuite/libffi.call/stret_large2.c, + testsuite/libffi.call/stret_medium.c, + testsuite/libffi.call/stret_medium2.c, + testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead + of checking for MMAP. Use intptr_t instead of long casts. + +2009-06-04 Andrew Haley + + * src/powerpc/ffitarget.h: Fix misapplied merge from gcc. + +2009-06-04 Andrew Haley + + * src/mips/o32.S, + src/mips/n32.S: Fix licence formatting. + +2009-06-04 Andrew Haley + + * src/x86/darwin.S: Fix licence formatting. + src/x86/win32.S: Likewise. + src/sh64/sysv.S: Likewise. + src/sh/sysv.S: Likewise. + +2009-06-04 Andrew Haley + + * src/sh64/ffi.c: Remove lint directives. Was missing from merge + of Andreas Tobler's patch from 2006-04-22. + +2009-06-04 Andrew Haley + + * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of + 2007-03-07. + +2008-12-26 Timothy Wall + + * testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_align_longdouble.c, + testsuite/libffi.call/cls_align_longdouble_split.c, + testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected + failures on x86_64 cygwin/mingw. + +2008-12-22 Timothy Wall + + * testsuite/libffi.call/closure_fn0.c, + testsuite/libffi.call/closure_fn1.c, + testsuite/libffi.call/closure_fn2.c, + testsuite/libffi.call/closure_fn3.c, + testsuite/libffi.call/closure_fn4.c, + testsuite/libffi.call/closure_fn5.c, + testsuite/libffi.call/closure_fn6.c, + testsuite/libffi.call/closure_loc_fn0.c, + testsuite/libffi.call/closure_stdcall.c, + testsuite/libffi.call/cls_align_pointer.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c: use portable cast from + pointer to integer (intptr_t). + * testsuite/libffi.call/cls_longdouble.c: disable for win64. + +2008-12-19 Anthony Green + + * configure.ac: Bump version to 3.0.8. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-11-11 Anthony Green + + * configure.ac: Bump version to 3.0.7. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-08-25 Andreas Tobler + + * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and + FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum. + Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT. + Adjust copyright notice. + * src/powerpc/ffi.c: Add two new flags to indicate if we have one + register or two register to use for FFI_SYSV structs. + (ffi_prep_cif_machdep): Pass the right register flag introduced above. + (ffi_closure_helper_SYSV): Fix the return type for + FFI_SYSV_TYPE_SMALL_STRUCT. Comment. + Adjust copyright notice. + +2008-07-24 Anthony Green + + * testsuite/libffi.call/cls_dbls_struct.c, + testsuite/libffi.call/cls_double_va.c, + testsuite/libffi.call/cls_longdouble.c, + testsuite/libffi.call/cls_longdouble_va.c, + testsuite/libffi.call/cls_pointer.c, + testsuite/libffi.call/cls_pointer_stack.c, + testsuite/libffi.call/err_bad_abi.c: Clean up failures from + compiler warnings. + +2008-07-17 Anthony Green + + * configure.ac: Bump version to 3.0.6. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. Add documentation. + * README: Update for new release. + +2008-07-16 Kaz Kojima + + * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned + int. + +2008-07-16 Kaz Kojima + + * src/sh/sysv.S: Add .note.GNU-stack on Linux. + * src/sh64/sysv.S: Likewise. + +2008-04-03 Anthony Green + + * libffi.pc.in (Libs): Add -L${libdir}. + * configure.ac: Bump version to 3.0.5. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-04-03 Anthony Green + Xerces Ranby + + * include/ffi.h.in: Wrap definition of target architecture to + protect from double definitions. + +2008-03-22 Moriyoshi Koizumi + + * src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in + closure_loc_fn0.c. + * testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0): + New test. + +2008-03-04 Anthony Green + Blake Chaffin + hos@tamanegi.org + + * testsuite/libffi.call/cls_align_longdouble_split2.c + testsuite/libffi.call/cls_align_longdouble_split.c + testsuite/libffi.call/cls_dbls_struct.c + testsuite/libffi.call/cls_double_va.c + testsuite/libffi.call/cls_longdouble.c + testsuite/libffi.call/cls_longdouble_va.c + testsuite/libffi.call/cls_pointer.c + testsuite/libffi.call/cls_pointer_stack.c + testsuite/libffi.call/err_bad_abi.c + testsuite/libffi.call/err_bad_typedef.c + testsuite/libffi.call/huge_struct.c + testsuite/libffi.call/stret_large2.c + testsuite/libffi.call/stret_large.c + testsuite/libffi.call/stret_medium2.c + testsuite/libffi.call/stret_medium.c: New tests from Apple. + +2008-02-26 Jakub Jelinek + Anthony Green + + * src/alpha/osf.S: Add .note.GNU-stack on Linux. + * src/s390/sysv.S: Likewise. + * src/powerpc/linux64.S: Likewise. + * src/powerpc/linux64_closure.S: Likewise. + * src/powerpc/ppc_closure.S: Likewise. + * src/powerpc/sysv.S: Likewise. + * src/x86/unix64.S: Likewise. + * src/x86/sysv.S: Likewise. + * src/sparc/v8.S: Likewise. + * src/sparc/v9.S: Likewise. + * src/m68k/sysv.S: Likewise. + * src/ia64/unix.S: Likewise. + * src/arm/sysv.S: Likewise. + +2008-02-26 Anthony Green + Thomas Heller + + * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C + comment. + +2008-02-26 Anthony Green + Thomas Heller + + * include/ffi.h.in: Change void (*)() to void (*)(void). + +2008-02-26 Anthony Green + Thomas Heller + + * src/alpha/ffi.c: Change void (*)() to void (*)(void). + src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c, + src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c, + src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S, + src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c, + src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c, + src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S, + src/x86/ffi64.c: Ditto. + +2008-02-24 Anthony Green + + * configure.ac: Accept openbsd*, not just openbsd. + Bump version to 3.0.4. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-22 Anthony Green + + * README: Clean up list of tested platforms. + +2008-02-22 Anthony Green + + * configure.ac: Bump version to 3.0.3. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. Clean up test docs. + +2008-02-22 Bjoern Koenig + Andreas Tobler + + * configure.ac: Add amd64-*-freebsd* target. + * configure: Regenerate. + +2008-02-22 Thomas Heller + + * configure.ac: Add x86 OpenBSD support. + * configure: Rebuilt. + +2008-02-21 Thomas Heller + + * README: Change "make test" to "make check". + +2008-02-21 Anthony Green + + * configure.ac: Bump version to 3.0.2. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-21 Björn König + + * src/x86/freebsd.S: New file. + * configure.ac: Add x86 FreeBSD support. + * Makefile.am: Ditto. + +2008-02-15 Anthony Green + + * configure.ac: Bump version to 3.0.1. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * libtool-version: Increment revision. + * README: Update for new release. + +2008-02-15 David Daney + + * src/mips/ffi.c: Remove extra '>' from include directive. + (ffi_prep_closure_loc): Use clear_location instead of tramp. + +2008-02-15 Anthony Green + + * configure.ac: Bump version to 3.0.0. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-15 David Daney + + * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE): + Define (conditionally), and use it to include cachectl.h. + (ffi_prep_closure_loc): Fix cache flushing. + * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define. + +2008-02-15 Anthony Green + + * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3: + Update dates and remove all references to ffi_prep_closure. + * configure.ac: Bump version to 2.99.9. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-15 Anthony Green + + * man/ffi_prep_closure.3: Delete. + * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3. + (man_MANS): Ditto. + * man/Makefile.in: Rebuilt. + * configure.ac: Bump version to 2.99.8. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + +2008-02-14 Anthony Green + + * configure.ac: Bump version to 2.99.7. + * configure, doc/stamp-vti, doc/version.texi: Rebuilt. + * include/ffi.h.in LICENSE src/debug.c src/closures.c + src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h + src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c + src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S + src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c + src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c + src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S + src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h + src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c + src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S + src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h + src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h + src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S + src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h + src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S + src/arm/ffitarget.h src/prep_cif.c: Update license text. + +2008-02-14 Anthony Green + + * README: Update tested platforms. + * configure.ac: Bump version to 2.99.6. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * configure.ac: Bump version to 2.99.5. + * configure: Rebuilt. + * Makefile.am (EXTRA_DIST): Add darwin64.S + * Makefile.in: Rebuilt. + * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree. + * LICENSE: Update WARRANTY. + +2008-02-14 Anthony Green + + * libffi.pc.in (libdir): Fix libdir definition. + * configure.ac: Bump version to 2.99.4. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * README: Update. + * libffi.info: New file. + * doc/stamp-vti: New file. + * configure.ac: Bump version to 2.99.3. + * configure: Rebuilt. + +2008-02-14 Anthony Green + + * Makefile.am (SUBDIRS): Add man dir. + * Makefile.in: Rebuilt. + * configure.ac: Create Makefile. + * configure: Rebuilt. + * man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3 + man/Makefile.am man/Makefile.in: New files. + +2008-02-14 Tom Tromey + + * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt. + * mdate-sh, texinfo.tex: New files. + * Makefile.am (info_TEXINFOS): New variable. + * doc/libffi.texi: New file. + * doc/version.texi: Likewise. + +2008-02-14 Anthony Green + + * Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET). + (lib_LTLIBRARIES): Define. + (toolexeclib_LIBRARIES): Undefine. + * Makefile.in: Rebuilt. + * configure.ac: Reset version to 2.99.1. + * configure.in: Rebuilt. + +2008-02-14 Anthony Green + + * libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@. + * configure.ac: Reset version to 2.99.1. + * configure.in: Rebuilt. + * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi. + * Makefile.in: Rebuilt. + * LICENSE: Update copyright notice. + +2008-02-14 Anthony Green + + * include/Makefile.am (nodist_includes_HEADERS): Define. Don't + distribute ffitarget.h or ffi.h from the build include dir. + * Makefile.in: Rebuilt. + +2008-02-14 Anthony Green + + * include/Makefile.am (includesdir): Install headers under libdir. + (pkgconfigdir): Define. Install libffi.pc. + * include/Makefile.in: Rebuilt. + * libffi.pc.in: Create. + * libtool-version: Increment CURRENT + * configure.ac: Add libffi.pc.in + * configure: Rebuilt. + +2008-02-03 Anthony Green + + * include/Makefile.am (includesdir): Fix header install with + DESTDIR. + * include/Makefile.in: Rebuilt. + +2008-02-03 Timothy Wall + + * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return + offset based on code pointer, not data pointer. + +2008-02-01 Anthony Green + + * include/Makefile.am: Fix header installs. + * Makefile.am: Ditto. + * include/Makefile.in: Rebuilt. + * Makefile.in: Ditto. + +2008-02-01 Anthony Green + + * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL, + FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last + patch. + +2008-01-31 Anthony Green + + * Makefile.am (EXTRA_DIST): Add missing files. + * testsuite/Makefile.am: Ditto. + * Makefile.in, testsuite/Makefile.in: Rebuilt. + +2008-01-31 Timothy Wall + + * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall + closures. + * src/x86/ffitarget.h: Increase size of trampoline for stdcall + closures. + * src/x86/win32.S: Add assembly for stdcall closure. + * src/x86/ffi.c: Initialize stdcall closure trampoline. + +2008-01-30 H.J. Lu + + PR libffi/34612 + * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when + returning struct. + + * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer" + tests. + +2008-01-30 Anthony Green + + * Makefile.am, include/Makefile.am: Move headers to + libffi_la_SOURCES for new automake. + * Makefile.in, include/Makefile.in: Rebuilt. + + * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for + execution outside of gcc tree. + * testsuite/lib/target-libpath.exp: Ditto. + + * testsuite/lib/libffi-dg.exp: Many changes to allow for execution + outside of gcc tree. + + +============================================================================= +From the old ChangeLog.libgcj file.... + +2004-01-14 Kelley Cook + + * configure.in: Add in AC_PREREQ(2.13) + +2003-02-20 Alexandre Oliva + + * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to + config.status. + * configure: Rebuilt. + +2002-01-27 Alexandre Oliva + + * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST. + Remove USE_LIBDIR conditional. + * Makefile.am (toolexecdir, toolexeclibdir): Don't override. + * Makefile.in, configure: Rebuilt. + +Mon Aug 9 18:33:38 1999 Rainer Orth + + * include/Makefile.in: Rebuilt. + * Makefile.in: Rebuilt + * Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native + builds. + Use USE_LIBDIR. + + * configure: Rebuilt. + * configure.in (USE_LIBDIR): Define for native builds. + Use lowercase in configure --help explanations. + +1999-08-08 Anthony Green + + * include/ffi.h.in (FFI_FN): Remove `...'. + +1999-08-08 Anthony Green + + * Makefile.in: Rebuilt. + * Makefile.am (AM_CFLAGS): Compile with -fexceptions. + + * src/x86/sysv.S: Add exception handling metadata. + + +============================================================================= + +The libffi version 1 ChangeLog archive. + +Version 1 of libffi had per-directory ChangeLogs. Current and future +versions have a single ChangeLog file in the root directory. The +version 1 ChangeLogs have all been concatenated into this file for +future reference only. + +--- libffi ---------------------------------------------------------------- + +Mon Oct 5 02:17:50 1998 Anthony Green + + * configure.in: Boosted rev. + * configure, Makefile.in, aclocal.m4: Rebuilt. + * README: Boosted rev and updated release notes. + +Mon Oct 5 01:03:03 1998 Anthony Green + + * configure.in: Boosted rev. + * configure, Makefile.in, aclocal.m4: Rebuilt. + * README: Boosted rev and updated release notes. + +1998-07-25 Andreas Schwab + + * m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags. + Correctly handle small structures. + (ffi_prep_args): Also handle small structures. + (ffi_call): Pass size of return type to ffi_call_SYSV. + * m68k/sysv.S: Adjust for above changes. Correctly align small + structures in the return value. + + * types.c (uint64, sint64) [M68K]: Change alignment to 4. + +Fri Apr 17 17:26:58 1998 Anthony Green + + * configure.in: Boosted rev. + * configure,Makefile.in,aclocal.m4: Rebuilt. + * README: Boosted rev and added release notes. + +Sun Feb 22 00:50:41 1998 Geoff Keating + + * configure.in: Add PowerPC config bits. + +1998-02-14 Andreas Schwab + + * configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM + to AC_CANONICAL_HOST, this is not a compiler. Use $host instead + of $target. Remove AC_CHECK_SIZEOF(char), we already know the + result. Fix argument of AC_ARG_ENABLE. + * configure, fficonfig.h.in: Rebuilt. + +Tue Feb 10 20:53:40 1998 Richard Henderson + + * configure.in: Add Alpha config bits. + +Tue May 13 13:39:20 1997 Anthony Green + + * README: Updated dates and reworded Irix comments. + + * configure.in: Removed AC_PROG_RANLIB. + + * Makefile.in, aclocal.m4, config.guess, config.sub, configure, + ltmain.sh, */Makefile.in: libtoolized again and rebuilt with + automake and autoconf. + +Sat May 10 18:44:50 1997 Tom Tromey + + * configure, aclocal.m4: Rebuilt. + * configure.in: Don't compute EXTRADIST; now handled in + src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE. + Don't run AM_MAINTAINER_MODE. + +Thu May 8 14:34:05 1997 Anthony Green + + * missing, ltmain.sh, ltconfig.sh: Created. These are new files + required by automake and libtool. + + * README: Boosted rev to 1.14. Added notes. + + * acconfig.h: Moved PACKAGE and VERSION for new automake. + + * configure.in: Changes for libtool. + + * Makefile.am (check): make test now make check. Uses libtool now. + + * Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt. + +Thu May 1 16:27:07 1997 Anthony Green + + * missing: Added file required by new automake. + +Tue Nov 26 14:10:42 1996 Anthony Green + + * acconfig.h: Added USING_PURIFY flag. This is defined when + --enable-purify-safety was used at configure time. + + * configure.in (allsources): Added --enable-purify-safety switch. + (VERSION): Boosted rev to 1.13. + * configure: Rebuilt. + +Fri Nov 22 06:46:12 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.12. + Removed special CFLAGS hack for gcc. + * configure: Rebuilt. + + * README: Boosted rev to 1.12. Added notes. + + * Many files: Cygnus Support changed to Cygnus Solutions. + +Wed Oct 30 11:15:25 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.11. + * configure: Rebuilt. + + * README: Boosted rev to 1.11. Added notes about GNU make. + +Tue Oct 29 12:25:12 1996 Anthony Green + + * configure.in: Fixed -Wall trick. + (VERSION): Boosted rev. + * configure: Rebuilt + + * acconfig.h: Needed for --enable-debug configure switch. + + * README: Boosted rev to 1.09. Added more notes on building + libffi, and LCLint. + + * configure.in: Added --enable-debug switch. Boosted rev to + 1.09. + * configure: Rebuilt + +Tue Oct 15 13:11:28 1996 Anthony Green + + * configure.in (VERSION): Boosted rev to 1.08 + * configure: Rebuilt. + + * README: Added n32 bug fix notes. + + * Makefile.am: Added "make lint" production. + * Makefile.in: Rebuilt. + +Mon Oct 14 10:54:46 1996 Anthony Green + + * README: Added web page reference. + + * configure.in, README: Boosted rev to 1.05 + * configure: Rebuilt. + + * README: Fixed n32 sample code. + +Fri Oct 11 17:09:28 1996 Anthony Green + + * README: Added sparc notes. + + * configure.in, README: Boosted rev to 1.04. + * configure: Rebuilt. + +Thu Oct 10 10:31:03 1996 Anthony Green + + * configure.in, README: Boosted rev to 1.03. + * configure: Rebuilt. + + * README: Added struct notes. + + * Makefile.am (EXTRA_DIST): Added LICENSE to distribution. + * Makefile.in: Rebuilt. + + * README: Removed Linux section. No special notes now + because aggregates arg/return types work. + +Wed Oct 9 16:16:42 1996 Anthony Green + + * README, configure.in (VERSION): Boosted rev to 1.02 + * configure: Rebuilt. + +Tue Oct 8 11:56:33 1996 Anthony Green + + * README (NOTE): Added n32 notes. + + * Makefile.am: Added test production. + * Makefile: Rebuilt + + * README: spell checked! + + * configure.in (VERSION): Boosted rev to 1.01 + * configure: Rebuilt. + +Mon Oct 7 15:50:22 1996 Anthony Green + + * configure.in: Added nasty bit to support SGI tools. + * configure: Rebuilt. + + * README: Added SGI notes. Added note about automake bug. + +Mon Oct 7 11:00:28 1996 Anthony Green + + * README: Rewrote intro, and fixed examples. + +Fri Oct 4 10:19:55 1996 Anthony Green + + * configure.in: -D$TARGET is no longer used as a compiler switch. + It is now inserted into ffi.h at configure time. + * configure: Rebuilt. + + * FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status. + +Thu Oct 3 13:47:34 1996 Anthony Green + + * README, LICENSE: Created. Wrote some docs. + + * configure.in: Don't barf on i586-unknown-linuxaout. + Added EXTRADIST code for "make dist". + * configure: Rebuilt. + + * */Makefile.in: Rebuilt with patched automake. + +Tue Oct 1 17:12:25 1996 Anthony Green + + * Makefile.am, aclocal.m4, config.guess, config.sub, + configure.in, fficonfig.h.in, install-sh, mkinstalldirs, + stamp-h.in: Created + * Makefile.in, configure: Generated + +--- libffi/include -------------------------------------------------------- + +Tue Feb 24 13:09:36 1998 Anthony Green + + * ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on + ffi.h.in changes. This is a work-around for SGI's "simple" + assembler. + +Sun Feb 22 00:51:55 1998 Geoff Keating + + * ffi.h.in: PowerPC support. + +1998-02-14 Andreas Schwab + + * ffi.h.in: Add m68k support. + (FFI_TYPE_LONGDOUBLE): Make it a separate value. + +Tue Feb 10 20:55:16 1998 Richard Henderson + + * ffi.h.in (SIZEOF_ARG): Use a pointer type by default. + + * ffi.h.in: Alpha support. + +Fri Nov 22 06:48:45 1996 Anthony Green + + * ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions. + +Wed Nov 20 22:31:01 1996 Anthony Green + + * ffi.h.in: Added ffi_type_void definition. + +Tue Oct 29 12:22:40 1996 Anthony Green + + * Makefile.am (hack_DATA): Always install ffi_mips.h. + + * ffi.h.in: Removed FFI_DEBUG. It's now in the correct + place (acconfig.h). + Added #include for size_t definition. + +Tue Oct 15 17:23:35 1996 Anthony Green + + * ffi.h.in, ffi_common.h, ffi_mips.h: More clean up. + Commented out #define of FFI_DEBUG. + +Tue Oct 15 13:01:06 1996 Anthony Green + + * ffi_common.h: Added bool definition. + + * ffi.h.in, ffi_common.h: Clean up based on LCLint output. + Added funny /*@...@*/ comments to annotate source. + +Mon Oct 14 12:29:23 1996 Anthony Green + + * ffi.h.in: Interface changes based on feedback from Jim + Blandy. + +Fri Oct 11 16:49:35 1996 Anthony Green + + * ffi.h.in: Small change for sparc support. + +Thu Oct 10 14:53:37 1996 Anthony Green + + * ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for + special structure return types. + +Wed Oct 9 13:55:57 1996 Anthony Green + + * ffi.h.in: Added SIZEOF_ARG definition for X86 + +Tue Oct 8 11:40:36 1996 Anthony Green + + * ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings. + Use it to case your function pointers to the proper type. + + * ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug. + + * Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST. + * Makefile: Rebuilt. + + * ffi_mips.h: Created. Moved all common mips definitions here. + +Mon Oct 7 10:58:12 1996 Anthony Green + + * ffi.h.in: The SGI assember is very picky about parens. Redefined + some macros to avoid problems. + + * ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added + externs for pointer, and 64bit integral ffi_types. + +Fri Oct 4 09:51:37 1996 Anthony Green + + * ffi.h.in: Added FFI_ABI member to ffi_cif and changed + function prototypes accordingly. + Added #define @TARGET@. Now programs including ffi.h don't + have to specify this themselves. + +Thu Oct 3 15:36:44 1996 Anthony Green + + * ffi.h.in: Changed ffi_prep_cif's values from void* to void** + + * Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist" + to work. + * Makefile.in: Regenerated. + +Wed Oct 2 10:16:59 1996 Anthony Green + + * Makefile.am: Created + * Makefile.in: Generated + + * ffi_common.h: Added rcsid comment + +Tue Oct 1 17:13:51 1996 Anthony Green + + * ffi.h.in, ffi_common.h: Created + +--- libffi/src ------------------------------------------------------------ + +Mon Oct 5 02:17:50 1998 Anthony Green + + * arm/ffi.c, arm/sysv.S: Created. + + * Makefile.am: Added arm files. + * Makefile.in: Rebuilt. + +Mon Oct 5 01:41:38 1998 Anthony Green + + * Makefile.am (libffi_la_LDFLAGS): Incremented revision. + +Sun Oct 4 16:27:17 1998 Anthony Green + + * alpha/osf.S (ffi_call_osf): Patch for DU assembler. + + * ffitest.c (main): long long and long double return values work + for x86. + +Fri Apr 17 11:50:58 1998 Anthony Green + + * Makefile.in: Rebuilt. + + * ffitest.c (main): Floating point tests not executed for systems + with broken lond double (SunOS 4 w/ GCC). + + * types.c: Fixed x86 alignment info for long long types. + +Thu Apr 16 07:15:28 1998 Anthony Green + + * ffitest.c: Added more notes about GCC bugs under Irix 6. + +Wed Apr 15 08:42:22 1998 Anthony Green + + * ffitest.c (struct5): New test function. + (main): New test with struct5. + +Thu Mar 5 10:48:11 1998 Anthony Green + + * prep_cif.c (initialize_aggregate): Fix assertion for + nested structures. + +Tue Feb 24 16:33:41 1998 Anthony Green + + * prep_cif.c (ffi_prep_cif): Added long double support for sparc. + +Sun Feb 22 00:52:18 1998 Geoff Keating + + * powerpc/asm.h: New file. + * powerpc/ffi.c: New file. + * powerpc/sysv.S: New file. + * Makefile.am: PowerPC port. + * ffitest.c (main): Allow all tests to run even in presence of gcc + bug on PowerPC. + +1998-02-17 Anthony Green + + * mips/ffi.c: Fixed comment typo. + + * x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat): + Fixed x86 long double return handling. + + * types.c: Fixed x86 long double alignment info. + +1998-02-14 Andreas Schwab + + * types.c: Add m68k support. + + * ffitest.c (floating): Add long double parameter. + (return_ll, ldblit): New functions to test long long and long + double return value. + (main): Fix type error in assignment of ts[1-4]_type.elements. + Add tests for long long and long double arguments and return + values. + + * prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for + struct value pointer. + + * m68k/ffi.c, m68k/sysv.S: New files. + * Makefile.am: Add bits for m68k port. Add kludge to work around + automake deficiency. + (test): Don't require "." in $PATH. + * Makefile.in: Rebuilt. + +Wed Feb 11 07:36:50 1998 Anthony Green + + * Makefile.in: Rebuilt. + +Tue Feb 10 20:56:00 1998 Richard Henderson + + * alpha/ffi.c, alpha/osf.S: New files. + * Makefile.am: Alpha port. + +Tue Nov 18 14:12:07 1997 Anthony Green + + * mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag + for n32. + +Tue Jun 3 17:18:20 1997 Anthony Green + + * ffitest.c (main): Added hack to get structure tests working + correctly. + +Sat May 10 19:06:42 1997 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (EXTRA_DIST): Explicitly list all distributable + files in subdirs. + (VERSION, CC): Removed. + +Thu May 8 17:19:01 1997 Anthony Green + + * Makefile.am: Many changes for new automake and libtool. + * Makefile.in: Rebuilt. + +Fri Nov 22 06:57:56 1996 Anthony Green + + * ffitest.c (main): Fixed test case for non mips machines. + +Wed Nov 20 22:31:59 1996 Anthony Green + + * types.c: Added ffi_type_void declaration. + +Tue Oct 29 13:07:19 1996 Anthony Green + + * ffitest.c (main): Fixed character constants. + (main): Emit warning for structure test 3 failure on Sun. + + * Makefile.am (VPATH): Fixed VPATH def'n so automake won't + strip it out. + Moved distdir hack from libffi to automake. + (ffitest): Added missing -c for $(COMPILE) (change in automake). + * Makefile.in: Rebuilt. + +Tue Oct 15 13:08:20 1996 Anthony Green + + * Makefile.am: Added "make lint" production. + * Makefile.in: Rebuilt. + + * prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro. + Clean up based on LCLint output. Added funny /*@...@*/ comments to + annotate source. + + * ffitest.c, debug.c: Cleaned up code. + +Mon Oct 14 12:26:56 1996 Anthony Green + + * ffitest.c: Changes based on interface changes. + + * prep_cif.c (ffi_prep_cif): Cleaned up interface based on + feedback from Jim Blandy. + +Fri Oct 11 15:53:18 1996 Anthony Green + + * ffitest.c: Reordered tests while porting to sparc. + Made changes to handle lame structure passing for sparc. + Removed calls to fflush(). + + * prep_cif.c (ffi_prep_cif): Added special case for sparc + aggregate type arguments. + +Thu Oct 10 09:56:51 1996 Anthony Green + + * ffitest.c (main): Added structure passing/returning tests. + + * prep_cif.c (ffi_prep_cif): Perform proper initialization + of structure return types if needed. + (initialize_aggregate): Bug fix + +Wed Oct 9 16:04:20 1996 Anthony Green + + * types.c: Added special definitions for x86 (double doesn't + need double word alignment). + + * ffitest.c: Added many tests + +Tue Oct 8 09:19:22 1996 Anthony Green + + * prep_cif.c (ffi_prep_cif): Fixed assertion. + + * debug.c (ffi_assert): Must return a non void now. + + * Makefile.am: Added test production. + * Makefile: Rebuilt. + + * ffitest.c (main): Created. + + * types.c: Created. Stripped common code out of */ffi.c. + + * prep_cif.c: Added missing stdlib.h include. + + * debug.c (ffi_type_test): Used "a" to eliminate compiler + warnings in non-debug builds. Included ffi_common.h. + +Mon Oct 7 15:36:42 1996 Anthony Green + + * Makefile.am: Added a rule for .s -> .o + This is required by the SGI compiler. + * Makefile: Rebuilt. + +Fri Oct 4 09:51:08 1996 Anthony Green + + * prep_cif.c (initialize_aggregate): Moved abi specification + to ffi_prep_cif(). + +Thu Oct 3 15:37:37 1996 Anthony Green + + * prep_cif.c (ffi_prep_cif): Changed values from void* to void**. + (initialize_aggregate): Fixed aggregate type initialization. + + * Makefile.am (EXTRA_DIST): Added support code for "make dist". + * Makefile.in: Regenerated. + +Wed Oct 2 11:41:57 1996 Anthony Green + + * debug.c, prep_cif: Created. + + * Makefile.am: Added debug.o and prep_cif.o to OBJ. + * Makefile.in: Regenerated. + + * Makefile.am (INCLUDES): Added missing -I../include + * Makefile.in: Regenerated. + +Tue Oct 1 17:11:51 1996 Anthony Green + + * error.c, Makefile.am: Created. + * Makefile.in: Generated. + +--- libffi/src/x86 -------------------------------------------------------- + +Sun Oct 4 16:27:17 1998 Anthony Green + + * sysv.S (retlongdouble): Fixed long long return value support. + * ffi.c (ffi_prep_cif_machdep): Ditto. + +Wed May 13 04:30:33 1998 Anthony Green + + * ffi.c (ffi_prep_cif_machdep): Fixed long double return value + support. + +Wed Apr 15 08:43:20 1998 Anthony Green + + * ffi.c (ffi_prep_args): small struct support was missing. + +Thu May 8 16:53:58 1997 Anthony Green + + * objects.mak: Removed. + +Mon Dec 2 15:12:58 1996 Tom Tromey + + * sysv.S: Use .balign, for a.out Linux boxes. + +Tue Oct 15 13:06:50 1996 Anthony Green + + * ffi.c: Clean up based on LCLint output. + Added funny /*@...@*/ comments to annotate source. + +Fri Oct 11 16:43:38 1996 Anthony Green + + * ffi.c (ffi_call): Added assertion for bad ABIs. + +Wed Oct 9 13:57:27 1996 Anthony Green + + * sysv.S (retdouble): Fixed double return problems. + + * ffi.c (ffi_call): Corrected fn arg definition. + (ffi_prep_cif_machdep): Fixed double return problems + +Tue Oct 8 12:12:49 1996 Anthony Green + + * ffi.c: Moved ffi_type definitions to types.c. + (ffi_prep_args): Fixed type promotion bug. + +Mon Oct 7 15:53:06 1996 Anthony Green + + * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' + +Fri Oct 4 09:54:53 1996 Anthony Green + + * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped + remaining args. + +Wed Oct 2 10:07:05 1996 Anthony Green + + * ffi.c, sysv.S, objects.mak: Created. + (ffi_prep_cif): cif->rvalue no longer initialized to NULL. + (ffi_prep_cif_machdep): Moved machine independent cif processing + to src/prep_cif.c. Introduced ffi_prep_cif_machdep(). + +--- libffi/src/mips ------------------------------------------------------- + +Tue Feb 17 17:18:07 1998 Anthony Green + + * o32.S: Fixed typo in comment. + + * ffi.c (ffi_prep_cif_machdep): Fixed argument processing. + +Thu May 8 16:53:58 1997 Anthony Green + + * o32.s, n32.s: Wrappers for SGI tool support. + + * objects.mak: Removed. + +Tue Oct 29 14:37:45 1996 Anthony Green + + * ffi.c (ffi_prep_args): Changed int z to size_t z. + +Tue Oct 15 13:17:25 1996 Anthony Green + + * n32.S: Fixed bad stack munging. + + * ffi.c: Moved prototypes for ffi_call_?32() to here from + ffi_mips.h because extended_cif is not defined in ffi_mips.h. + +Mon Oct 14 12:42:02 1996 Anthony Green + + * ffi.c: Interface changes based on feedback from Jim Blandy. + +Thu Oct 10 11:22:16 1996 Anthony Green + + * n32.S, ffi.c: Lots of changes to support passing and + returning structures with the n32 calling convention. + + * n32.S: Fixed fn pointer bug. + + * ffi.c (ffi_prep_cif_machdep): Fix for o32 structure + return values. + (ffi_prep_args): Fixed n32 structure passing when structures + partially fit in registers. + +Wed Oct 9 13:49:25 1996 Anthony Green + + * objects.mak: Added n32.o. + + * n32.S: Created. + + * ffi.c (ffi_prep_args): Added magic to support proper + n32 processing. + +Tue Oct 8 10:37:35 1996 Anthony Green + + * ffi.c: Moved ffi_type definitions to types.c. + (ffi_prep_args): Fixed type promotion bug. + + * o32.S: This code is only built for o32 compiles. + A lot of the #define cruft has moved to ffi_mips.h. + + * ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg + is only processed if the first is either a float or double. + +Mon Oct 7 15:33:59 1996 Anthony Green + + * o32.S: Modified to compile under each of o32, n32 and n64. + + * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' + +Fri Oct 4 09:53:25 1996 Anthony Green + + * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped + remaining args. + +Wed Oct 2 17:41:22 1996 Anthony Green + + * o32.S: Removed crufty definitions. + +Wed Oct 2 12:53:42 1996 Anthony Green + + * ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL. + (ffi_prep_cif_machdep): Moved all machine independent cif processing + to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types + of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT. + +Tue Oct 1 17:11:02 1996 Anthony Green + + * ffi.c, o32.S, object.mak: Created + +--- libffi/src/sparc ------------------------------------------------------ + +Tue Feb 24 16:33:18 1998 Anthony Green + + * ffi.c (ffi_prep_args): Added long double support. + +Thu May 8 16:53:58 1997 Anthony Green + + * objects.mak: Removed. + +Thu May 1 16:07:56 1997 Anthony Green + + * v8.S: Fixed minor portability problem reported by + Russ McManus . + +Tue Nov 26 14:12:43 1996 Anthony Green + + * v8.S: Used STACKFRAME define elsewhere. + + * ffi.c (ffi_prep_args): Zero out space when USING_PURIFY + is set. + (ffi_prep_cif_machdep): Allocate the correct stack frame + space for functions with < 6 args. + +Tue Oct 29 15:08:55 1996 Anthony Green + + * ffi.c (ffi_prep_args): int z is now size_t z. + +Mon Oct 14 13:31:24 1996 Anthony Green + + * v8.S (ffi_call_V8): Gordon rewrites this again. It looks + great now. + + * ffi.c (ffi_call): The comment about hijacked registers + is no longer valid after gordoni hacked v8.S. + + * v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler. + + * v8.S, ffi.c: ffi_call() had changed to accept more than + two args, so v8.S had to change (because it hijacks incoming + arg registers). + + * ffi.c: Interface changes based on feedback from Jim Blandy. + +Thu Oct 10 17:48:16 1996 Anthony Green + + * ffi.c, v8.S, objects.mak: Created. + + diff --git a/ChangeLog.v1 b/ChangeLog.v1 deleted file mode 100644 index af3a37756..000000000 --- a/ChangeLog.v1 +++ /dev/null @@ -1,764 +0,0 @@ -The libffi version 1 ChangeLog archive. - -Version 1 of libffi had per-directory ChangeLogs. Current and future -versions have a single ChangeLog file in the root directory. The -version 1 ChangeLogs have all been concatenated into this file for -future reference only. - ---- libffi ---------------------------------------------------------------- - -Mon Oct 5 02:17:50 1998 Anthony Green - - * configure.in: Boosted rev. - * configure, Makefile.in, aclocal.m4: Rebuilt. - * README: Boosted rev and updated release notes. - -Mon Oct 5 01:03:03 1998 Anthony Green - - * configure.in: Boosted rev. - * configure, Makefile.in, aclocal.m4: Rebuilt. - * README: Boosted rev and updated release notes. - -1998-07-25 Andreas Schwab - - * m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags. - Correctly handle small structures. - (ffi_prep_args): Also handle small structures. - (ffi_call): Pass size of return type to ffi_call_SYSV. - * m68k/sysv.S: Adjust for above changes. Correctly align small - structures in the return value. - - * types.c (uint64, sint64) [M68K]: Change alignment to 4. - -Fri Apr 17 17:26:58 1998 Anthony Green - - * configure.in: Boosted rev. - * configure,Makefile.in,aclocal.m4: Rebuilt. - * README: Boosted rev and added release notes. - -Sun Feb 22 00:50:41 1998 Geoff Keating - - * configure.in: Add PowerPC config bits. - -1998-02-14 Andreas Schwab - - * configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM - to AC_CANONICAL_HOST, this is not a compiler. Use $host instead - of $target. Remove AC_CHECK_SIZEOF(char), we already know the - result. Fix argument of AC_ARG_ENABLE. - * configure, fficonfig.h.in: Rebuilt. - -Tue Feb 10 20:53:40 1998 Richard Henderson - - * configure.in: Add Alpha config bits. - -Tue May 13 13:39:20 1997 Anthony Green - - * README: Updated dates and reworded Irix comments. - - * configure.in: Removed AC_PROG_RANLIB. - - * Makefile.in, aclocal.m4, config.guess, config.sub, configure, - ltmain.sh, */Makefile.in: libtoolized again and rebuilt with - automake and autoconf. - -Sat May 10 18:44:50 1997 Tom Tromey - - * configure, aclocal.m4: Rebuilt. - * configure.in: Don't compute EXTRADIST; now handled in - src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE. - Don't run AM_MAINTAINER_MODE. - -Thu May 8 14:34:05 1997 Anthony Green - - * missing, ltmain.sh, ltconfig.sh: Created. These are new files - required by automake and libtool. - - * README: Boosted rev to 1.14. Added notes. - - * acconfig.h: Moved PACKAGE and VERSION for new automake. - - * configure.in: Changes for libtool. - - * Makefile.am (check): make test now make check. Uses libtool now. - - * Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt. - -Thu May 1 16:27:07 1997 Anthony Green - - * missing: Added file required by new automake. - -Tue Nov 26 14:10:42 1996 Anthony Green - - * acconfig.h: Added USING_PURIFY flag. This is defined when - --enable-purify-safety was used at configure time. - - * configure.in (allsources): Added --enable-purify-safety switch. - (VERSION): Boosted rev to 1.13. - * configure: Rebuilt. - -Fri Nov 22 06:46:12 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.12. - Removed special CFLAGS hack for gcc. - * configure: Rebuilt. - - * README: Boosted rev to 1.12. Added notes. - - * Many files: Cygnus Support changed to Cygnus Solutions. - -Wed Oct 30 11:15:25 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.11. - * configure: Rebuilt. - - * README: Boosted rev to 1.11. Added notes about GNU make. - -Tue Oct 29 12:25:12 1996 Anthony Green - - * configure.in: Fixed -Wall trick. - (VERSION): Boosted rev. - * configure: Rebuilt - - * acconfig.h: Needed for --enable-debug configure switch. - - * README: Boosted rev to 1.09. Added more notes on building - libffi, and LCLint. - - * configure.in: Added --enable-debug switch. Boosted rev to - 1.09. - * configure: Rebuilt - -Tue Oct 15 13:11:28 1996 Anthony Green - - * configure.in (VERSION): Boosted rev to 1.08 - * configure: Rebuilt. - - * README: Added n32 bug fix notes. - - * Makefile.am: Added "make lint" production. - * Makefile.in: Rebuilt. - -Mon Oct 14 10:54:46 1996 Anthony Green - - * README: Added web page reference. - - * configure.in, README: Boosted rev to 1.05 - * configure: Rebuilt. - - * README: Fixed n32 sample code. - -Fri Oct 11 17:09:28 1996 Anthony Green - - * README: Added sparc notes. - - * configure.in, README: Boosted rev to 1.04. - * configure: Rebuilt. - -Thu Oct 10 10:31:03 1996 Anthony Green - - * configure.in, README: Boosted rev to 1.03. - * configure: Rebuilt. - - * README: Added struct notes. - - * Makefile.am (EXTRA_DIST): Added LICENSE to distribution. - * Makefile.in: Rebuilt. - - * README: Removed Linux section. No special notes now - because aggregates arg/return types work. - -Wed Oct 9 16:16:42 1996 Anthony Green - - * README, configure.in (VERSION): Boosted rev to 1.02 - * configure: Rebuilt. - -Tue Oct 8 11:56:33 1996 Anthony Green - - * README (NOTE): Added n32 notes. - - * Makefile.am: Added test production. - * Makefile: Rebuilt - - * README: spell checked! - - * configure.in (VERSION): Boosted rev to 1.01 - * configure: Rebuilt. - -Mon Oct 7 15:50:22 1996 Anthony Green - - * configure.in: Added nasty bit to support SGI tools. - * configure: Rebuilt. - - * README: Added SGI notes. Added note about automake bug. - -Mon Oct 7 11:00:28 1996 Anthony Green - - * README: Rewrote intro, and fixed examples. - -Fri Oct 4 10:19:55 1996 Anthony Green - - * configure.in: -D$TARGET is no longer used as a compiler switch. - It is now inserted into ffi.h at configure time. - * configure: Rebuilt. - - * FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status. - -Thu Oct 3 13:47:34 1996 Anthony Green - - * README, LICENSE: Created. Wrote some docs. - - * configure.in: Don't barf on i586-unknown-linuxaout. - Added EXTRADIST code for "make dist". - * configure: Rebuilt. - - * */Makefile.in: Rebuilt with patched automake. - -Tue Oct 1 17:12:25 1996 Anthony Green - - * Makefile.am, aclocal.m4, config.guess, config.sub, - configure.in, fficonfig.h.in, install-sh, mkinstalldirs, - stamp-h.in: Created - * Makefile.in, configure: Generated - ---- libffi/include -------------------------------------------------------- - -Tue Feb 24 13:09:36 1998 Anthony Green - - * ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on - ffi.h.in changes. This is a work-around for SGI's "simple" - assembler. - -Sun Feb 22 00:51:55 1998 Geoff Keating - - * ffi.h.in: PowerPC support. - -1998-02-14 Andreas Schwab - - * ffi.h.in: Add m68k support. - (FFI_TYPE_LONGDOUBLE): Make it a separate value. - -Tue Feb 10 20:55:16 1998 Richard Henderson - - * ffi.h.in (SIZEOF_ARG): Use a pointer type by default. - - * ffi.h.in: Alpha support. - -Fri Nov 22 06:48:45 1996 Anthony Green - - * ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions. - -Wed Nov 20 22:31:01 1996 Anthony Green - - * ffi.h.in: Added ffi_type_void definition. - -Tue Oct 29 12:22:40 1996 Anthony Green - - * Makefile.am (hack_DATA): Always install ffi_mips.h. - - * ffi.h.in: Removed FFI_DEBUG. It's now in the correct - place (acconfig.h). - Added #include for size_t definition. - -Tue Oct 15 17:23:35 1996 Anthony Green - - * ffi.h.in, ffi_common.h, ffi_mips.h: More clean up. - Commented out #define of FFI_DEBUG. - -Tue Oct 15 13:01:06 1996 Anthony Green - - * ffi_common.h: Added bool definition. - - * ffi.h.in, ffi_common.h: Clean up based on LCLint output. - Added funny /*@...@*/ comments to annotate source. - -Mon Oct 14 12:29:23 1996 Anthony Green - - * ffi.h.in: Interface changes based on feedback from Jim - Blandy. - -Fri Oct 11 16:49:35 1996 Anthony Green - - * ffi.h.in: Small change for sparc support. - -Thu Oct 10 14:53:37 1996 Anthony Green - - * ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for - special structure return types. - -Wed Oct 9 13:55:57 1996 Anthony Green - - * ffi.h.in: Added SIZEOF_ARG definition for X86 - -Tue Oct 8 11:40:36 1996 Anthony Green - - * ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings. - Use it to case your function pointers to the proper type. - - * ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug. - - * Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST. - * Makefile: Rebuilt. - - * ffi_mips.h: Created. Moved all common mips definitions here. - -Mon Oct 7 10:58:12 1996 Anthony Green - - * ffi.h.in: The SGI assember is very picky about parens. Redefined - some macros to avoid problems. - - * ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added - externs for pointer, and 64bit integral ffi_types. - -Fri Oct 4 09:51:37 1996 Anthony Green - - * ffi.h.in: Added FFI_ABI member to ffi_cif and changed - function prototypes accordingly. - Added #define @TARGET@. Now programs including ffi.h don't - have to specify this themselves. - -Thu Oct 3 15:36:44 1996 Anthony Green - - * ffi.h.in: Changed ffi_prep_cif's values from void* to void** - - * Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist" - to work. - * Makefile.in: Regenerated. - -Wed Oct 2 10:16:59 1996 Anthony Green - - * Makefile.am: Created - * Makefile.in: Generated - - * ffi_common.h: Added rcsid comment - -Tue Oct 1 17:13:51 1996 Anthony Green - - * ffi.h.in, ffi_common.h: Created - ---- libffi/src ------------------------------------------------------------ - -Mon Oct 5 02:17:50 1998 Anthony Green - - * arm/ffi.c, arm/sysv.S: Created. - - * Makefile.am: Added arm files. - * Makefile.in: Rebuilt. - -Mon Oct 5 01:41:38 1998 Anthony Green - - * Makefile.am (libffi_la_LDFLAGS): Incremented revision. - -Sun Oct 4 16:27:17 1998 Anthony Green - - * alpha/osf.S (ffi_call_osf): Patch for DU assembler. - - * ffitest.c (main): long long and long double return values work - for x86. - -Fri Apr 17 11:50:58 1998 Anthony Green - - * Makefile.in: Rebuilt. - - * ffitest.c (main): Floating point tests not executed for systems - with broken lond double (SunOS 4 w/ GCC). - - * types.c: Fixed x86 alignment info for long long types. - -Thu Apr 16 07:15:28 1998 Anthony Green - - * ffitest.c: Added more notes about GCC bugs under Irix 6. - -Wed Apr 15 08:42:22 1998 Anthony Green - - * ffitest.c (struct5): New test function. - (main): New test with struct5. - -Thu Mar 5 10:48:11 1998 Anthony Green - - * prep_cif.c (initialize_aggregate): Fix assertion for - nested structures. - -Tue Feb 24 16:33:41 1998 Anthony Green - - * prep_cif.c (ffi_prep_cif): Added long double support for sparc. - -Sun Feb 22 00:52:18 1998 Geoff Keating - - * powerpc/asm.h: New file. - * powerpc/ffi.c: New file. - * powerpc/sysv.S: New file. - * Makefile.am: PowerPC port. - * ffitest.c (main): Allow all tests to run even in presence of gcc - bug on PowerPC. - -1998-02-17 Anthony Green - - * mips/ffi.c: Fixed comment typo. - - * x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat): - Fixed x86 long double return handling. - - * types.c: Fixed x86 long double alignment info. - -1998-02-14 Andreas Schwab - - * types.c: Add m68k support. - - * ffitest.c (floating): Add long double parameter. - (return_ll, ldblit): New functions to test long long and long - double return value. - (main): Fix type error in assignment of ts[1-4]_type.elements. - Add tests for long long and long double arguments and return - values. - - * prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for - struct value pointer. - - * m68k/ffi.c, m68k/sysv.S: New files. - * Makefile.am: Add bits for m68k port. Add kludge to work around - automake deficiency. - (test): Don't require "." in $PATH. - * Makefile.in: Rebuilt. - -Wed Feb 11 07:36:50 1998 Anthony Green - - * Makefile.in: Rebuilt. - -Tue Feb 10 20:56:00 1998 Richard Henderson - - * alpha/ffi.c, alpha/osf.S: New files. - * Makefile.am: Alpha port. - -Tue Nov 18 14:12:07 1997 Anthony Green - - * mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag - for n32. - -Tue Jun 3 17:18:20 1997 Anthony Green - - * ffitest.c (main): Added hack to get structure tests working - correctly. - -Sat May 10 19:06:42 1997 Tom Tromey - - * Makefile.in: Rebuilt. - * Makefile.am (EXTRA_DIST): Explicitly list all distributable - files in subdirs. - (VERSION, CC): Removed. - -Thu May 8 17:19:01 1997 Anthony Green - - * Makefile.am: Many changes for new automake and libtool. - * Makefile.in: Rebuilt. - -Fri Nov 22 06:57:56 1996 Anthony Green - - * ffitest.c (main): Fixed test case for non mips machines. - -Wed Nov 20 22:31:59 1996 Anthony Green - - * types.c: Added ffi_type_void declaration. - -Tue Oct 29 13:07:19 1996 Anthony Green - - * ffitest.c (main): Fixed character constants. - (main): Emit warning for structure test 3 failure on Sun. - - * Makefile.am (VPATH): Fixed VPATH def'n so automake won't - strip it out. - Moved distdir hack from libffi to automake. - (ffitest): Added missing -c for $(COMPILE) (change in automake). - * Makefile.in: Rebuilt. - -Tue Oct 15 13:08:20 1996 Anthony Green - - * Makefile.am: Added "make lint" production. - * Makefile.in: Rebuilt. - - * prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro. - Clean up based on LCLint output. Added funny /*@...@*/ comments to - annotate source. - - * ffitest.c, debug.c: Cleaned up code. - -Mon Oct 14 12:26:56 1996 Anthony Green - - * ffitest.c: Changes based on interface changes. - - * prep_cif.c (ffi_prep_cif): Cleaned up interface based on - feedback from Jim Blandy. - -Fri Oct 11 15:53:18 1996 Anthony Green - - * ffitest.c: Reordered tests while porting to sparc. - Made changes to handle lame structure passing for sparc. - Removed calls to fflush(). - - * prep_cif.c (ffi_prep_cif): Added special case for sparc - aggregate type arguments. - -Thu Oct 10 09:56:51 1996 Anthony Green - - * ffitest.c (main): Added structure passing/returning tests. - - * prep_cif.c (ffi_prep_cif): Perform proper initialization - of structure return types if needed. - (initialize_aggregate): Bug fix - -Wed Oct 9 16:04:20 1996 Anthony Green - - * types.c: Added special definitions for x86 (double doesn't - need double word alignment). - - * ffitest.c: Added many tests - -Tue Oct 8 09:19:22 1996 Anthony Green - - * prep_cif.c (ffi_prep_cif): Fixed assertion. - - * debug.c (ffi_assert): Must return a non void now. - - * Makefile.am: Added test production. - * Makefile: Rebuilt. - - * ffitest.c (main): Created. - - * types.c: Created. Stripped common code out of */ffi.c. - - * prep_cif.c: Added missing stdlib.h include. - - * debug.c (ffi_type_test): Used "a" to eliminate compiler - warnings in non-debug builds. Included ffi_common.h. - -Mon Oct 7 15:36:42 1996 Anthony Green - - * Makefile.am: Added a rule for .s -> .o - This is required by the SGI compiler. - * Makefile: Rebuilt. - -Fri Oct 4 09:51:08 1996 Anthony Green - - * prep_cif.c (initialize_aggregate): Moved abi specification - to ffi_prep_cif(). - -Thu Oct 3 15:37:37 1996 Anthony Green - - * prep_cif.c (ffi_prep_cif): Changed values from void* to void**. - (initialize_aggregate): Fixed aggregate type initialization. - - * Makefile.am (EXTRA_DIST): Added support code for "make dist". - * Makefile.in: Regenerated. - -Wed Oct 2 11:41:57 1996 Anthony Green - - * debug.c, prep_cif: Created. - - * Makefile.am: Added debug.o and prep_cif.o to OBJ. - * Makefile.in: Regenerated. - - * Makefile.am (INCLUDES): Added missing -I../include - * Makefile.in: Regenerated. - -Tue Oct 1 17:11:51 1996 Anthony Green - - * error.c, Makefile.am: Created. - * Makefile.in: Generated. - ---- libffi/src/x86 -------------------------------------------------------- - -Sun Oct 4 16:27:17 1998 Anthony Green - - * sysv.S (retlongdouble): Fixed long long return value support. - * ffi.c (ffi_prep_cif_machdep): Ditto. - -Wed May 13 04:30:33 1998 Anthony Green - - * ffi.c (ffi_prep_cif_machdep): Fixed long double return value - support. - -Wed Apr 15 08:43:20 1998 Anthony Green - - * ffi.c (ffi_prep_args): small struct support was missing. - -Thu May 8 16:53:58 1997 Anthony Green - - * objects.mak: Removed. - -Mon Dec 2 15:12:58 1996 Tom Tromey - - * sysv.S: Use .balign, for a.out Linux boxes. - -Tue Oct 15 13:06:50 1996 Anthony Green - - * ffi.c: Clean up based on LCLint output. - Added funny /*@...@*/ comments to annotate source. - -Fri Oct 11 16:43:38 1996 Anthony Green - - * ffi.c (ffi_call): Added assertion for bad ABIs. - -Wed Oct 9 13:57:27 1996 Anthony Green - - * sysv.S (retdouble): Fixed double return problems. - - * ffi.c (ffi_call): Corrected fn arg definition. - (ffi_prep_cif_machdep): Fixed double return problems - -Tue Oct 8 12:12:49 1996 Anthony Green - - * ffi.c: Moved ffi_type definitions to types.c. - (ffi_prep_args): Fixed type promotion bug. - -Mon Oct 7 15:53:06 1996 Anthony Green - - * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' - -Fri Oct 4 09:54:53 1996 Anthony Green - - * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped - remaining args. - -Wed Oct 2 10:07:05 1996 Anthony Green - - * ffi.c, sysv.S, objects.mak: Created. - (ffi_prep_cif): cif->rvalue no longer initialized to NULL. - (ffi_prep_cif_machdep): Moved machine independent cif processing - to src/prep_cif.c. Introduced ffi_prep_cif_machdep(). - ---- libffi/src/mips ------------------------------------------------------- - -Tue Feb 17 17:18:07 1998 Anthony Green - - * o32.S: Fixed typo in comment. - - * ffi.c (ffi_prep_cif_machdep): Fixed argument processing. - -Thu May 8 16:53:58 1997 Anthony Green - - * o32.s, n32.s: Wrappers for SGI tool support. - - * objects.mak: Removed. - -Tue Oct 29 14:37:45 1996 Anthony Green - - * ffi.c (ffi_prep_args): Changed int z to size_t z. - -Tue Oct 15 13:17:25 1996 Anthony Green - - * n32.S: Fixed bad stack munging. - - * ffi.c: Moved prototypes for ffi_call_?32() to here from - ffi_mips.h because extended_cif is not defined in ffi_mips.h. - -Mon Oct 14 12:42:02 1996 Anthony Green - - * ffi.c: Interface changes based on feedback from Jim Blandy. - -Thu Oct 10 11:22:16 1996 Anthony Green - - * n32.S, ffi.c: Lots of changes to support passing and - returning structures with the n32 calling convention. - - * n32.S: Fixed fn pointer bug. - - * ffi.c (ffi_prep_cif_machdep): Fix for o32 structure - return values. - (ffi_prep_args): Fixed n32 structure passing when structures - partially fit in registers. - -Wed Oct 9 13:49:25 1996 Anthony Green - - * objects.mak: Added n32.o. - - * n32.S: Created. - - * ffi.c (ffi_prep_args): Added magic to support proper - n32 processing. - -Tue Oct 8 10:37:35 1996 Anthony Green - - * ffi.c: Moved ffi_type definitions to types.c. - (ffi_prep_args): Fixed type promotion bug. - - * o32.S: This code is only built for o32 compiles. - A lot of the #define cruft has moved to ffi_mips.h. - - * ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg - is only processed if the first is either a float or double. - -Mon Oct 7 15:33:59 1996 Anthony Green - - * o32.S: Modified to compile under each of o32, n32 and n64. - - * ffi.c (FFI_*_TYPEDEF): Removed redundant ';' - -Fri Oct 4 09:53:25 1996 Anthony Green - - * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped - remaining args. - -Wed Oct 2 17:41:22 1996 Anthony Green - - * o32.S: Removed crufty definitions. - -Wed Oct 2 12:53:42 1996 Anthony Green - - * ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL. - (ffi_prep_cif_machdep): Moved all machine independent cif processing - to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types - of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT. - -Tue Oct 1 17:11:02 1996 Anthony Green - - * ffi.c, o32.S, object.mak: Created - ---- libffi/src/sparc ------------------------------------------------------ - -Tue Feb 24 16:33:18 1998 Anthony Green - - * ffi.c (ffi_prep_args): Added long double support. - -Thu May 8 16:53:58 1997 Anthony Green - - * objects.mak: Removed. - -Thu May 1 16:07:56 1997 Anthony Green - - * v8.S: Fixed minor portability problem reported by - Russ McManus . - -Tue Nov 26 14:12:43 1996 Anthony Green - - * v8.S: Used STACKFRAME define elsewhere. - - * ffi.c (ffi_prep_args): Zero out space when USING_PURIFY - is set. - (ffi_prep_cif_machdep): Allocate the correct stack frame - space for functions with < 6 args. - -Tue Oct 29 15:08:55 1996 Anthony Green - - * ffi.c (ffi_prep_args): int z is now size_t z. - -Mon Oct 14 13:31:24 1996 Anthony Green - - * v8.S (ffi_call_V8): Gordon rewrites this again. It looks - great now. - - * ffi.c (ffi_call): The comment about hijacked registers - is no longer valid after gordoni hacked v8.S. - - * v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler. - - * v8.S, ffi.c: ffi_call() had changed to accept more than - two args, so v8.S had to change (because it hijacks incoming - arg registers). - - * ffi.c: Interface changes based on feedback from Jim Blandy. - -Thu Oct 10 17:48:16 1996 Anthony Green - - * ffi.c, v8.S, objects.mak: Created. - - From 09dc0a71a44c95ee0d2f47de94b6b59534c2ce24 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 15 Nov 2019 10:19:00 -0500 Subject: [PATCH 061/231] Stretch out timeout for test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a70a17e1b..175265178 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,5 +65,5 @@ install: script: - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi - - travis_wait 59 sleep infinity & + - travis_wait 115 sleep infinity & - ./.travis/build.sh From 6f221e8269aa16f6b5eec41cfd1d7d90a9fbea0c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 15 Nov 2019 11:06:17 -0500 Subject: [PATCH 062/231] Disable wine builds. --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 175265178..bfbe34e60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,9 @@ matrix: # env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 - - os: linux - env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" +# This currently exceeds the 50min timeout on travis-ci +# - os: linux +# env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux From b58bd77236e7d41fc04b4be7edd1c6728626c99b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 15 Nov 2019 11:18:59 -0500 Subject: [PATCH 063/231] Re-enable mingw32 tests. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bfbe34e60..175265178 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,8 @@ matrix: # env: HOST=aarch64-apple-darwin13 - os: osx env: HOST=x86_64-apple-darwin10 -# This currently exceeds the 50min timeout on travis-ci -# - os: linux -# env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" + - os: linux + env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" - os: linux env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - os: linux From 73dd43afc8a447ba98ea02e9aad4c6898dc77fb0 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 17 Nov 2019 07:22:25 -0600 Subject: [PATCH 064/231] IEEE754 binary128 long double support for PowerPC64 (#526) * powerpc: Adjust flags to make room for vector types * powerpc64 ELFv2 IEEE128 long double support --- src/powerpc/ffi.c | 5 +- src/powerpc/ffi_linux64.c | 162 ++++++++++++++++++++++++++++++++-- src/powerpc/ffi_powerpc.h | 25 ++++-- src/powerpc/ffitarget.h | 14 ++- src/powerpc/linux64.S | 111 +++++++++++++++++------ src/powerpc/linux64_closure.S | 70 ++++++++++++++- 6 files changed, 335 insertions(+), 52 deletions(-) diff --git a/src/powerpc/ffi.c b/src/powerpc/ffi.c index 94a117004..a19bcbbfc 100644 --- a/src/powerpc/ffi.c +++ b/src/powerpc/ffi.c @@ -85,8 +85,9 @@ ffi_call_int (ffi_cif *cif, can write r3 and r4 to memory without worrying about struct size. For ELFv2 ABI, use a bounce buffer for homogeneous structs too, - for similar reasons. */ - unsigned long smst_buffer[8]; + for similar reasons. This bounce buffer must be aligned to 16 + bytes for use with homogeneous structs of vectors (float128). */ + float128 smst_buffer[8]; extended_cif ecif; ecif.cif = cif; diff --git a/src/powerpc/ffi_linux64.c b/src/powerpc/ffi_linux64.c index 4cf59a434..de0d03376 100644 --- a/src/powerpc/ffi_linux64.c +++ b/src/powerpc/ffi_linux64.c @@ -38,7 +38,8 @@ /* About the LINUX64 ABI. */ enum { NUM_GPR_ARG_REGISTERS64 = 8, - NUM_FPR_ARG_REGISTERS64 = 13 + NUM_FPR_ARG_REGISTERS64 = 13, + NUM_VEC_ARG_REGISTERS64 = 12, }; enum { ASM_NEEDS_REGISTERS64 = 4 }; @@ -81,11 +82,12 @@ discover_homogeneous_aggregate (ffi_abi abi, of FPRs, but according to the ABI must be considered distinct from doubles. They are also limited to a maximum of four members in a homogeneous aggregate. */ - else + else if ((abi & FFI_LINUX_LONG_DOUBLE_IEEE128) == 0) { *elnum = 2; return FFI_TYPE_LONGDOUBLE; } + /* Fall through. */ #endif case FFI_TYPE_FLOAT: case FFI_TYPE_DOUBLE: @@ -130,13 +132,23 @@ ffi_prep_cif_linux64_core (ffi_cif *cif) { ffi_type **ptr; unsigned bytes; - unsigned i, fparg_count = 0, intarg_count = 0; + unsigned i, fparg_count = 0, intarg_count = 0, vecarg_count = 0; unsigned flags = cif->flags; unsigned elt, elnum, rtype; #if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE - /* If compiled without long double support.. */ - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + /* If compiled without long double support... */ + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0 || + (cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + return FFI_BAD_ABI; +#elif !defined(__VEC__) + /* If compiled without vector register support (used by assembly)... */ + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + return FFI_BAD_ABI; +#else + /* If the IEEE128 flag is set, but long double is only 64 bits wide... */ + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) == 0 && + (cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) return FFI_BAD_ABI; #endif @@ -166,6 +178,11 @@ ffi_prep_cif_linux64_core (ffi_cif *cif) { #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + flags |= FLAG_RETURNS_VEC; + break; + } if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) flags |= FLAG_RETURNS_128BITS; /* Fall through. */ @@ -221,6 +238,15 @@ ffi_prep_cif_linux64_core (ffi_cif *cif) { #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + vecarg_count++; + /* Align to 16 bytes, plus the 16-byte argument. */ + intarg_count = (intarg_count + 3) & ~0x1; + if (vecarg_count > NUM_VEC_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + break; + } if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) { fparg_count++; @@ -248,6 +274,17 @@ ffi_prep_cif_linux64_core (ffi_cif *cif) } intarg_count += ((*ptr)->size + 7) / 8; elt = discover_homogeneous_aggregate (cif->abi, *ptr, &elnum); +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + if (elt == FFI_TYPE_LONGDOUBLE && + (cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + vecarg_count += elnum; + if (vecarg_count > NUM_VEC_ARG_REGISTERS64) + flags |= FLAG_ARG_NEEDS_PSAVE; + break; + } + else +#endif if (elt) { fparg_count += elnum; @@ -286,10 +323,17 @@ ffi_prep_cif_linux64_core (ffi_cif *cif) flags |= FLAG_FP_ARGUMENTS; if (intarg_count > 4) flags |= FLAG_4_GPR_ARGUMENTS; + if (vecarg_count != 0) + flags |= FLAG_VEC_ARGUMENTS; /* Space for the FPR registers, if needed. */ if (fparg_count != 0) bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double); + /* Space for the vector registers, if needed, aligned to 16 bytes. */ + if (vecarg_count != 0) { + bytes = (bytes + 15) & ~0xF; + bytes += NUM_VEC_ARG_REGISTERS64 * sizeof (float128); + } /* Stack space. */ #if _CALL_ELF == 2 @@ -372,6 +416,8 @@ ffi_prep_cif_linux64_var (ffi_cif *cif, |--------------------------------------------| | | FPR registers f1-f13 (optional) 13*8 | | |--------------------------------------------| | + | VEC registers v2-v13 (optional) 12*16 | | + |--------------------------------------------| | | Parameter save area | | |--------------------------------------------| | | TOC save area 8 | | @@ -401,6 +447,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) unsigned long *ul; float *f; double *d; + float128 *f128; size_t p; } valp; @@ -419,6 +466,11 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) valp fpr_base; unsigned int fparg_count; + /* 'vec_base' points at the space for v2, and grows upwards as + we use vector registers. */ + valp vec_base; + unsigned int vecarg_count; + unsigned int i, words, nargs, nfixedargs; ffi_type **ptr; double double_tmp; @@ -435,6 +487,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) unsigned long **ul; float **f; double **d; + float128 **f128; } p_argv; unsigned long gprvalue; unsigned long align; @@ -449,11 +502,21 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) #endif fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64; fparg_count = 0; + /* Place the vector args below the FPRs, if used, else the GPRs. */ + if (ecif->cif->flags & FLAG_FP_ARGUMENTS) + vec_base.p = fpr_base.p & ~0xF; + else + vec_base.p = gpr_base.p; + vec_base.f128 -= NUM_VEC_ARG_REGISTERS64; + vecarg_count = 0; next_arg.ul = gpr_base.ul; /* Check that everything starts aligned properly. */ FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0); FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0); + FFI_ASSERT (((unsigned long) gpr_base.c & 0xF) == 0); + FFI_ASSERT (((unsigned long) gpr_end.c & 0xF) == 0); + FFI_ASSERT (((unsigned long) vec_base.c & 0xF) == 0); FFI_ASSERT ((bytes & 0xF) == 0); /* Deal with return values that are actually pass-by-reference. */ @@ -478,6 +541,22 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) { #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: + if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + next_arg.p = FFI_ALIGN (next_arg.p, 16); + if (next_arg.ul == gpr_end.ul) + next_arg.ul = rest.ul; + if (vecarg_count < NUM_VEC_ARG_REGISTERS64 && i < nfixedargs) + *vec_base.f128++ = **p_argv.f128; + else + *next_arg.f128 = **p_argv.f128; + if (++next_arg.f128 == gpr_end.f128) + next_arg.f128 = rest.f128; + vecarg_count++; + FFI_ASSERT (__LDBL_MANT_DIG__ == 113); + FFI_ASSERT (flags & FLAG_VEC_ARGUMENTS); + break; + } if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) { double_tmp = (*p_argv.d)[0]; @@ -589,9 +668,29 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) void *v; float *f; double *d; + float128 *f128; } arg; arg.v = *p_argv.v; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + if (elt == FFI_TYPE_LONGDOUBLE && + (ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + do + { + if (vecarg_count < NUM_VEC_ARG_REGISTERS64 + && i < nfixedargs) + *vec_base.f128++ = *arg.f128++; + else + *next_arg.f128 = *arg.f128++; + if (++next_arg.f128 == gpr_end.f128) + next_arg.f128 = rest.f128; + vecarg_count++; + } + while (--elnum != 0); + } + else +#endif if (elt == FFI_TYPE_FLOAT) { do @@ -762,17 +861,20 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, void *user_data, void *rvalue, unsigned long *pst, - ffi_dblfl *pfr) + ffi_dblfl *pfr, + float128 *pvec) { /* rvalue is the pointer to space for return value in closure assembly */ /* pst is the pointer to parameter save area (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */ /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */ + /* pvec is the pointer to where v2-v13 are stored in ffi_closure_LINUX64 */ void **avalue; ffi_type **arg_types; unsigned long i, avn, nfixedargs; ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64; + float128 *end_pvec = pvec + NUM_VEC_ARG_REGISTERS64; unsigned long align; avalue = alloca (cif->nargs * sizeof (void *)); @@ -851,6 +953,7 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, unsigned long *ul; float *f; double *d; + float128 *f128; size_t p; } to, from; @@ -858,6 +961,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, aggregate size is not greater than the space taken by the registers so store back to the register/parameter save arrays. */ +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + if (elt == FFI_TYPE_LONGDOUBLE && + (cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + if (pvec + elnum <= end_pvec) + to.v = pvec; + else + to.v = pst; + } + else +#endif if (pfr + elnum <= end_pfr) to.v = pfr; else @@ -865,6 +979,23 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, avalue[i] = to.v; from.ul = pst; +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE + if (elt == FFI_TYPE_LONGDOUBLE && + (cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + do + { + if (pvec < end_pvec && i < nfixedargs) + *to.f128 = *pvec++; + else + *to.f128 = *from.f128; + to.f128++; + from.f128++; + } + while (--elnum != 0); + } + else +#endif if (elt == FFI_TYPE_FLOAT) { do @@ -920,7 +1051,18 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE case FFI_TYPE_LONGDOUBLE: - if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) + if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0) + { + if (((unsigned long) pst & 0xF) != 0) + ++pst; + if (pvec < end_pvec && i < nfixedargs) + avalue[i] = pvec++; + else + avalue[i] = pst; + pst += 2; + break; + } + else if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0) { if (pfr + 1 < end_pfr && i + 1 < nfixedargs) { @@ -995,13 +1137,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, /* Tell ffi_closure_LINUX64 how to perform return type promotions. */ if ((cif->flags & FLAG_RETURNS_SMST) != 0) { - if ((cif->flags & FLAG_RETURNS_FP) == 0) + if ((cif->flags & (FLAG_RETURNS_FP | FLAG_RETURNS_VEC)) == 0) return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1; + else if ((cif->flags & FLAG_RETURNS_VEC) != 0) + return FFI_V2_TYPE_VECTOR_HOMOG; else if ((cif->flags & FLAG_RETURNS_64BITS) != 0) return FFI_V2_TYPE_DOUBLE_HOMOG; else return FFI_V2_TYPE_FLOAT_HOMOG; } + if ((cif->flags & FLAG_RETURNS_VEC) != 0) + return FFI_V2_TYPE_VECTOR; return cif->rtype->type; } #endif diff --git a/src/powerpc/ffi_powerpc.h b/src/powerpc/ffi_powerpc.h index 3dcd6b571..5ee2a7095 100644 --- a/src/powerpc/ffi_powerpc.h +++ b/src/powerpc/ffi_powerpc.h @@ -31,22 +31,24 @@ enum { /* The assembly depends on these exact flags. */ /* These go in cr7 */ - FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ + FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */ FLAG_RETURNS_NOTHING = 1 << (31-30), FLAG_RETURNS_FP = 1 << (31-29), - FLAG_RETURNS_64BITS = 1 << (31-28), + FLAG_RETURNS_VEC = 1 << (31-28), - /* This goes in cr6 */ - FLAG_RETURNS_128BITS = 1 << (31-27), + /* These go in cr6 */ + FLAG_RETURNS_64BITS = 1 << (31-27), + FLAG_RETURNS_128BITS = 1 << (31-26), - FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */ + FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */ /* These go in cr1 */ FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */ FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */ FLAG_4_GPR_ARGUMENTS = 1 << (31- 5), - FLAG_RETVAL_REFERENCE = 1 << (31- 4) + FLAG_RETVAL_REFERENCE = 1 << (31- 4), + FLAG_VEC_ARGUMENTS = 1 << (31- 3), }; typedef union @@ -55,6 +57,14 @@ typedef union double d; } ffi_dblfl; +#if defined(__FLOAT128_TYPE__) +typedef _Float128 float128; +#elif defined(__FLOAT128__) +typedef __float128 float128; +#else +typedef __int128 float128; +#endif + void FFI_HIDDEN ffi_closure_SYSV (void); void FFI_HIDDEN ffi_go_closure_sysv (void); void FFI_HIDDEN ffi_call_SYSV(extended_cif *, void (*)(void), void *, @@ -91,4 +101,5 @@ int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_cif *, void (*) (ffi_cif *, void *, void **, void *), void *, void *, - unsigned long *, ffi_dblfl *); + unsigned long *, ffi_dblfl *, + float128 *); diff --git a/src/powerpc/ffitarget.h b/src/powerpc/ffitarget.h index 90aa36b0f..7fb9a9390 100644 --- a/src/powerpc/ffitarget.h +++ b/src/powerpc/ffitarget.h @@ -91,15 +91,19 @@ typedef enum ffi_abi { /* This and following bits can reuse FFI_COMPAT values. */ FFI_LINUX_STRUCT_ALIGN = 1, FFI_LINUX_LONG_DOUBLE_128 = 2, + FFI_LINUX_LONG_DOUBLE_IEEE128 = 4, FFI_DEFAULT_ABI = (FFI_LINUX # ifdef __STRUCT_PARM_ALIGN__ | FFI_LINUX_STRUCT_ALIGN # endif # ifdef __LONG_DOUBLE_128__ | FFI_LINUX_LONG_DOUBLE_128 +# ifdef __LONG_DOUBLE_IEEE128__ + | FFI_LINUX_LONG_DOUBLE_IEEE128 +# endif # endif ), - FFI_LAST_ABI = 12 + FFI_LAST_ABI = 16 # else /* This bit, always set in new code, must not be set in any of the @@ -167,9 +171,11 @@ typedef enum ffi_abi { #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2) /* Used by ELFv2 for homogenous structure returns. */ -#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1) -#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2) -#define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3) +#define FFI_V2_TYPE_VECTOR (FFI_PPC_TYPE_LAST + 1) +#define FFI_V2_TYPE_VECTOR_HOMOG (FFI_PPC_TYPE_LAST + 2) +#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 3) +#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 4) +#define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 5) #if _CALL_ELF == 2 # define FFI_TRAMPOLINE_SIZE 32 diff --git a/src/powerpc/linux64.S b/src/powerpc/linux64.S index b2ae60ead..c99889c1c 100644 --- a/src/powerpc/linux64.S +++ b/src/powerpc/linux64.S @@ -101,40 +101,70 @@ ffi_call_LINUX64: ld %r2, 8(%r29) # endif /* Now do the call. */ - /* Set up cr1 with bits 4-7 of the flags. */ - mtcrf 0x40, %r31 + /* Set up cr1 with bits 3-7 of the flags. */ + mtcrf 0xc0, %r31 /* Get the address to call into CTR. */ mtctr %r12 /* Load all those argument registers. */ - ld %r3, -32-(8*8)(%r28) - ld %r4, -32-(7*8)(%r28) - ld %r5, -32-(6*8)(%r28) - ld %r6, -32-(5*8)(%r28) + addi %r29, %r28, -32-(8*8) + ld %r3, (0*8)(%r29) + ld %r4, (1*8)(%r29) + ld %r5, (2*8)(%r29) + ld %r6, (3*8)(%r29) bf- 5, 1f - ld %r7, -32-(4*8)(%r28) - ld %r8, -32-(3*8)(%r28) - ld %r9, -32-(2*8)(%r28) - ld %r10, -32-(1*8)(%r28) + ld %r7, (4*8)(%r29) + ld %r8, (5*8)(%r29) + ld %r9, (6*8)(%r29) + ld %r10, (7*8)(%r29) 1: /* Load all the FP registers. */ bf- 6, 2f - lfd %f1, -32-(21*8)(%r28) - lfd %f2, -32-(20*8)(%r28) - lfd %f3, -32-(19*8)(%r28) - lfd %f4, -32-(18*8)(%r28) - lfd %f5, -32-(17*8)(%r28) - lfd %f6, -32-(16*8)(%r28) - lfd %f7, -32-(15*8)(%r28) - lfd %f8, -32-(14*8)(%r28) - lfd %f9, -32-(13*8)(%r28) - lfd %f10, -32-(12*8)(%r28) - lfd %f11, -32-(11*8)(%r28) - lfd %f12, -32-(10*8)(%r28) - lfd %f13, -32-(9*8)(%r28) + addi %r29, %r29, -(14*8) + lfd %f1, ( 1*8)(%r29) + lfd %f2, ( 2*8)(%r29) + lfd %f3, ( 3*8)(%r29) + lfd %f4, ( 4*8)(%r29) + lfd %f5, ( 5*8)(%r29) + lfd %f6, ( 6*8)(%r29) + lfd %f7, ( 7*8)(%r29) + lfd %f8, ( 8*8)(%r29) + lfd %f9, ( 9*8)(%r29) + lfd %f10, (10*8)(%r29) + lfd %f11, (11*8)(%r29) + lfd %f12, (12*8)(%r29) + lfd %f13, (13*8)(%r29) 2: + /* Load all the vector registers. */ + bf- 3, 3f + addi %r29, %r29, -16 + lvx %v13, 0, %r29 + addi %r29, %r29, -16 + lvx %v12, 0, %r29 + addi %r29, %r29, -16 + lvx %v11, 0, %r29 + addi %r29, %r29, -16 + lvx %v10, 0, %r29 + addi %r29, %r29, -16 + lvx %v9, 0, %r29 + addi %r29, %r29, -16 + lvx %v8, 0, %r29 + addi %r29, %r29, -16 + lvx %v7, 0, %r29 + addi %r29, %r29, -16 + lvx %v6, 0, %r29 + addi %r29, %r29, -16 + lvx %v5, 0, %r29 + addi %r29, %r29, -16 + lvx %v4, 0, %r29 + addi %r29, %r29, -16 + lvx %v3, 0, %r29 + addi %r29, %r29, -16 + lvx %v2, 0, %r29 +3: + /* Make the call. */ ld %r11, 8(%r28) bctrl @@ -152,6 +182,7 @@ ffi_call_LINUX64: bt 31, .Lstruct_return_value bt 30, .Ldone_return_value bt 29, .Lfp_return_value + bt 28, .Lvec_return_value std %r3, 0(%r30) /* Fall through... */ @@ -167,12 +198,16 @@ ffi_call_LINUX64: ld %r31, -8(%r1) blr +.Lvec_return_value: + stvx %v2, 0, %r30 + b .Ldone_return_value + .Lfp_return_value: .cfi_def_cfa_register 28 - bf 28, .Lfloat_return_value - stfd %f1, 0(%r30) mtcrf 0x02, %r31 /* cr6 */ - bf 27, .Ldone_return_value + bf 27, .Lfloat_return_value + stfd %f1, 0(%r30) + bf 26, .Ldone_return_value stfd %f2, 8(%r30) b .Ldone_return_value .Lfloat_return_value: @@ -180,8 +215,9 @@ ffi_call_LINUX64: b .Ldone_return_value .Lstruct_return_value: - bf 29, .Lsmall_struct - bf 28, .Lfloat_homog_return_value + bf 29, .Lvec_homog_or_small_struct + mtcrf 0x02, %r31 /* cr6 */ + bf 27, .Lfloat_homog_return_value stfd %f1, 0(%r30) stfd %f2, 8(%r30) stfd %f3, 16(%r30) @@ -203,6 +239,25 @@ ffi_call_LINUX64: stfs %f8, 28(%r30) b .Ldone_return_value +.Lvec_homog_or_small_struct: + bf 28, .Lsmall_struct + stvx %v2, 0, %r30 + addi %r30, %r30, 16 + stvx %v3, 0, %r30 + addi %r30, %r30, 16 + stvx %v4, 0, %r30 + addi %r30, %r30, 16 + stvx %v5, 0, %r30 + addi %r30, %r30, 16 + stvx %v6, 0, %r30 + addi %r30, %r30, 16 + stvx %v7, 0, %r30 + addi %r30, %r30, 16 + stvx %v8, 0, %r30 + addi %r30, %r30, 16 + stvx %v9, 0, %r30 + b .Ldone_return_value + .Lsmall_struct: std %r3, 0(%r30) std %r4, 8(%r30) diff --git a/src/powerpc/linux64_closure.S b/src/powerpc/linux64_closure.S index 7f2a214df..d67e4bbbd 100644 --- a/src/powerpc/linux64_closure.S +++ b/src/powerpc/linux64_closure.S @@ -61,9 +61,15 @@ ffi_closure_LINUX64: # endif # if _CALL_ELF == 2 -# 32 byte special reg save area + 64 byte parm save area -# + 64 byte retval area + 13*8 fpr save area + round to 16 -# define STACKFRAME 272 +# ifdef __VEC__ +# 32 byte special reg save area + 64 byte parm save area +# + 128 byte retval area + 13*8 fpr save area + 12*16 vec save area + round to 16 +# define STACKFRAME 528 +# else +# 32 byte special reg save area + 64 byte parm save area +# + 64 byte retval area + 13*8 fpr save area + round to 16 +# define STACKFRAME 272 +# endif # define PARMSAVE 32 # define RETVAL PARMSAVE+64 # else @@ -146,6 +152,35 @@ ffi_closure_LINUX64: # load up the pointer to the saved fpr registers addi %r8, %r1, -104 +# ifdef __VEC__ + # load up the pointer to the saved vector registers + # 8 bytes padding for 16-byte alignment at -112(%r1) + addi %r9, %r8, -24 + stvx %v13, 0, %r9 + addi %r9, %r9, -16 + stvx %v12, 0, %r9 + addi %r9, %r9, -16 + stvx %v11, 0, %r9 + addi %r9, %r9, -16 + stvx %v10, 0, %r9 + addi %r9, %r9, -16 + stvx %v9, 0, %r9 + addi %r9, %r9, -16 + stvx %v8, 0, %r9 + addi %r9, %r9, -16 + stvx %v7, 0, %r9 + addi %r9, %r9, -16 + stvx %v6, 0, %r9 + addi %r9, %r9, -16 + stvx %v5, 0, %r9 + addi %r9, %r9, -16 + stvx %v4, 0, %r9 + addi %r9, %r9, -16 + stvx %v3, 0, %r9 + addi %r9, %r9, -16 + stvx %v2, 0, %r9 +# endif + # load up the pointer to the result storage addi %r6, %r1, -STACKFRAME+RETVAL @@ -313,6 +348,16 @@ ffi_closure_LINUX64: .cfi_def_cfa_offset 0 blr .cfi_def_cfa_offset STACKFRAME +# case FFI_V2_TYPE_VECTOR + addi %r3, %r1, RETVAL + lvx %v2, 0, %r3 + mtlr %r0 + b .Lfinish +# case FFI_V2_TYPE_VECTOR_HOMOG + addi %r3, %r1, RETVAL + lvx %v2, 0, %r3 + addi %r3, %r3, 16 + b .Lmorevector # case FFI_V2_TYPE_FLOAT_HOMOG lfs %f1, RETVAL+0(%r1) lfs %f2, RETVAL+4(%r1) @@ -332,6 +377,25 @@ ffi_closure_LINUX64: .cfi_def_cfa_offset 0 blr .cfi_def_cfa_offset STACKFRAME +.Lmorevector: + lvx %v3, 0, %r3 + addi %r3, %r3, 16 + lvx %v4, 0, %r3 + addi %r3, %r3, 16 + lvx %v5, 0, %r3 + mtlr %r0 + addi %r3, %r3, 16 + lvx %v6, 0, %r3 + addi %r3, %r3, 16 + lvx %v7, 0, %r3 + addi %r3, %r3, 16 + lvx %v8, 0, %r3 + addi %r3, %r3, 16 + lvx %v9, 0, %r3 + addi %r1, %r1, STACKFRAME + .cfi_def_cfa_offset 0 + blr + .cfi_def_cfa_offset STACKFRAME .Lmorefloat: lfs %f4, RETVAL+12(%r1) mtlr %r0 From b6804d16453890b78844b1b3c1acf16af98cadb8 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 17 Nov 2019 09:19:14 -0500 Subject: [PATCH 065/231] Mention binary128 long double support for Power --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3d89f7beb..177649d73 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.3-rc2 was released on November 2, 2019. Check the libffi web +libffi-3.3-rc3 was released on November 9, 2019. Check the libffi web page for updates: . @@ -200,11 +200,13 @@ See the git log for details at http://github.com/libffi/libffi. 3.3 TBD Add RISC-V support. New API in support of GO closures. + Add IEEE754 binary128 long double support for 64-bit Power Default to Microsoft's 64 bit long double ABI with Visual C++. GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI. + Add Windows on ARM64 (WOA) support. + Add Windows 32-bit ARM support. + Raw java (gcj) API deprecated. Many new tests cases and bug fixes. - Add windows on arm64 (WOA) support. - Add Windows 32-bit arm support. 3.2.1 Nov-12-14 Build fix for non-iOS AArch64 targets. From d087b595637ebb795c0cec1ff0c4409befb486b7 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 06:34:42 -0500 Subject: [PATCH 066/231] Build/test for m32r-elf and bfin-elf --- .travis.yml | 3 ++ .travis/bfin-sim.exp | 58 +++++++++++++++++++++++++++++ .travis/build-cross-in-container.sh | 10 +++++ .travis/build.sh | 18 +++++++++ .travis/m32r-sim.exp | 58 +++++++++++++++++++++++++++++ .travis/site.exp | 8 +++- 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 .travis/bfin-sim.exp create mode 100755 .travis/build-cross-in-container.sh create mode 100644 .travis/m32r-sim.exp diff --git a/.travis.yml b/.travis.yml index 175265178..5925eac6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,9 @@ language: cpp matrix: include: + - os: linux + env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="$TRAVIS_BUI - os: linux + env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" # This configuration is still using the native x86 toolchain? # - os: osx # env: HOST=aarch64-apple-darwin13 diff --git a/.travis/bfin-sim.exp b/.travis/bfin-sim.exp new file mode 100644 index 000000000..13cd0ff8e --- /dev/null +++ b/.travis/bfin-sim.exp @@ -0,0 +1,58 @@ +# Copyright (C) 2010, 2019 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This is a list of toolchains that are supported on this board. +set_board_info target_install {bfin-elf} + +# Load the generic configuration for this board. This will define a basic set +# of routines needed by the tool to communicate with the board. +load_generic_config "sim" + +# basic-sim.exp is a basic description for the standard Cygnus simulator. +load_base_board_description "basic-sim" + +# "bfin" is the name of the sim subdir in devo/sim. +setup_sim bfin + +# No multilib options needed by default. +process_multilib_options "" + +# We only support newlib on this target. We assume that all multilib +# options have been specified before we get here. + +set_board_info compiler "[find_gcc]" +set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]" +set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]" + +# Configuration settings for testsuites +set_board_info noargs 1 +set_board_info gdb,nosignals 1 +set_board_info gdb,noresults 1 +set_board_info gdb,cannot_call_functions 1 +set_board_info gdb,skip_float_tests 1 +set_board_info gdb,can_reverse 1 +set_board_info gdb,use_precord 1 + +# More time is needed +set_board_info gcc,timeout 800 +set_board_info gdb,timeout 60 + +# Used by a few gcc.c-torture testcases to delimit how large the stack can +# be. +set_board_info gcc,stack_size 5000 + diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh new file mode 100755 index 000000000..195330b50 --- /dev/null +++ b/.travis/build-cross-in-container.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cd /opt + +./configure --host=${HOST} +make +make dist +make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true + + diff --git a/.travis/build.sh b/.travis/build.sh index ab334e5ea..3cb356bd1 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -68,6 +68,16 @@ function build_cross_linux() exit $? } +function build_cross() +{ + ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/libffi-ci-${HOST}:latest bash -c /opt/.travis/build-cross-in-container.sh + + ./rlgl l https://rl.gl + ID=$(./rlgl start) + ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log + exit $? +} + function build_ios() { which python @@ -104,6 +114,14 @@ case "$HOST" in aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; + bfin-elf ) + ./autogen.sh + GCC_OPTIONS=-msim build_cross + ;; + m32r-elf ) + ./autogen.sh + build_cross + ;; m68k-linux-gnu ) ./autogen.sh GCC_OPTIONS=-mcpu=547x build_cross_linux diff --git a/.travis/m32r-sim.exp b/.travis/m32r-sim.exp new file mode 100644 index 000000000..b3341f223 --- /dev/null +++ b/.travis/m32r-sim.exp @@ -0,0 +1,58 @@ +# Copyright (C) 2010, 2019 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This is a list of toolchains that are supported on this board. +set_board_info target_install {m32r-elf} + +# Load the generic configuration for this board. This will define a basic set +# of routines needed by the tool to communicate with the board. +load_generic_config "sim" + +# basic-sim.exp is a basic description for the standard Cygnus simulator. +load_base_board_description "basic-sim" + +# "m32r" is the name of the sim subdir in devo/sim. +setup_sim m32r + +# No multilib options needed by default. +process_multilib_options "" + +# We only support newlib on this target. We assume that all multilib +# options have been specified before we get here. + +set_board_info compiler "[find_gcc]" +set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]" +set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]" + +# Configuration settings for testsuites +set_board_info noargs 1 +set_board_info gdb,nosignals 1 +set_board_info gdb,noresults 1 +set_board_info gdb,cannot_call_functions 1 +set_board_info gdb,skip_float_tests 1 +set_board_info gdb,can_reverse 1 +set_board_info gdb,use_precord 1 + +# More time is needed +set_board_info gcc,timeout 800 +set_board_info gdb,timeout 60 + +# Used by a few gcc.c-torture testcases to delimit how large the stack can +# be. +set_board_info gcc,stack_size 5000 + diff --git a/.travis/site.exp b/.travis/site.exp index e42cb1d09..8bfbc7556 100644 --- a/.travis/site.exp +++ b/.travis/site.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008, 2010, 2018 Anthony Green +# Copyright (C) 2008, 2010, 2018, 2019 Anthony Green # Make sure we look in the right place for the board description files. if ![info exists boards_dir] { @@ -11,6 +11,12 @@ verbose "Global Config File: target_triplet is $target_triplet" 2 global target_list case "$target_triplet" in { + { "bfin-elf" } { + set target_list "bfin-sim" + } + { "m32r-elf" } { + set target_list "m32r-sim" + } { "moxie-elf" } { set target_list "moxie-sim" } From c88f4d2677d4dc6659a1aa6418e636f8fcf9bd9b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 12:25:51 -0500 Subject: [PATCH 067/231] Fix typo for m32r and bfin builds --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5925eac6f..414ba309d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,8 @@ language: cpp matrix: include: - os: linux - env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="$TRAVIS_BUI - os: linux + env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" + - os: linux env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" # This configuration is still using the native x86 toolchain? # - os: osx From 97e3b1fe1a0fbdb43bf28fe6198cb26eaa719c93 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 13:02:44 -0500 Subject: [PATCH 068/231] Add test support for or1k. Fix yaml typo. --- .travis.yml | 4 ++- .travis/or1k-sim.exp | 58 ++++++++++++++++++++++++++++++++++++++++++++ .travis/site.exp | 3 +++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .travis/or1k-sim.exp diff --git a/.travis.yml b/.travis.yml index 414ba309d..fda2f0f4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,11 @@ language: cpp matrix: include: + - os: linux + env: HOST=or1k-elf RUNTESTFLAGS="--target_board or1k-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - os: linux env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - - os: linux + - os: linux env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" # This configuration is still using the native x86 toolchain? # - os: osx diff --git a/.travis/or1k-sim.exp b/.travis/or1k-sim.exp new file mode 100644 index 000000000..64e1444fe --- /dev/null +++ b/.travis/or1k-sim.exp @@ -0,0 +1,58 @@ +# Copyright (C) 2010, 2019 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This is a list of toolchains that are supported on this board. +set_board_info target_install {or1k-elf} + +# Load the generic configuration for this board. This will define a basic set +# of routines needed by the tool to communicate with the board. +load_generic_config "sim" + +# basic-sim.exp is a basic description for the standard Cygnus simulator. +load_base_board_description "basic-sim" + +# "or1k" is the name of the sim subdir in devo/sim. +setup_sim or1k + +# No multilib options needed by default. +process_multilib_options "" + +# We only support newlib on this target. We assume that all multilib +# options have been specified before we get here. + +set_board_info compiler "[find_gcc]" +set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]" +set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]" + +# Configuration settings for testsuites +set_board_info noargs 1 +set_board_info gdb,nosignals 1 +set_board_info gdb,noresults 1 +set_board_info gdb,cannot_call_functions 1 +set_board_info gdb,skip_float_tests 1 +set_board_info gdb,can_reverse 1 +set_board_info gdb,use_precord 1 + +# More time is needed +set_board_info gcc,timeout 800 +set_board_info gdb,timeout 60 + +# Used by a few gcc.c-torture testcases to delimit how large the stack can +# be. +set_board_info gcc,stack_size 5000 + diff --git a/.travis/site.exp b/.travis/site.exp index 8bfbc7556..644ec6318 100644 --- a/.travis/site.exp +++ b/.travis/site.exp @@ -20,5 +20,8 @@ case "$target_triplet" in { { "moxie-elf" } { set target_list "moxie-sim" } + { "or1k-elf" } { + set target_list "or1k-sim" + } } From bbea6394f9f27de68aac037abb264151d6de9f64 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 13:06:26 -0500 Subject: [PATCH 069/231] Capture more or1k hosts --- configure.host | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.host b/configure.host index 6762eba0e..d9850d450 100644 --- a/configure.host +++ b/configure.host @@ -178,7 +178,7 @@ case "${host}" in SOURCES="ffi.c sysv.S" ;; - or1k*-linux*) + or1k*-*-*) TARGET=OR1K; TARGETDIR=or1k SOURCES="ffi.c sysv.S" ;; From 581048f91e9e25e3b17a2906edd8840f35999918 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 13:17:27 -0500 Subject: [PATCH 070/231] Be specific when building CI container images --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 3cb356bd1..46f08ec01 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -70,7 +70,7 @@ function build_cross_linux() function build_cross() { - ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/libffi-ci-${HOST}:latest bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" docker.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) From 8c9cf44cb2a2d46ddcb148508fb5350438b4a62b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 13:47:42 -0500 Subject: [PATCH 071/231] Set path to simulator. Add debugging output. --- .travis/build-cross-in-container.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh index 195330b50..a7f672e6c 100755 --- a/.travis/build-cross-in-container.sh +++ b/.travis/build-cross-in-container.sh @@ -2,6 +2,11 @@ cd /opt +set -x +echo $PATH +export PATH=/usr/local/bin:$PATH +echo $PATH + ./configure --host=${HOST} make make dist From a8223271a3d7ff1e8a1553c2a5ed9b4e1a24a774 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 13:59:10 -0500 Subject: [PATCH 072/231] More cross build debugging --- .travis/build-cross-in-container.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh index a7f672e6c..68d92bda0 100755 --- a/.travis/build-cross-in-container.sh +++ b/.travis/build-cross-in-container.sh @@ -7,9 +7,11 @@ echo $PATH export PATH=/usr/local/bin:$PATH echo $PATH +ls -l /usr/local/bin + ./configure --host=${HOST} make make dist -make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true +make check RUNTESTFLAGS="-v -v -v -v -a $RUNTESTFLAGS" || true From dfa60e5eb44482d45b8c79b815e6b6789e62ce18 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 14:02:33 -0500 Subject: [PATCH 073/231] Fix cross builds for or1k --- .travis/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index 46f08ec01..72fa11ef0 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -122,6 +122,10 @@ case "$HOST" in ./autogen.sh build_cross ;; + or1k-elf ) + ./autogen.sh + build_cross + ;; m68k-linux-gnu ) ./autogen.sh GCC_OPTIONS=-mcpu=547x build_cross_linux From 14bfbec0fd312001f7922ee6100cbc3155ae585b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 14:40:30 -0500 Subject: [PATCH 074/231] Pull before running --- .travis/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 72fa11ef0..942f7afa6 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -70,7 +70,8 @@ function build_cross_linux() function build_cross() { - ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" docker.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} + ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) From 9a394c24951f3fc5cfbd0ff268278a7b45afc77e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 14:45:29 -0500 Subject: [PATCH 075/231] Remove verbosity --- .travis/build-cross-in-container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh index 68d92bda0..11447dbc5 100755 --- a/.travis/build-cross-in-container.sh +++ b/.travis/build-cross-in-container.sh @@ -12,6 +12,6 @@ ls -l /usr/local/bin ./configure --host=${HOST} make make dist -make check RUNTESTFLAGS="-v -v -v -v -a $RUNTESTFLAGS" || true +make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true From da1358816e7b02e6f8431e4df336d0934bcabd4c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 14:54:14 -0500 Subject: [PATCH 076/231] Set vars --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 942f7afa6..681d117f0 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -71,7 +71,7 @@ function build_cross_linux() function build_cross() { ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} - ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) From 27d31130cabfe82683fc0e3e82247fd522f45607 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 15:06:51 -0500 Subject: [PATCH 077/231] Fix DEJAGNU variable --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fda2f0f4b..7cd3a186a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,11 @@ language: cpp matrix: include: - os: linux - env: HOST=or1k-elf RUNTESTFLAGS="--target_board or1k-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" + env: HOST=or1k-elf RUNTESTFLAGS="--target_board or1k-sim" DEJAGNU="/opt/.travis/site.exp" - os: linux - env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" + env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="/opt/.travis/site.exp" - os: linux - env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" + env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="/opt/.travis/site.exp" # This configuration is still using the native x86 toolchain? # - os: osx # env: HOST=aarch64-apple-darwin13 From 6f734f8a5ff13d106f81741c11c7cb2551706c7f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 15:13:16 -0500 Subject: [PATCH 078/231] Adapt for new old ChangeLog file --- Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index ea3d3832d..d1381fd26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,8 +14,7 @@ if BUILD_DOCS SUBDIRS += doc endif -EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ - ChangeLog.libffi ChangeLog.libffi-3.1 \ +EXTRA_DIST = LICENSE ChangeLog.old \ m4/libtool.m4 m4/lt~obsolete.m4 \ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ m4/ltversion.m4 src/debug.c msvcc.sh \ From 54fc80dfd8d608ec718cade762c358b8fd819f38 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 18 Nov 2019 15:20:00 -0500 Subject: [PATCH 079/231] Fake TRAVIS_BUILD_DIR --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 681d117f0..db596b3d9 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -71,7 +71,7 @@ function build_cross_linux() function build_cross() { ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} - ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) From 262cf74fd4003a928ca73e96ef8698546e535c46 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 19 Nov 2019 10:06:57 -0500 Subject: [PATCH 080/231] No c++ for or1k-elf --- testsuite/libffi.call/unwindtest_ffi_call.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/unwindtest_ffi_call.cc b/testsuite/libffi.call/unwindtest_ffi_call.cc index 153d24094..1c7f39ba9 100644 --- a/testsuite/libffi.call/unwindtest_ffi_call.cc +++ b/testsuite/libffi.call/unwindtest_ffi_call.cc @@ -4,7 +4,7 @@ PR: none. Originator: Andreas Tobler 20061213 */ -/* { dg-do run { xfail moxie*-*-* } } */ +/* { dg-do run { xfail moxie*-*-* or1k-*-* } } */ #include "ffitest.h" From 497018686d4df0012ea7bf1a4ab41b918b5e65bc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 19 Nov 2019 10:07:16 -0500 Subject: [PATCH 081/231] Disable type warnings for or1k. --- testsuite/libffi.call/huge_struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/huge_struct.c b/testsuite/libffi.call/huge_struct.c index 187c42cc3..1915c3f1e 100644 --- a/testsuite/libffi.call/huge_struct.c +++ b/testsuite/libffi.call/huge_struct.c @@ -7,7 +7,7 @@ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ -/* { dg-options -Wformat=0 { target moxie*-*-elf } } */ +/* { dg-options -Wformat=0 { target moxie*-*-elf or1k-*-* } } */ #include "ffitest.h" From d6e4f96b482690e6cdaf67a70bb33d1bfe0acd15 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 19 Nov 2019 13:36:49 -0500 Subject: [PATCH 082/231] No C++ for or1k --- testsuite/libffi.call/unwindtest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/unwindtest.cc b/testsuite/libffi.call/unwindtest.cc index e1145657d..69ebe9d00 100644 --- a/testsuite/libffi.call/unwindtest.cc +++ b/testsuite/libffi.call/unwindtest.cc @@ -4,7 +4,7 @@ PR: none. Originator: Jeff Sturm */ -/* { dg-do run { xfail x86_64-apple-darwin* moxie*-*-* } } */ +/* { dg-do run { xfail x86_64-apple-darwin* moxie*-*-* or1k-*-* } } */ #include "ffitest.h" From bd3a4687c0743076f420dee2a02075fd64fa547e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 19 Nov 2019 17:14:23 -0500 Subject: [PATCH 083/231] No C++ for or1k-unknown-elf --- testsuite/libffi.call/unwindtest_ffi_call.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/unwindtest_ffi_call.cc b/testsuite/libffi.call/unwindtest_ffi_call.cc index 1c7f39ba9..65296f1ee 100644 --- a/testsuite/libffi.call/unwindtest_ffi_call.cc +++ b/testsuite/libffi.call/unwindtest_ffi_call.cc @@ -4,7 +4,7 @@ PR: none. Originator: Andreas Tobler 20061213 */ -/* { dg-do run { xfail moxie*-*-* or1k-*-* } } */ +/* { dg-do run { xfail moxie*-*-* or1k-unknown-elf } } */ #include "ffitest.h" From 31543c799a224ef446cef19a2372b054ecad3822 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 20 Nov 2019 06:15:55 -0500 Subject: [PATCH 084/231] Add work-around for users who manage their own closure memory As suggested by DJ --- src/closures.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/closures.c b/src/closures.c index 86e74c282..512002165 100644 --- a/src/closures.c +++ b/src/closures.c @@ -1,5 +1,6 @@ /* ----------------------------------------------------------------------- - closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc. + closures.c - Copyright (c) 2019 Anthony Green + Copyright (c) 2007, 2009, 2010 Red Hat, Inc. Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc Copyright (c) 2011 Plausible Labs Cooperative, Inc. @@ -936,7 +937,14 @@ void * ffi_data_to_code_pointer (void *data) { msegmentptr seg = segment_holding (gm, data); - return add_segment_exec_offset (data, seg); + /* We expect closures to be allocated with ffi_closure_alloc(), in + which case seg will be non-NULL. However, some users take on the + burden of managing this memory themselves, in which case this + we'll just return data. */ + if (seg) + return add_segment_exec_offset (data, seg); + else + return data; } /* Release a chunk of memory allocated with ffi_closure_alloc. If From 91a7fbe94e3884536cf2eb8e644bc79d6b19c80e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 20 Nov 2019 07:16:41 -0500 Subject: [PATCH 085/231] Fix or1k lack-of-g++ checking in testsuite --- testsuite/libffi.call/call.exp | 13 ++++++++++++- testsuite/libffi.call/unwindtest.cc | 2 +- testsuite/libffi.call/unwindtest_ffi_call.cc | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index ab4741526..13ba2bdcd 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -32,10 +32,21 @@ if { [string match $compiler_vendor "microsoft"] } { set additional_options ""; } -set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.c]] run-many-tests $tlist $additional_options +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.cc]] + +# No C++ for or1k +if { [istarget "or1k-*-*"] } { + foreach test $tlist { + unsupported "$test" + } +} else { + run-many-tests $tlist $additional_options +} + dg-finish # Local Variables: diff --git a/testsuite/libffi.call/unwindtest.cc b/testsuite/libffi.call/unwindtest.cc index 69ebe9d00..e1145657d 100644 --- a/testsuite/libffi.call/unwindtest.cc +++ b/testsuite/libffi.call/unwindtest.cc @@ -4,7 +4,7 @@ PR: none. Originator: Jeff Sturm */ -/* { dg-do run { xfail x86_64-apple-darwin* moxie*-*-* or1k-*-* } } */ +/* { dg-do run { xfail x86_64-apple-darwin* moxie*-*-* } } */ #include "ffitest.h" diff --git a/testsuite/libffi.call/unwindtest_ffi_call.cc b/testsuite/libffi.call/unwindtest_ffi_call.cc index 65296f1ee..153d24094 100644 --- a/testsuite/libffi.call/unwindtest_ffi_call.cc +++ b/testsuite/libffi.call/unwindtest_ffi_call.cc @@ -4,7 +4,7 @@ PR: none. Originator: Andreas Tobler 20061213 */ -/* { dg-do run { xfail moxie*-*-* or1k-unknown-elf } } */ +/* { dg-do run { xfail moxie*-*-* } } */ #include "ffitest.h" From 34a3a661b80c0fa7817c0654ae9fd0686d3b8cd2 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 21 Nov 2019 04:59:39 -0500 Subject: [PATCH 086/231] Fix formatting of README. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 177649d73..b12913eb9 100644 --- a/README.md +++ b/README.md @@ -200,12 +200,12 @@ See the git log for details at http://github.com/libffi/libffi. 3.3 TBD Add RISC-V support. New API in support of GO closures. - Add IEEE754 binary128 long double support for 64-bit Power + Add IEEE754 binary128 long double support for 64-bit Power Default to Microsoft's 64 bit long double ABI with Visual C++. GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI. Add Windows on ARM64 (WOA) support. Add Windows 32-bit ARM support. - Raw java (gcj) API deprecated. + Raw java (gcj) API deprecated. Many new tests cases and bug fixes. 3.2.1 Nov-12-14 From 970b7fce4f804df57ec582a0220c22eaeccc239a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 21 Nov 2019 05:04:54 -0500 Subject: [PATCH 087/231] Update autoconf-archive m4 macros --- m4/ax_append_flag.m4 | 31 +++++-------------------------- m4/ax_check_compile_flag.m4 | 31 +++++-------------------------- m4/ax_compiler_vendor.m4 | 3 ++- m4/ax_configure_args.m4 | 31 +++++-------------------------- m4/ax_gcc_archflag.m4 | 10 +++++++--- 5 files changed, 24 insertions(+), 82 deletions(-) diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 index e8c5312af..dd6d8b614 100644 --- a/m4/ax_append_flag.m4 +++ b/m4/ax_append_flag.m4 @@ -23,33 +23,12 @@ # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2011 Maarten Bosmans # -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. -#serial 7 +#serial 8 AC_DEFUN([AX_APPEND_FLAG], [dnl diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 index dcabb92a1..bd753b34d 100644 --- a/m4/ax_check_compile_flag.m4 +++ b/m4/ax_check_compile_flag.m4 @@ -29,33 +29,12 @@ # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2011 Maarten Bosmans # -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. -#serial 5 +#serial 6 AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4 index 4ca808955..73efdb005 100644 --- a/m4/ax_compiler_vendor.m4 +++ b/m4/ax_compiler_vendor.m4 @@ -44,7 +44,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 16 +#serial 17 AC_DEFUN([AX_COMPILER_VENDOR], [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, @@ -56,6 +56,7 @@ AC_DEFUN([AX_COMPILER_VENDOR], clang: __clang__ cray: _CRAYC fujitsu: __FUJITSU + sdcc: SDCC, __SDCC gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC diff --git a/m4/ax_configure_args.m4 b/m4/ax_configure_args.m4 index 95f9f6411..9237efea7 100644 --- a/m4/ax_configure_args.m4 +++ b/m4/ax_configure_args.m4 @@ -31,33 +31,12 @@ # # Copyright (c) 2008 Guido U. Draheim # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. -#serial 13 +#serial 14 AC_DEFUN([AX_CONFIGURE_ARGS],[ # [$]@ is unusable in 2.60+ but earlier autoconf had no ac_configure_args diff --git a/m4/ax_gcc_archflag.m4 b/m4/ax_gcc_archflag.m4 index d4a37f8ab..c52b9b296 100644 --- a/m4/ax_gcc_archflag.m4 +++ b/m4/ax_gcc_archflag.m4 @@ -37,7 +37,7 @@ # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # Copyright (c) 2014 Tsukasa Oi -# Copyright (c) 2017 Alexey Kopytov +# Copyright (c) 2017-2018 Alexey Kopytov # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -65,7 +65,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 20 +#serial 22 AC_DEFUN([AX_GCC_ARCHFLAG], [AC_REQUIRE([AC_PROG_CC]) @@ -108,7 +108,7 @@ case $host_cpu in *2?6[[ad]]?:*:*:*) ax_gcc_arch="sandybridge corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; *3?6[[ae]]?:*:*:*) ax_gcc_arch="ivybridge core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; *3?6[[cf]]?:*:*:*|*4?6[[56]]?:*:*:*) ax_gcc_arch="haswell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; - *3?6d?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; + *3?6d?:*:*:*|*4?6[[7f]]?:*:*:*|*5?66?:*:*:*) ax_gcc_arch="broadwell core-avx2 core-avx-i corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;; *1?6c?:*:*:*|*2?6[[67]]?:*:*:*|*3?6[[56]]?:*:*:*) ax_gcc_arch="bonnell atom core2 pentium-m pentium3 pentiumpro" ;; *3?67?:*:*:*|*[[45]]?6[[ad]]?:*:*:*) ax_gcc_arch="silvermont atom core2 pentium-m pentium3 pentiumpro" ;; *000?f[[012]]?:*:*:*|?f[[012]]?:*:*:*|f[[012]]?:*:*:*) ax_gcc_arch="pentium4 pentiumpro" ;; @@ -198,6 +198,10 @@ case $host_cpu in *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";; *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";; 603ev|8240) ax_gcc_arch="$cputype 603e 603";; + *POWER7*) ax_gcc_arch="power7";; + *POWER8*) ax_gcc_arch="power8";; + *POWER9*) ax_gcc_arch="power9";; + *POWER10*) ax_gcc_arch="power10";; *) ax_gcc_arch=$cputype ;; esac ax_gcc_arch="$ax_gcc_arch powerpc" From d01088a5194ff1a2250e7dbee04a9a167b582db7 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 21 Nov 2019 05:36:06 -0500 Subject: [PATCH 088/231] Mention more major port contributors --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b12913eb9..a8f2b04fd 100644 --- a/README.md +++ b/README.md @@ -423,7 +423,9 @@ developers: aarch64 Marcus Shawcroft, James Greenhalgh alpha Richard Henderson + arc Hackers at Synopsis arm Raffaele Sena + avr32 Bradley Smith blackfin Alexandre Keunecke I. de Mendonca cris Simon Posnjak, Hans-Peter Nilsson frv Anthony Green @@ -431,6 +433,7 @@ developers: m32r Kazuhiro Inaoka m68k Andreas Schwab m88k Miod Vallat + metag Hackers at Imagination Technologies microblaze Nathan Rossi mips Anthony Green, Casey Marshall mips64 David Daney @@ -441,6 +444,7 @@ developers: powerpc Geoffrey Keating, Andreas Tobler, David Edelsohn, John Hornkvist powerpc64 Jakub Jelinek + riscv Michael Knyszek, Andrew Waterman, Stef O'Rear s390 Gerhard Tonn, Ulrich Weigand sh Kaz Kojima sh64 Kaz Kojima From 8e3935fa761d3e6f19ccf5e6733fd40dee637d94 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 22 Nov 2019 12:42:26 -0500 Subject: [PATCH 089/231] Manual clean-ups, and include the PDF in the source distribution. --- Makefile.am | 4 +++- doc/libffi.texi | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Makefile.am b/Makefile.am index d1381fd26..4fd6193d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ EXTRA_DIST = LICENSE ChangeLog.old \ generate-darwin-source-and-headers.py \ libffi.xcodeproj/project.pbxproj \ libtool-ldflags libtool-version configure.host README.md \ - libffi.map.in LICENSE-BUILDTOOLS msvc_build make_sunver.pl + libffi.map.in LICENSE-BUILDTOOLS msvc_build make_sunver.pl # local.exp is generated by configure DISTCLEANFILES = local.exp @@ -153,5 +153,7 @@ AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) dist-hook: + d=`(cd $(distdir); pwd)`; (cd doc; make pdf; cp *.pdf $$d/doc) if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog s=`awk '/was released on/{ print NR; exit}' $(top_srcdir)/README.md`; tail -n +$$(($$s-1)) $(top_srcdir)/README.md > $(distdir)/README.md + diff --git a/doc/libffi.texi b/doc/libffi.texi index 8cfa1c0f4..bd305936c 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -1,7 +1,8 @@ \input texinfo @c -*-texinfo-*- @c %**start of header @setfilename libffi.info -@settitle libffi +@include version.texi +@settitle libffi: the portable foreign function interface library @setchapternewpage off @c %**end of header @@ -12,32 +13,43 @@ @syncodeindex pg cp @syncodeindex tp cp -@include version.texi - @copying -This manual is for Libffi, a portable foreign-function interface +This manual is for libffi, a portable foreign function interface library. -Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc. +Copyright @copyright{} 2008--2019 Anthony Green and Red Hat, Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +``Software''), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -@quotation -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. A copy of the license is included in the -section entitled ``GNU General Public License''. +THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -@end quotation @end copying @dircategory Development @direntry -* libffi: (libffi). Portable foreign-function interface library. +* libffi: (libffi). Portable foreign function interface library. @end direntry @titlepage -@title Libffi +@title libffi: a foreign function interface library +@subtitle For Version @value{VERSION} of libffi +@author Anthony Green @page @vskip 0pt plus 1filll @insertcopying From 247a5e7878379b7af33338d51898d7fb9e82e686 Mon Sep 17 00:00:00 2001 From: Michael Haubenwallner Date: Fri, 22 Nov 2019 20:17:58 +0100 Subject: [PATCH 090/231] Capture x86-windows host like x86_64-windows (#529) --- configure.host | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.host b/configure.host index d9850d450..9a72cda87 100644 --- a/configure.host +++ b/configure.host @@ -74,7 +74,7 @@ case "${host}" in TARGET=X86_FREEBSD; TARGETDIR=x86 ;; - i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix* \ + i?86-*-cygwin* | i?86-*-mingw* | i?86-*-win* | i?86-*-os2* | i?86-*-interix* \ | x86_64-*-cygwin* | x86_64-*-mingw* | x86_64-*-win* ) TARGETDIR=x86 if test $ac_cv_sizeof_size_t = 4; then From 1761a10645dadc0840bf1ff3a4998f9a342e8cad Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 22 Nov 2019 18:53:09 -0500 Subject: [PATCH 091/231] Remove gccbug detection. GCC is good now. --- testsuite/lib/libffi.exp | 19 +------------------ testsuite/libffi.bhaible/bhaible.exp | 1 - testsuite/libffi.bhaible/test-call.c | 2 -- testsuite/libffi.bhaible/test-callback.c | 2 -- 4 files changed, 1 insertion(+), 23 deletions(-) diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index a24405139..c02adf953 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -24,11 +24,6 @@ load_lib libgloss.exp load_gcc_lib target-libpath.exp load_gcc_lib wrapper.exp -proc check_effective_target_gccbug { } { - global has_gccbug - return $has_gccbug -} - # Return 1 if the target matches the effective target 'arg', 0 otherwise. # This can be used with any check_* proc that takes no argument and # returns only 1 or 0. It could be used with check_* procs that take @@ -482,7 +477,6 @@ proc libffi-dg-runtest { testcases default-extra-flags } { proc run-many-tests { testcases extra_flags } { global compiler_vendor - global has_gccbug global env switch $compiler_vendor { "clang" { @@ -498,7 +492,7 @@ proc run-many-tests { testcases extra_flags } { if [info exists env(LIBFFI_TEST_OPTIMIZATION)] { set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ] } else { - set optimizations { "-O0" "-O2" "-O2 -fomit-frame-pointer" } + set optimizations { "-O0" "-O2" } } } default { @@ -544,17 +538,6 @@ proc run-many-tests { testcases extra_flags } { foreach opt $optimizations { foreach abi $abis { set options [concat $common $opt $abi] - set has_gccbug false; - if { [string match $compiler_vendor "gnu"] \ - && [string match "*MSABI*" $abi] \ - && ( ( [string match "*DGTEST=57 *" $common] \ - && [string match "*call.c*" $testname] ) \ - || ( [string match "*DGTEST=54 *" $common] \ - && [string match "*callback*" $testname] ) \ - || [string match "*DGTEST=55 *" $common] \ - || [string match "*DGTEST=56 *" $common] ) } then { - set has_gccbug true; - } verbose "Testing $testname, $options" 1 dg-test $test $options "" } diff --git a/testsuite/libffi.bhaible/bhaible.exp b/testsuite/libffi.bhaible/bhaible.exp index 4e5051b09..3522bd4f0 100644 --- a/testsuite/libffi.bhaible/bhaible.exp +++ b/testsuite/libffi.bhaible/bhaible.exp @@ -19,7 +19,6 @@ libffi-init global srcdir subdir global compiler_vendor -global has_gccbug # The conversion of this testsuite into a dejagnu compatible testsuite # was done in a pretty lazy fashion, and requires the use of compiler diff --git a/testsuite/libffi.bhaible/test-call.c b/testsuite/libffi.bhaible/test-call.c index caa77deb2..251a97382 100644 --- a/testsuite/libffi.bhaible/test-call.c +++ b/testsuite/libffi.bhaible/test-call.c @@ -16,8 +16,6 @@ along with this program. If not, see . **/ -/* { dg-do run { xfail gccbug } }*/ - #include #include #include diff --git a/testsuite/libffi.bhaible/test-callback.c b/testsuite/libffi.bhaible/test-callback.c index 67a8145e1..64f3a0149 100644 --- a/testsuite/libffi.bhaible/test-callback.c +++ b/testsuite/libffi.bhaible/test-callback.c @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -/* { dg-do run { xfail gccbug } }*/ - #include #include #include From 332a539e88d26a0524c10a39283a3099d071ca10 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 22 Nov 2019 18:54:30 -0500 Subject: [PATCH 092/231] Move closure tests so we can easily XFAIL them for some targets --- testsuite/libffi.closures/closure.exp | 50 +++++++ .../closure_fn0.c | 0 .../closure_fn1.c | 0 .../closure_fn2.c | 0 .../closure_fn3.c | 0 .../closure_fn4.c | 0 .../closure_fn5.c | 0 .../closure_fn6.c | 0 .../closure_loc_fn0.c | 0 .../closure_simple.c | 0 .../cls_12byte.c | 0 .../cls_16byte.c | 0 .../cls_18byte.c | 0 .../cls_19byte.c | 0 .../cls_1_1byte.c | 0 .../cls_20byte.c | 0 .../cls_20byte1.c | 0 .../cls_24byte.c | 0 .../cls_2byte.c | 0 .../cls_3_1byte.c | 0 .../cls_3byte1.c | 0 .../cls_3byte2.c | 0 .../cls_3float.c | 0 .../cls_4_1byte.c | 0 .../cls_4byte.c | 0 .../cls_5_1_byte.c | 0 .../cls_5byte.c | 0 .../cls_64byte.c | 0 .../cls_6_1_byte.c | 0 .../cls_6byte.c | 0 .../cls_7_1_byte.c | 0 .../cls_7byte.c | 0 .../cls_8byte.c | 0 .../cls_9byte1.c | 0 .../cls_9byte2.c | 0 .../cls_align_double.c | 0 .../cls_align_float.c | 0 .../cls_align_longdouble.c | 0 .../cls_align_longdouble_split.c | 0 .../cls_align_longdouble_split2.c | 0 .../cls_align_pointer.c | 0 .../cls_align_sint16.c | 0 .../cls_align_sint32.c | 0 .../cls_align_sint64.c | 0 .../cls_align_uint16.c | 0 .../cls_align_uint32.c | 0 .../cls_align_uint64.c | 0 .../cls_dbls_struct.c | 0 .../cls_double.c | 0 .../cls_double_va.c | 0 .../cls_float.c | 0 .../cls_longdouble.c | 0 .../cls_longdouble_va.c | 0 .../cls_many_mixed_args.c | 0 .../cls_many_mixed_float_double.c | 0 .../cls_multi_schar.c | 0 .../cls_multi_sshort.c | 0 .../cls_multi_sshortchar.c | 0 .../cls_multi_uchar.c | 0 .../cls_multi_ushort.c | 0 .../cls_multi_ushortchar.c | 0 .../cls_pointer.c | 0 .../cls_pointer_stack.c | 0 .../cls_schar.c | 0 .../cls_sint.c | 0 .../cls_sshort.c | 0 .../cls_struct_va1.c | 0 .../cls_uchar.c | 0 .../cls_uchar_va.c | 0 .../cls_uint.c | 0 .../cls_uint_va.c | 0 .../cls_ulong_va.c | 0 .../cls_ulonglong.c | 0 .../cls_ushort.c | 0 .../cls_ushort_va.c | 0 testsuite/libffi.closures/ffitest.h | 138 ++++++++++++++++++ 76 files changed, 188 insertions(+) create mode 100644 testsuite/libffi.closures/closure.exp rename testsuite/{libffi.call => libffi.closures}/closure_fn0.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn1.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn2.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn3.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn4.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn5.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_fn6.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_loc_fn0.c (100%) rename testsuite/{libffi.call => libffi.closures}/closure_simple.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_12byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_16byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_18byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_19byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_1_1byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_20byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_20byte1.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_24byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_2byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_3_1byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_3byte1.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_3byte2.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_3float.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_4_1byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_4byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_5_1_byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_5byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_64byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_6_1_byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_6byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_7_1_byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_7byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_8byte.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_9byte1.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_9byte2.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_double.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_float.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_longdouble.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_longdouble_split.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_longdouble_split2.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_pointer.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_sint16.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_sint32.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_sint64.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_uint16.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_uint32.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_align_uint64.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_dbls_struct.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_double.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_double_va.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_float.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_longdouble.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_longdouble_va.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_many_mixed_args.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_many_mixed_float_double.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_schar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_sshort.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_sshortchar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_uchar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_ushort.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_multi_ushortchar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_pointer.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_pointer_stack.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_schar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_sint.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_sshort.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_struct_va1.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_uchar.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_uchar_va.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_uint.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_uint_va.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_ulong_va.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_ulonglong.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_ushort.c (100%) rename testsuite/{libffi.call => libffi.closures}/cls_ushort_va.c (100%) create mode 100644 testsuite/libffi.closures/ffitest.h diff --git a/testsuite/libffi.closures/closure.exp b/testsuite/libffi.closures/closure.exp new file mode 100644 index 000000000..eafbef0f4 --- /dev/null +++ b/testsuite/libffi.closures/closure.exp @@ -0,0 +1,50 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014, 2019 Free Software Foundation, Inc. +# Copyright (C) 2019 Anthony Green + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +if { [string match $compiler_vendor "microsoft"] } { + # -wd4005 macro redefinition + # -wd4244 implicit conversion to type of smaller size + # -wd4305 truncation to smaller type + # -wd4477 printf %lu of uintptr_t + # -wd4312 implicit conversion to type of greater size + # -wd4311 pointer truncation to unsigned long + # -EHsc C++ Exception Handling (no SEH exceptions) + set additional_options "-wd4005 -wd4244 -wd4305 -wd4477 -wd4312 -wd4311 -EHsc"; +} else { + set additional_options ""; +} + +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.c]] + +if { [libffi_feature_test "#if FFI_CLOSURES"] } { + run-many-tests $tlist "" +} else { + foreach test $tlist { + unsupported "$test" + } +} + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/testsuite/libffi.call/closure_fn0.c b/testsuite/libffi.closures/closure_fn0.c similarity index 100% rename from testsuite/libffi.call/closure_fn0.c rename to testsuite/libffi.closures/closure_fn0.c diff --git a/testsuite/libffi.call/closure_fn1.c b/testsuite/libffi.closures/closure_fn1.c similarity index 100% rename from testsuite/libffi.call/closure_fn1.c rename to testsuite/libffi.closures/closure_fn1.c diff --git a/testsuite/libffi.call/closure_fn2.c b/testsuite/libffi.closures/closure_fn2.c similarity index 100% rename from testsuite/libffi.call/closure_fn2.c rename to testsuite/libffi.closures/closure_fn2.c diff --git a/testsuite/libffi.call/closure_fn3.c b/testsuite/libffi.closures/closure_fn3.c similarity index 100% rename from testsuite/libffi.call/closure_fn3.c rename to testsuite/libffi.closures/closure_fn3.c diff --git a/testsuite/libffi.call/closure_fn4.c b/testsuite/libffi.closures/closure_fn4.c similarity index 100% rename from testsuite/libffi.call/closure_fn4.c rename to testsuite/libffi.closures/closure_fn4.c diff --git a/testsuite/libffi.call/closure_fn5.c b/testsuite/libffi.closures/closure_fn5.c similarity index 100% rename from testsuite/libffi.call/closure_fn5.c rename to testsuite/libffi.closures/closure_fn5.c diff --git a/testsuite/libffi.call/closure_fn6.c b/testsuite/libffi.closures/closure_fn6.c similarity index 100% rename from testsuite/libffi.call/closure_fn6.c rename to testsuite/libffi.closures/closure_fn6.c diff --git a/testsuite/libffi.call/closure_loc_fn0.c b/testsuite/libffi.closures/closure_loc_fn0.c similarity index 100% rename from testsuite/libffi.call/closure_loc_fn0.c rename to testsuite/libffi.closures/closure_loc_fn0.c diff --git a/testsuite/libffi.call/closure_simple.c b/testsuite/libffi.closures/closure_simple.c similarity index 100% rename from testsuite/libffi.call/closure_simple.c rename to testsuite/libffi.closures/closure_simple.c diff --git a/testsuite/libffi.call/cls_12byte.c b/testsuite/libffi.closures/cls_12byte.c similarity index 100% rename from testsuite/libffi.call/cls_12byte.c rename to testsuite/libffi.closures/cls_12byte.c diff --git a/testsuite/libffi.call/cls_16byte.c b/testsuite/libffi.closures/cls_16byte.c similarity index 100% rename from testsuite/libffi.call/cls_16byte.c rename to testsuite/libffi.closures/cls_16byte.c diff --git a/testsuite/libffi.call/cls_18byte.c b/testsuite/libffi.closures/cls_18byte.c similarity index 100% rename from testsuite/libffi.call/cls_18byte.c rename to testsuite/libffi.closures/cls_18byte.c diff --git a/testsuite/libffi.call/cls_19byte.c b/testsuite/libffi.closures/cls_19byte.c similarity index 100% rename from testsuite/libffi.call/cls_19byte.c rename to testsuite/libffi.closures/cls_19byte.c diff --git a/testsuite/libffi.call/cls_1_1byte.c b/testsuite/libffi.closures/cls_1_1byte.c similarity index 100% rename from testsuite/libffi.call/cls_1_1byte.c rename to testsuite/libffi.closures/cls_1_1byte.c diff --git a/testsuite/libffi.call/cls_20byte.c b/testsuite/libffi.closures/cls_20byte.c similarity index 100% rename from testsuite/libffi.call/cls_20byte.c rename to testsuite/libffi.closures/cls_20byte.c diff --git a/testsuite/libffi.call/cls_20byte1.c b/testsuite/libffi.closures/cls_20byte1.c similarity index 100% rename from testsuite/libffi.call/cls_20byte1.c rename to testsuite/libffi.closures/cls_20byte1.c diff --git a/testsuite/libffi.call/cls_24byte.c b/testsuite/libffi.closures/cls_24byte.c similarity index 100% rename from testsuite/libffi.call/cls_24byte.c rename to testsuite/libffi.closures/cls_24byte.c diff --git a/testsuite/libffi.call/cls_2byte.c b/testsuite/libffi.closures/cls_2byte.c similarity index 100% rename from testsuite/libffi.call/cls_2byte.c rename to testsuite/libffi.closures/cls_2byte.c diff --git a/testsuite/libffi.call/cls_3_1byte.c b/testsuite/libffi.closures/cls_3_1byte.c similarity index 100% rename from testsuite/libffi.call/cls_3_1byte.c rename to testsuite/libffi.closures/cls_3_1byte.c diff --git a/testsuite/libffi.call/cls_3byte1.c b/testsuite/libffi.closures/cls_3byte1.c similarity index 100% rename from testsuite/libffi.call/cls_3byte1.c rename to testsuite/libffi.closures/cls_3byte1.c diff --git a/testsuite/libffi.call/cls_3byte2.c b/testsuite/libffi.closures/cls_3byte2.c similarity index 100% rename from testsuite/libffi.call/cls_3byte2.c rename to testsuite/libffi.closures/cls_3byte2.c diff --git a/testsuite/libffi.call/cls_3float.c b/testsuite/libffi.closures/cls_3float.c similarity index 100% rename from testsuite/libffi.call/cls_3float.c rename to testsuite/libffi.closures/cls_3float.c diff --git a/testsuite/libffi.call/cls_4_1byte.c b/testsuite/libffi.closures/cls_4_1byte.c similarity index 100% rename from testsuite/libffi.call/cls_4_1byte.c rename to testsuite/libffi.closures/cls_4_1byte.c diff --git a/testsuite/libffi.call/cls_4byte.c b/testsuite/libffi.closures/cls_4byte.c similarity index 100% rename from testsuite/libffi.call/cls_4byte.c rename to testsuite/libffi.closures/cls_4byte.c diff --git a/testsuite/libffi.call/cls_5_1_byte.c b/testsuite/libffi.closures/cls_5_1_byte.c similarity index 100% rename from testsuite/libffi.call/cls_5_1_byte.c rename to testsuite/libffi.closures/cls_5_1_byte.c diff --git a/testsuite/libffi.call/cls_5byte.c b/testsuite/libffi.closures/cls_5byte.c similarity index 100% rename from testsuite/libffi.call/cls_5byte.c rename to testsuite/libffi.closures/cls_5byte.c diff --git a/testsuite/libffi.call/cls_64byte.c b/testsuite/libffi.closures/cls_64byte.c similarity index 100% rename from testsuite/libffi.call/cls_64byte.c rename to testsuite/libffi.closures/cls_64byte.c diff --git a/testsuite/libffi.call/cls_6_1_byte.c b/testsuite/libffi.closures/cls_6_1_byte.c similarity index 100% rename from testsuite/libffi.call/cls_6_1_byte.c rename to testsuite/libffi.closures/cls_6_1_byte.c diff --git a/testsuite/libffi.call/cls_6byte.c b/testsuite/libffi.closures/cls_6byte.c similarity index 100% rename from testsuite/libffi.call/cls_6byte.c rename to testsuite/libffi.closures/cls_6byte.c diff --git a/testsuite/libffi.call/cls_7_1_byte.c b/testsuite/libffi.closures/cls_7_1_byte.c similarity index 100% rename from testsuite/libffi.call/cls_7_1_byte.c rename to testsuite/libffi.closures/cls_7_1_byte.c diff --git a/testsuite/libffi.call/cls_7byte.c b/testsuite/libffi.closures/cls_7byte.c similarity index 100% rename from testsuite/libffi.call/cls_7byte.c rename to testsuite/libffi.closures/cls_7byte.c diff --git a/testsuite/libffi.call/cls_8byte.c b/testsuite/libffi.closures/cls_8byte.c similarity index 100% rename from testsuite/libffi.call/cls_8byte.c rename to testsuite/libffi.closures/cls_8byte.c diff --git a/testsuite/libffi.call/cls_9byte1.c b/testsuite/libffi.closures/cls_9byte1.c similarity index 100% rename from testsuite/libffi.call/cls_9byte1.c rename to testsuite/libffi.closures/cls_9byte1.c diff --git a/testsuite/libffi.call/cls_9byte2.c b/testsuite/libffi.closures/cls_9byte2.c similarity index 100% rename from testsuite/libffi.call/cls_9byte2.c rename to testsuite/libffi.closures/cls_9byte2.c diff --git a/testsuite/libffi.call/cls_align_double.c b/testsuite/libffi.closures/cls_align_double.c similarity index 100% rename from testsuite/libffi.call/cls_align_double.c rename to testsuite/libffi.closures/cls_align_double.c diff --git a/testsuite/libffi.call/cls_align_float.c b/testsuite/libffi.closures/cls_align_float.c similarity index 100% rename from testsuite/libffi.call/cls_align_float.c rename to testsuite/libffi.closures/cls_align_float.c diff --git a/testsuite/libffi.call/cls_align_longdouble.c b/testsuite/libffi.closures/cls_align_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_align_longdouble.c rename to testsuite/libffi.closures/cls_align_longdouble.c diff --git a/testsuite/libffi.call/cls_align_longdouble_split.c b/testsuite/libffi.closures/cls_align_longdouble_split.c similarity index 100% rename from testsuite/libffi.call/cls_align_longdouble_split.c rename to testsuite/libffi.closures/cls_align_longdouble_split.c diff --git a/testsuite/libffi.call/cls_align_longdouble_split2.c b/testsuite/libffi.closures/cls_align_longdouble_split2.c similarity index 100% rename from testsuite/libffi.call/cls_align_longdouble_split2.c rename to testsuite/libffi.closures/cls_align_longdouble_split2.c diff --git a/testsuite/libffi.call/cls_align_pointer.c b/testsuite/libffi.closures/cls_align_pointer.c similarity index 100% rename from testsuite/libffi.call/cls_align_pointer.c rename to testsuite/libffi.closures/cls_align_pointer.c diff --git a/testsuite/libffi.call/cls_align_sint16.c b/testsuite/libffi.closures/cls_align_sint16.c similarity index 100% rename from testsuite/libffi.call/cls_align_sint16.c rename to testsuite/libffi.closures/cls_align_sint16.c diff --git a/testsuite/libffi.call/cls_align_sint32.c b/testsuite/libffi.closures/cls_align_sint32.c similarity index 100% rename from testsuite/libffi.call/cls_align_sint32.c rename to testsuite/libffi.closures/cls_align_sint32.c diff --git a/testsuite/libffi.call/cls_align_sint64.c b/testsuite/libffi.closures/cls_align_sint64.c similarity index 100% rename from testsuite/libffi.call/cls_align_sint64.c rename to testsuite/libffi.closures/cls_align_sint64.c diff --git a/testsuite/libffi.call/cls_align_uint16.c b/testsuite/libffi.closures/cls_align_uint16.c similarity index 100% rename from testsuite/libffi.call/cls_align_uint16.c rename to testsuite/libffi.closures/cls_align_uint16.c diff --git a/testsuite/libffi.call/cls_align_uint32.c b/testsuite/libffi.closures/cls_align_uint32.c similarity index 100% rename from testsuite/libffi.call/cls_align_uint32.c rename to testsuite/libffi.closures/cls_align_uint32.c diff --git a/testsuite/libffi.call/cls_align_uint64.c b/testsuite/libffi.closures/cls_align_uint64.c similarity index 100% rename from testsuite/libffi.call/cls_align_uint64.c rename to testsuite/libffi.closures/cls_align_uint64.c diff --git a/testsuite/libffi.call/cls_dbls_struct.c b/testsuite/libffi.closures/cls_dbls_struct.c similarity index 100% rename from testsuite/libffi.call/cls_dbls_struct.c rename to testsuite/libffi.closures/cls_dbls_struct.c diff --git a/testsuite/libffi.call/cls_double.c b/testsuite/libffi.closures/cls_double.c similarity index 100% rename from testsuite/libffi.call/cls_double.c rename to testsuite/libffi.closures/cls_double.c diff --git a/testsuite/libffi.call/cls_double_va.c b/testsuite/libffi.closures/cls_double_va.c similarity index 100% rename from testsuite/libffi.call/cls_double_va.c rename to testsuite/libffi.closures/cls_double_va.c diff --git a/testsuite/libffi.call/cls_float.c b/testsuite/libffi.closures/cls_float.c similarity index 100% rename from testsuite/libffi.call/cls_float.c rename to testsuite/libffi.closures/cls_float.c diff --git a/testsuite/libffi.call/cls_longdouble.c b/testsuite/libffi.closures/cls_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_longdouble.c rename to testsuite/libffi.closures/cls_longdouble.c diff --git a/testsuite/libffi.call/cls_longdouble_va.c b/testsuite/libffi.closures/cls_longdouble_va.c similarity index 100% rename from testsuite/libffi.call/cls_longdouble_va.c rename to testsuite/libffi.closures/cls_longdouble_va.c diff --git a/testsuite/libffi.call/cls_many_mixed_args.c b/testsuite/libffi.closures/cls_many_mixed_args.c similarity index 100% rename from testsuite/libffi.call/cls_many_mixed_args.c rename to testsuite/libffi.closures/cls_many_mixed_args.c diff --git a/testsuite/libffi.call/cls_many_mixed_float_double.c b/testsuite/libffi.closures/cls_many_mixed_float_double.c similarity index 100% rename from testsuite/libffi.call/cls_many_mixed_float_double.c rename to testsuite/libffi.closures/cls_many_mixed_float_double.c diff --git a/testsuite/libffi.call/cls_multi_schar.c b/testsuite/libffi.closures/cls_multi_schar.c similarity index 100% rename from testsuite/libffi.call/cls_multi_schar.c rename to testsuite/libffi.closures/cls_multi_schar.c diff --git a/testsuite/libffi.call/cls_multi_sshort.c b/testsuite/libffi.closures/cls_multi_sshort.c similarity index 100% rename from testsuite/libffi.call/cls_multi_sshort.c rename to testsuite/libffi.closures/cls_multi_sshort.c diff --git a/testsuite/libffi.call/cls_multi_sshortchar.c b/testsuite/libffi.closures/cls_multi_sshortchar.c similarity index 100% rename from testsuite/libffi.call/cls_multi_sshortchar.c rename to testsuite/libffi.closures/cls_multi_sshortchar.c diff --git a/testsuite/libffi.call/cls_multi_uchar.c b/testsuite/libffi.closures/cls_multi_uchar.c similarity index 100% rename from testsuite/libffi.call/cls_multi_uchar.c rename to testsuite/libffi.closures/cls_multi_uchar.c diff --git a/testsuite/libffi.call/cls_multi_ushort.c b/testsuite/libffi.closures/cls_multi_ushort.c similarity index 100% rename from testsuite/libffi.call/cls_multi_ushort.c rename to testsuite/libffi.closures/cls_multi_ushort.c diff --git a/testsuite/libffi.call/cls_multi_ushortchar.c b/testsuite/libffi.closures/cls_multi_ushortchar.c similarity index 100% rename from testsuite/libffi.call/cls_multi_ushortchar.c rename to testsuite/libffi.closures/cls_multi_ushortchar.c diff --git a/testsuite/libffi.call/cls_pointer.c b/testsuite/libffi.closures/cls_pointer.c similarity index 100% rename from testsuite/libffi.call/cls_pointer.c rename to testsuite/libffi.closures/cls_pointer.c diff --git a/testsuite/libffi.call/cls_pointer_stack.c b/testsuite/libffi.closures/cls_pointer_stack.c similarity index 100% rename from testsuite/libffi.call/cls_pointer_stack.c rename to testsuite/libffi.closures/cls_pointer_stack.c diff --git a/testsuite/libffi.call/cls_schar.c b/testsuite/libffi.closures/cls_schar.c similarity index 100% rename from testsuite/libffi.call/cls_schar.c rename to testsuite/libffi.closures/cls_schar.c diff --git a/testsuite/libffi.call/cls_sint.c b/testsuite/libffi.closures/cls_sint.c similarity index 100% rename from testsuite/libffi.call/cls_sint.c rename to testsuite/libffi.closures/cls_sint.c diff --git a/testsuite/libffi.call/cls_sshort.c b/testsuite/libffi.closures/cls_sshort.c similarity index 100% rename from testsuite/libffi.call/cls_sshort.c rename to testsuite/libffi.closures/cls_sshort.c diff --git a/testsuite/libffi.call/cls_struct_va1.c b/testsuite/libffi.closures/cls_struct_va1.c similarity index 100% rename from testsuite/libffi.call/cls_struct_va1.c rename to testsuite/libffi.closures/cls_struct_va1.c diff --git a/testsuite/libffi.call/cls_uchar.c b/testsuite/libffi.closures/cls_uchar.c similarity index 100% rename from testsuite/libffi.call/cls_uchar.c rename to testsuite/libffi.closures/cls_uchar.c diff --git a/testsuite/libffi.call/cls_uchar_va.c b/testsuite/libffi.closures/cls_uchar_va.c similarity index 100% rename from testsuite/libffi.call/cls_uchar_va.c rename to testsuite/libffi.closures/cls_uchar_va.c diff --git a/testsuite/libffi.call/cls_uint.c b/testsuite/libffi.closures/cls_uint.c similarity index 100% rename from testsuite/libffi.call/cls_uint.c rename to testsuite/libffi.closures/cls_uint.c diff --git a/testsuite/libffi.call/cls_uint_va.c b/testsuite/libffi.closures/cls_uint_va.c similarity index 100% rename from testsuite/libffi.call/cls_uint_va.c rename to testsuite/libffi.closures/cls_uint_va.c diff --git a/testsuite/libffi.call/cls_ulong_va.c b/testsuite/libffi.closures/cls_ulong_va.c similarity index 100% rename from testsuite/libffi.call/cls_ulong_va.c rename to testsuite/libffi.closures/cls_ulong_va.c diff --git a/testsuite/libffi.call/cls_ulonglong.c b/testsuite/libffi.closures/cls_ulonglong.c similarity index 100% rename from testsuite/libffi.call/cls_ulonglong.c rename to testsuite/libffi.closures/cls_ulonglong.c diff --git a/testsuite/libffi.call/cls_ushort.c b/testsuite/libffi.closures/cls_ushort.c similarity index 100% rename from testsuite/libffi.call/cls_ushort.c rename to testsuite/libffi.closures/cls_ushort.c diff --git a/testsuite/libffi.call/cls_ushort_va.c b/testsuite/libffi.closures/cls_ushort_va.c similarity index 100% rename from testsuite/libffi.call/cls_ushort_va.c rename to testsuite/libffi.closures/cls_ushort_va.c diff --git a/testsuite/libffi.closures/ffitest.h b/testsuite/libffi.closures/ffitest.h new file mode 100644 index 000000000..cfce1ad58 --- /dev/null +++ b/testsuite/libffi.closures/ffitest.h @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include "fficonfig.h" + +#if defined HAVE_STDINT_H +#include +#endif + +#if defined HAVE_INTTYPES_H +#include +#endif + +#define MAX_ARGS 256 + +#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0) + +/* Define macros so that compilers other than gcc can run the tests. */ +#undef __UNUSED__ +#if defined(__GNUC__) +#define __UNUSED__ __attribute__((__unused__)) +#define __STDCALL__ __attribute__((stdcall)) +#define __THISCALL__ __attribute__((thiscall)) +#define __FASTCALL__ __attribute__((fastcall)) +#define __MSABI__ __attribute__((ms_abi)) +#else +#define __UNUSED__ +#define __STDCALL__ __stdcall +#define __THISCALL__ __thiscall +#define __FASTCALL__ __fastcall +#endif + +#ifndef ABI_NUM +#define ABI_NUM FFI_DEFAULT_ABI +#define ABI_ATTR +#endif + +/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a + file open. */ +#ifdef HAVE_MMAP_ANON +# undef HAVE_MMAP_DEV_ZERO + +# include +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) +# define MAP_ANONYMOUS MAP_ANON +# endif +# define USING_MMAP + +#endif + +#ifdef HAVE_MMAP_DEV_ZERO + +# include +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# define USING_MMAP + +#endif + +/* MinGW kludge. */ +#if defined(_WIN64) | defined(_WIN32) +#define PRIdLL "I64d" +#define PRIuLL "I64u" +#else +#define PRIdLL "lld" +#define PRIuLL "llu" +#endif + +/* Tru64 UNIX kludge. */ +#if defined(__alpha__) && defined(__osf__) +/* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */ +#undef PRIdLL +#define PRIdLL "ld" +#undef PRIuLL +#define PRIuLL "lu" +#define PRId8 "hd" +#define PRIu8 "hu" +#define PRId64 "ld" +#define PRIu64 "lu" +#define PRIuPTR "lu" +#endif + +/* PA HP-UX kludge. */ +#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR) +#define PRIuPTR "lu" +#endif + +/* IRIX kludge. */ +#if defined(__sgi) +/* IRIX 6.5 provides all definitions, but only for C99 + compilations. */ +#define PRId8 "hhd" +#define PRIu8 "hhu" +#if (_MIPS_SZLONG == 32) +#define PRId64 "lld" +#define PRIu64 "llu" +#endif +/* This doesn't match , which always has "lld" here, but the + arguments are uint64_t, int64_t, which are unsigned long, long for + 64-bit in . */ +#if (_MIPS_SZLONG == 64) +#define PRId64 "ld" +#define PRIu64 "lu" +#endif +/* This doesn't match , which has "u" here, but the arguments + are uintptr_t, which is always unsigned long. */ +#define PRIuPTR "lu" +#endif + +/* Solaris < 10 kludge. */ +#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) +#if defined(__arch64__) || defined (__x86_64__) +#define PRIuPTR "lu" +#else +#define PRIuPTR "u" +#endif +#endif + +/* MSVC kludge. */ +#if defined _MSC_VER +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) +#define PRIuPTR "lu" +#define PRIu8 "u" +#define PRId8 "d" +#define PRIu64 "I64u" +#define PRId64 "I64d" +#endif +#endif + +#ifndef PRIuPTR +#define PRIuPTR "u" +#endif From c88c0e92a9fbb4e69513394682c61aa848a035cc Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 22 Nov 2019 19:27:34 -0500 Subject: [PATCH 093/231] More more closure tests to the closure test directory --- testsuite/libffi.bhaible/bhaible.exp | 8 +++++++- testsuite/libffi.closures/closure.exp | 16 ++++++++++++++++ .../err_bad_abi.c | 0 .../huge_struct.c | 0 .../nested_struct.c | 0 .../nested_struct1.c | 0 .../nested_struct10.c | 0 .../nested_struct11.c | 0 .../nested_struct2.c | 0 .../nested_struct4.c | 0 .../nested_struct5.c | 0 .../nested_struct6.c | 0 .../nested_struct7.c | 0 .../nested_struct8.c | 0 .../nested_struct9.c | 0 .../{libffi.call => libffi.closures}/problem1.c | 0 .../stret_large.c | 0 .../stret_large2.c | 0 .../stret_medium.c | 0 .../stret_medium2.c | 0 .../testclosure.c | 0 .../unwindtest.cc | 0 22 files changed, 23 insertions(+), 1 deletion(-) rename testsuite/{libffi.call => libffi.closures}/err_bad_abi.c (100%) rename testsuite/{libffi.call => libffi.closures}/huge_struct.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct1.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct10.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct11.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct2.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct4.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct5.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct6.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct7.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct8.c (100%) rename testsuite/{libffi.call => libffi.closures}/nested_struct9.c (100%) rename testsuite/{libffi.call => libffi.closures}/problem1.c (100%) rename testsuite/{libffi.call => libffi.closures}/stret_large.c (100%) rename testsuite/{libffi.call => libffi.closures}/stret_large2.c (100%) rename testsuite/{libffi.call => libffi.closures}/stret_medium.c (100%) rename testsuite/{libffi.call => libffi.closures}/stret_medium2.c (100%) rename testsuite/{libffi.call => libffi.closures}/testclosure.c (100%) rename testsuite/{libffi.call => libffi.closures}/unwindtest.cc (100%) diff --git a/testsuite/libffi.bhaible/bhaible.exp b/testsuite/libffi.bhaible/bhaible.exp index 3522bd4f0..44aebc5e0 100644 --- a/testsuite/libffi.bhaible/bhaible.exp +++ b/testsuite/libffi.bhaible/bhaible.exp @@ -47,7 +47,13 @@ for {set i 1} {$i < 82} {incr i} { set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/test-callback.c]] for {set i 1} {$i < 81} {incr i} { - run-many-tests $tlist [format "-DDGTEST=%d %s" $i $warning_options] + if { [libffi_feature_test "#if FFI_CLOSURES"] } { + run-many-tests $tlist [format "-DDGTEST=%d %s" $i $warning_options] + } else { + foreach test $tlist { + unsupported [format "%s -DDGTEST=%d %s" $test $i $warning_options] + } + } } dg-finish diff --git a/testsuite/libffi.closures/closure.exp b/testsuite/libffi.closures/closure.exp index eafbef0f4..9bbc807a5 100644 --- a/testsuite/libffi.closures/closure.exp +++ b/testsuite/libffi.closures/closure.exp @@ -43,6 +43,22 @@ if { [libffi_feature_test "#if FFI_CLOSURES"] } { } } +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.cc]] + +# No C++ for or1k +if { [istarget "or1k-*-*"] } { + foreach test $tlist { + unsupported "$test" + } +} else { + if { [libffi_feature_test "#if FFI_CLOSURES"] } { + run-many-tests $tlist $additional_options + } else { + foreach test $tlist { + unsupported "$test" + } +} + dg-finish # Local Variables: diff --git a/testsuite/libffi.call/err_bad_abi.c b/testsuite/libffi.closures/err_bad_abi.c similarity index 100% rename from testsuite/libffi.call/err_bad_abi.c rename to testsuite/libffi.closures/err_bad_abi.c diff --git a/testsuite/libffi.call/huge_struct.c b/testsuite/libffi.closures/huge_struct.c similarity index 100% rename from testsuite/libffi.call/huge_struct.c rename to testsuite/libffi.closures/huge_struct.c diff --git a/testsuite/libffi.call/nested_struct.c b/testsuite/libffi.closures/nested_struct.c similarity index 100% rename from testsuite/libffi.call/nested_struct.c rename to testsuite/libffi.closures/nested_struct.c diff --git a/testsuite/libffi.call/nested_struct1.c b/testsuite/libffi.closures/nested_struct1.c similarity index 100% rename from testsuite/libffi.call/nested_struct1.c rename to testsuite/libffi.closures/nested_struct1.c diff --git a/testsuite/libffi.call/nested_struct10.c b/testsuite/libffi.closures/nested_struct10.c similarity index 100% rename from testsuite/libffi.call/nested_struct10.c rename to testsuite/libffi.closures/nested_struct10.c diff --git a/testsuite/libffi.call/nested_struct11.c b/testsuite/libffi.closures/nested_struct11.c similarity index 100% rename from testsuite/libffi.call/nested_struct11.c rename to testsuite/libffi.closures/nested_struct11.c diff --git a/testsuite/libffi.call/nested_struct2.c b/testsuite/libffi.closures/nested_struct2.c similarity index 100% rename from testsuite/libffi.call/nested_struct2.c rename to testsuite/libffi.closures/nested_struct2.c diff --git a/testsuite/libffi.call/nested_struct4.c b/testsuite/libffi.closures/nested_struct4.c similarity index 100% rename from testsuite/libffi.call/nested_struct4.c rename to testsuite/libffi.closures/nested_struct4.c diff --git a/testsuite/libffi.call/nested_struct5.c b/testsuite/libffi.closures/nested_struct5.c similarity index 100% rename from testsuite/libffi.call/nested_struct5.c rename to testsuite/libffi.closures/nested_struct5.c diff --git a/testsuite/libffi.call/nested_struct6.c b/testsuite/libffi.closures/nested_struct6.c similarity index 100% rename from testsuite/libffi.call/nested_struct6.c rename to testsuite/libffi.closures/nested_struct6.c diff --git a/testsuite/libffi.call/nested_struct7.c b/testsuite/libffi.closures/nested_struct7.c similarity index 100% rename from testsuite/libffi.call/nested_struct7.c rename to testsuite/libffi.closures/nested_struct7.c diff --git a/testsuite/libffi.call/nested_struct8.c b/testsuite/libffi.closures/nested_struct8.c similarity index 100% rename from testsuite/libffi.call/nested_struct8.c rename to testsuite/libffi.closures/nested_struct8.c diff --git a/testsuite/libffi.call/nested_struct9.c b/testsuite/libffi.closures/nested_struct9.c similarity index 100% rename from testsuite/libffi.call/nested_struct9.c rename to testsuite/libffi.closures/nested_struct9.c diff --git a/testsuite/libffi.call/problem1.c b/testsuite/libffi.closures/problem1.c similarity index 100% rename from testsuite/libffi.call/problem1.c rename to testsuite/libffi.closures/problem1.c diff --git a/testsuite/libffi.call/stret_large.c b/testsuite/libffi.closures/stret_large.c similarity index 100% rename from testsuite/libffi.call/stret_large.c rename to testsuite/libffi.closures/stret_large.c diff --git a/testsuite/libffi.call/stret_large2.c b/testsuite/libffi.closures/stret_large2.c similarity index 100% rename from testsuite/libffi.call/stret_large2.c rename to testsuite/libffi.closures/stret_large2.c diff --git a/testsuite/libffi.call/stret_medium.c b/testsuite/libffi.closures/stret_medium.c similarity index 100% rename from testsuite/libffi.call/stret_medium.c rename to testsuite/libffi.closures/stret_medium.c diff --git a/testsuite/libffi.call/stret_medium2.c b/testsuite/libffi.closures/stret_medium2.c similarity index 100% rename from testsuite/libffi.call/stret_medium2.c rename to testsuite/libffi.closures/stret_medium2.c diff --git a/testsuite/libffi.call/testclosure.c b/testsuite/libffi.closures/testclosure.c similarity index 100% rename from testsuite/libffi.call/testclosure.c rename to testsuite/libffi.closures/testclosure.c diff --git a/testsuite/libffi.call/unwindtest.cc b/testsuite/libffi.closures/unwindtest.cc similarity index 100% rename from testsuite/libffi.call/unwindtest.cc rename to testsuite/libffi.closures/unwindtest.cc From 36730f5d87c2a432e1b3bf1a0129fedbf4b0a488 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 22 Nov 2019 19:49:38 -0500 Subject: [PATCH 094/231] Move closure test to closure directory --- testsuite/{libffi.call => libffi.closures}/unwindtest_ffi_call.cc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename testsuite/{libffi.call => libffi.closures}/unwindtest_ffi_call.cc (100%) diff --git a/testsuite/libffi.call/unwindtest_ffi_call.cc b/testsuite/libffi.closures/unwindtest_ffi_call.cc similarity index 100% rename from testsuite/libffi.call/unwindtest_ffi_call.cc rename to testsuite/libffi.closures/unwindtest_ffi_call.cc From 049da08a22b0ca6d63d2be6c209da5ac1335365c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 07:44:26 -0500 Subject: [PATCH 095/231] Add dejagnu directives accidentally removed --- testsuite/libffi.bhaible/test-call.c | 2 ++ testsuite/libffi.bhaible/test-callback.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/testsuite/libffi.bhaible/test-call.c b/testsuite/libffi.bhaible/test-call.c index 251a97382..01a8a2157 100644 --- a/testsuite/libffi.bhaible/test-call.c +++ b/testsuite/libffi.bhaible/test-call.c @@ -16,6 +16,8 @@ along with this program. If not, see . **/ +/* { dg-do run } */ + #include #include #include diff --git a/testsuite/libffi.bhaible/test-callback.c b/testsuite/libffi.bhaible/test-callback.c index 64f3a0149..c2633c79b 100644 --- a/testsuite/libffi.bhaible/test-callback.c +++ b/testsuite/libffi.bhaible/test-callback.c @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +/* { dg-do run } */ + #include #include #include From 642d40ee6ae9a779b3c5ad930785d4b33cf94029 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 07:49:58 -0500 Subject: [PATCH 096/231] Account for moved test files --- testsuite/Makefile.am | 153 +++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 75 deletions(-) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index ccc78a1f3..64b51e17c 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -7,79 +7,28 @@ EXTRA_DEJAGNU_SITE_CONFIG=../local.exp CLEANFILES = *.exe core* *.log *.sum EXTRA_DIST = lib/target-libpath.exp lib/libffi.exp lib/wrapper.exp \ -libffi.call/strlen4.c libffi.call/cls_multi_sshort.c \ -libffi.call/cls_align_longdouble_split2.c libffi.call/cls_1_1byte.c \ -libffi.call/struct10.c libffi.call/cls_uint_va.c \ -libffi.call/many_mixed.c libffi.call/float.c libffi.call/struct5.c \ -libffi.call/return_fl3.c libffi.call/cls_3_1byte.c \ -libffi.call/return_fl1.c libffi.call/cls_many_mixed_args.c \ -libffi.call/cls_20byte1.c libffi.call/cls_pointer_stack.c \ -libffi.call/cls_align_float.c libffi.call/call.exp \ -libffi.call/pyobjc-tc.c libffi.call/float_va.c \ -libffi.call/cls_5_1_byte.c libffi.call/cls_9byte1.c \ -libffi.call/cls_align_uint32.c libffi.call/stret_medium.c \ -libffi.call/cls_3byte1.c libffi.call/cls_align_uint64.c \ -libffi.call/cls_longdouble_va.c libffi.call/cls_align_pointer.c \ -libffi.call/cls_19byte.c libffi.call/cls_ushort.c \ -libffi.call/cls_align_sint32.c libffi.call/struct8.c \ -libffi.call/pr1172638.c libffi.call/cls_ulonglong.c \ -libffi.call/cls_struct_va1.c libffi.call/cls_9byte2.c \ -libffi.call/closure_fn5.c libffi.call/cls_5byte.c \ -libffi.call/cls_3float.c libffi.call/return_sc.c \ -libffi.call/cls_schar.c libffi.call/closure_fn4.c \ -libffi.call/cls_uchar_va.c libffi.call/closure_fn0.c \ -libffi.call/huge_struct.c libffi.call/va_struct1.c \ -libffi.call/cls_ushort_va.c libffi.call/struct9.c libffi.call/va_1.c \ -libffi.call/cls_64byte.c libffi.call/va_struct2.c \ -libffi.call/cls_longdouble.c libffi.call/return_fl2.c \ -libffi.call/cls_ulong_va.c libffi.call/cls_6_1_byte.c \ -libffi.call/cls_align_uint16.c libffi.call/closure_fn2.c \ -libffi.call/align_mixed.c libffi.call/unwindtest_ffi_call.cc \ -libffi.call/cls_multi_ushortchar.c libffi.call/cls_8byte.c \ -libffi.call/ffitest.h libffi.call/nested_struct8.c \ -libffi.call/cls_pointer.c libffi.call/nested_struct2.c \ -libffi.call/nested_struct.c libffi.call/struct4.c \ -libffi.call/cls_multi_schar.c \ -libffi.call/cls_align_longdouble_split.c libffi.call/cls_uchar.c \ -libffi.call/return_ldl.c libffi.call/nested_struct9.c \ -libffi.call/cls_float.c libffi.call/stret_medium2.c \ -libffi.call/closure_loc_fn0.c libffi.call/float3.c \ -libffi.call/cls_6byte.c libffi.call/return_sl.c \ -libffi.call/closure_simple.c libffi.call/return_dbl1.c \ -libffi.call/cls_align_double.c libffi.call/cls_multi_uchar.c \ -libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \ -libffi.call/closure_fn3.c libffi.call/return_ll1.c \ -libffi.call/return_dbl2.c libffi.call/cls_align_sint64.c \ -libffi.call/nested_struct1.c libffi.call/negint.c \ -libffi.call/nested_struct3.c libffi.call/unwindtest.cc \ +libffi.call/strlen4.c libffi.call/struct10.c libffi.call/many_mixed.c \ +libffi.call/float.c libffi.call/struct5.c libffi.call/return_fl3.c \ +libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc-tc.c \ +libffi.call/float_va.c libffi.call/struct8.c libffi.call/pr1172638.c \ +libffi.call/return_sc.c libffi.call/va_struct1.c \ +libffi.call/align_stdcall.c libffi.call/struct9.c libffi.call/va_1.c \ +libffi.call/va_struct2.c libffi.call/return_fl2.c \ +libffi.call/align_mixed.c libffi.call/ffitest.h libffi.call/struct4.c \ +libffi.call/return_ldl.c libffi.call/float3.c libffi.call/return_sl.c \ +libffi.call/return_dbl1.c libffi.call/err_bad_typedef.c \ +libffi.call/return_ll1.c libffi.call/return_dbl2.c \ +libffi.call/negint.c libffi.call/nested_struct3.c \ libffi.call/struct2.c libffi.call/struct3.c libffi.call/return_fl.c \ -libffi.call/nested_struct5.c libffi.call/cls_multi_ushort.c \ -libffi.call/nested_struct11.c libffi.call/cls_multi_sshortchar.c \ -libffi.call/cls_align_longdouble.c libffi.call/cls_dbls_struct.c \ -libffi.call/cls_many_mixed_float_double.c libffi.call/stret_large.c \ -libffi.call/stret_large2.c libffi.call/cls_align_sint16.c \ -libffi.call/cls_2byte.c libffi.call/offsets.c libffi.call/struct7.c \ -libffi.call/nested_struct4.c libffi.call/problem1.c \ -libffi.call/va_struct3.c libffi.call/testclosure.c \ -libffi.call/float1.c libffi.call/nested_struct6.c \ -libffi.call/cls_4byte.c libffi.call/cls_24byte.c \ -libffi.call/uninitialized.c libffi.call/many2.c \ -libffi.call/nested_struct10.c libffi.call/struct6.c \ -libffi.call/strlen2.c libffi.call/float2.c libffi.call/cls_uint.c \ -libffi.call/cls_12byte.c libffi.call/return_ul.c \ -libffi.call/cls_sint.c libffi.call/cls_7_1_byte.c \ -libffi.call/struct1.c libffi.call/cls_sshort.c \ -libffi.call/cls_16byte.c libffi.call/strlen3.c \ -libffi.call/nested_struct7.c libffi.call/cls_double_va.c \ -libffi.call/return_dbl.c libffi.call/cls_3byte2.c \ -libffi.call/float4.c libffi.call/cls_double.c libffi.call/many.c \ -libffi.call/cls_7byte.c libffi.call/strlen.c \ -libffi.call/closure_fn6.c libffi.call/return_uc.c \ -libffi.call/closure_fn1.c libffi.call/cls_20byte.c \ -libffi.call/cls_18byte.c libffi.call/err_bad_abi.c \ -libffi.call/many_double.c libffi.call/return_ll.c \ -libffi.call/promotion.c libffi.complex/complex_defs_longdouble.inc \ -libffi.call/align_stdcall.c libffi.complex/cls_align_complex_float.c \ +libffi.call/offsets.c libffi.call/struct7.c libffi.call/va_struct3.c \ +libffi.call/float1.c libffi.call/uninitialized.c libffi.call/many2.c \ +libffi.call/struct6.c libffi.call/strlen2.c libffi.call/float2.c \ +libffi.call/return_ul.c libffi.call/struct1.c libffi.call/strlen3.c \ +libffi.call/return_dbl.c libffi.call/float4.c libffi.call/many.c \ +libffi.call/strlen.c libffi.call/return_uc.c libffi.call/many_double.c \ +libffi.call/return_ll.c libffi.call/promotion.c \ +libffi.complex/complex_defs_longdouble.inc \ +libffi.complex/cls_align_complex_float.c \ libffi.complex/cls_complex_va_float.c \ libffi.complex/cls_complex_struct_float.c \ libffi.complex/return_complex2_longdouble.c \ @@ -90,9 +39,9 @@ libffi.complex/cls_complex_va_longdouble.c \ libffi.complex/return_complex_double.c \ libffi.complex/return_complex.inc libffi.complex/many_complex.inc \ libffi.complex/complex_float.c libffi.complex/cls_align_complex.inc \ -libffi.complex/return_complex2_double.c \ +libffi.complex/return_complex2_double.c \ libffi.complex/many_complex_float.c libffi.complex/ffitest.h \ -libffi.complex/return_complex1_double.c \ +libffi.complex/return_complex1_double.c \ libffi.complex/cls_complex_struct_longdouble.c \ libffi.complex/complex_defs_double.inc \ libffi.complex/cls_complex_va_double.c \ @@ -116,4 +65,58 @@ libffi.go/aa-direct.c libffi.go/ffitest.h libffi.go/go.exp \ libffi.go/static-chain.h libffi.bhaible/bhaible.exp \ libffi.bhaible/test-call.c libffi.bhaible/alignof.h \ libffi.bhaible/testcases.c libffi.bhaible/test-callback.c \ -libffi.bhaible/Makefile libffi.bhaible/README config/default.exp +libffi.bhaible/Makefile libffi.bhaible/README config/default.exp \ +libffi.closures/cls_multi_sshort.c \ +libffi.closures/cls_align_longdouble_split2.c \ +libffi.closures/cls_1_1byte.c libffi.closures/cls_uint_va.c \ +libffi.closures/cls_3_1byte.c libffi.closures/cls_many_mixed_args.c \ +libffi.closures/cls_20byte1.c libffi.closures/cls_pointer_stack.c \ +libffi.closures/cls_align_float.c libffi.closures/cls_5_1_byte.c \ +libffi.closures/cls_9byte1.c libffi.closures/cls_align_uint32.c \ +libffi.closures/stret_medium.c libffi.closures/cls_3byte1.c \ +libffi.closures/cls_align_uint64.c libffi.closures/cls_longdouble_va.c \ +libffi.closures/cls_align_pointer.c libffi.closures/cls_19byte.c \ +libffi.closures/cls_ushort.c libffi.closures/cls_align_sint32.c \ +libffi.closures/cls_ulonglong.c libffi.closures/cls_struct_va1.c \ +libffi.closures/cls_9byte2.c libffi.closures/closure_fn5.c \ +libffi.closures/cls_5byte.c libffi.closures/cls_3float.c \ +libffi.closures/closure.exp libffi.closures/cls_schar.c \ +libffi.closures/closure_fn4.c libffi.closures/cls_uchar_va.c \ +libffi.closures/closure_fn0.c libffi.closures/huge_struct.c \ +libffi.closures/cls_ushort_va.c libffi.closures/closure.exp~ \ +libffi.closures/cls_64byte.c libffi.closures/cls_longdouble.c \ +libffi.closures/cls_ulong_va.c libffi.closures/cls_6_1_byte.c \ +libffi.closures/cls_align_uint16.c libffi.closures/closure_fn2.c \ +libffi.closures/unwindtest_ffi_call.cc \ +libffi.closures/cls_multi_ushortchar.c libffi.closures/cls_8byte.c \ +libffi.closures/ffitest.h libffi.closures/nested_struct8.c \ +libffi.closures/cls_pointer.c libffi.closures/nested_struct2.c \ +libffi.closures/nested_struct.c libffi.closures/cls_multi_schar.c \ +libffi.closures/cls_align_longdouble_split.c \ +libffi.closures/cls_uchar.c libffi.closures/nested_struct9.c \ +libffi.closures/cls_float.c libffi.closures/stret_medium2.c \ +libffi.closures/closure_loc_fn0.c libffi.closures/cls_6byte.c \ +libffi.closures/closure_simple.c libffi.closures/cls_align_double.c \ +libffi.closures/cls_multi_uchar.c libffi.closures/cls_4_1byte.c \ +libffi.closures/closure_fn3.c libffi.closures/cls_align_sint64.c \ +libffi.closures/nested_struct1.c libffi.closures/unwindtest.cc \ +libffi.closures/nested_struct5.c libffi.closures/cls_multi_ushort.c \ +libffi.closures/nested_struct11.c \ +libffi.closures/cls_multi_sshortchar.c \ +libffi.closures/cls_align_longdouble.c \ +libffi.closures/cls_dbls_struct.c \ +libffi.closures/cls_many_mixed_float_double.c \ +libffi.closures/stret_large.c libffi.closures/stret_large2.c \ +libffi.closures/cls_align_sint16.c libffi.closures/cls_2byte.c \ +libffi.closures/nested_struct4.c libffi.closures/problem1.c \ +libffi.closures/testclosure.c libffi.closures/nested_struct6.c \ +libffi.closures/cls_4byte.c libffi.closures/cls_24byte.c \ +libffi.closures/nested_struct10.c libffi.closures/cls_uint.c \ +libffi.closures/cls_12byte.c libffi.closures/cls_sint.c \ +libffi.closures/cls_7_1_byte.c libffi.closures/cls_sshort.c \ +libffi.closures/cls_16byte.c libffi.closures/nested_struct7.c \ +libffi.closures/cls_double_va.c libffi.closures/cls_3byte2.c \ +libffi.closures/cls_double.c libffi.closures/cls_7byte.c \ +libffi.closures/closure_fn6.c libffi.closures/closure_fn1.c \ +libffi.closures/cls_20byte.c libffi.closures/cls_18byte.c \ +libffi.closures/err_bad_abi.c From c72b82f465148b89f118ee73f8956dafdbac9b65 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 08:48:53 -0500 Subject: [PATCH 097/231] Remove junk file from dist --- testsuite/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 64b51e17c..68a094c14 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -83,7 +83,7 @@ libffi.closures/cls_5byte.c libffi.closures/cls_3float.c \ libffi.closures/closure.exp libffi.closures/cls_schar.c \ libffi.closures/closure_fn4.c libffi.closures/cls_uchar_va.c \ libffi.closures/closure_fn0.c libffi.closures/huge_struct.c \ -libffi.closures/cls_ushort_va.c libffi.closures/closure.exp~ \ +libffi.closures/cls_ushort_va.c \ libffi.closures/cls_64byte.c libffi.closures/cls_longdouble.c \ libffi.closures/cls_ulong_va.c libffi.closures/cls_6_1_byte.c \ libffi.closures/cls_align_uint16.c libffi.closures/closure_fn2.c \ From d996cb283cf373936498defa902be040ec20455e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 09:00:14 -0500 Subject: [PATCH 098/231] Version 3.3 --- README.md | 5 +++-- configure.ac | 2 +- doc/version.texi | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a8f2b04fd..3d6ce4431 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.3-rc3 was released on November 9, 2019. Check the libffi web +libffi-3.3 was released on November 23, 2019. Check the libffi web page for updates: . @@ -197,7 +197,7 @@ History See the git log for details at http://github.com/libffi/libffi. - 3.3 TBD + 3.3 Nov-23-19 Add RISC-V support. New API in support of GO closures. Add IEEE754 binary128 long double support for 64-bit Power @@ -206,6 +206,7 @@ See the git log for details at http://github.com/libffi/libffi. Add Windows on ARM64 (WOA) support. Add Windows 32-bit ARM support. Raw java (gcj) API deprecated. + Add pre-built PDF documentation to source distribution. Many new tests cases and bug fixes. 3.2.1 Nov-12-14 diff --git a/configure.ac b/configure.ac index a98ec176d..b764368d6 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.3-rc2], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.3], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index d6383370e..d9d509492 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 31 October 2019 -@set UPDATED-MONTH October 2019 -@set EDITION 3.3-rc2 -@set VERSION 3.3-rc2 +@set UPDATED 22 November 2019 +@set UPDATED-MONTH November 2019 +@set EDITION 3.3 +@set VERSION 3.3 From 1aca33301a791f503d943f5e3abe2c720296eb8f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 09:42:04 -0500 Subject: [PATCH 099/231] Add missing closing brace --- testsuite/libffi.closures/closure.exp | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/libffi.closures/closure.exp b/testsuite/libffi.closures/closure.exp index 9bbc807a5..ed4145ca8 100644 --- a/testsuite/libffi.closures/closure.exp +++ b/testsuite/libffi.closures/closure.exp @@ -56,6 +56,7 @@ if { [istarget "or1k-*-*"] } { } else { foreach test $tlist { unsupported "$test" + } } } From 5dcb741f1544c5e18c9dbf96aeb8b61cc556a616 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 23 Nov 2019 10:24:58 -0500 Subject: [PATCH 100/231] Move nested_struct3 test to closures directory --- testsuite/Makefile.am | 2 +- testsuite/{libffi.call => libffi.closures}/nested_struct3.c | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename testsuite/{libffi.call => libffi.closures}/nested_struct3.c (100%) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 68a094c14..bcfea5770 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -18,7 +18,7 @@ libffi.call/align_mixed.c libffi.call/ffitest.h libffi.call/struct4.c \ libffi.call/return_ldl.c libffi.call/float3.c libffi.call/return_sl.c \ libffi.call/return_dbl1.c libffi.call/err_bad_typedef.c \ libffi.call/return_ll1.c libffi.call/return_dbl2.c \ -libffi.call/negint.c libffi.call/nested_struct3.c \ +libffi.call/negint.c libffi.closures/nested_struct3.c \ libffi.call/struct2.c libffi.call/struct3.c libffi.call/return_fl.c \ libffi.call/offsets.c libffi.call/struct7.c libffi.call/va_struct3.c \ libffi.call/float1.c libffi.call/uninitialized.c libffi.call/many2.c \ diff --git a/testsuite/libffi.call/nested_struct3.c b/testsuite/libffi.closures/nested_struct3.c similarity index 100% rename from testsuite/libffi.call/nested_struct3.c rename to testsuite/libffi.closures/nested_struct3.c From fd99c95f90f85963f5ec88630c0428a8132012db Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 24 Nov 2019 11:11:25 -0500 Subject: [PATCH 101/231] Minor clean-up --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d6ce4431..ca774f5ee 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,8 @@ See the git log for details at http://github.com/libffi/libffi. Add Windows on ARM64 (WOA) support. Add Windows 32-bit ARM support. Raw java (gcj) API deprecated. - Add pre-built PDF documentation to source distribution. - Many new tests cases and bug fixes. + Add pre-built PDF documentation to source distribution. + Many new test cases and bug fixes. 3.2.1 Nov-12-14 Build fix for non-iOS AArch64 targets. From fb914c366fabb29ac373050ca0bfa4d9c1fef149 Mon Sep 17 00:00:00 2001 From: Panayotis Date: Sun, 24 Nov 2019 18:25:13 +0200 Subject: [PATCH 102/231] disable obsolete 32-bit targets in macOS (#511) --- README.md | 1 - generate-darwin-source-and-headers.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3d6ce4431..2562ab11b 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,6 @@ tested: | X86 | Interix | GCC | | X86 | kFreeBSD | GCC | | X86 | Linux | GCC | -| X86 | Mac OSX | GCC | | X86 | OpenBSD | GCC | | X86 | OS/2 | GCC | | X86 | Solaris | GCC | diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py index f7fc414b3..3d840b963 100755 --- a/generate-darwin-source-and-headers.py +++ b/generate-darwin-source-and-headers.py @@ -143,7 +143,7 @@ def xcrun_cmd(cmd): mkdir_p(build_dir) env = dict(CC=xcrun_cmd('clang'), LD=xcrun_cmd('ld'), - CFLAGS='%s' % (platform.version_min)) + CFLAGS='%s -fembed-bitcode' % (platform.version_min)) working_dir = os.getcwd() try: os.chdir(build_dir) @@ -173,7 +173,7 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): copy_src_platform_files(device_platform) copy_src_platform_files(device64_platform) if generate_osx: - copy_src_platform_files(desktop32_platform) +# copy_src_platform_files(desktop32_platform) copy_src_platform_files(desktop64_platform) platform_headers = collections.defaultdict(set) @@ -184,7 +184,7 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): build_target(device_platform, platform_headers) build_target(device64_platform, platform_headers) if generate_osx: - build_target(desktop32_platform, platform_headers) +# build_target(desktop32_platform, platform_headers) build_target(desktop64_platform, platform_headers) mkdir_p('darwin_common/include') From 86be66c8f608a84caea2ef724698093d2da2e5e2 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 24 Nov 2019 16:09:44 -0500 Subject: [PATCH 103/231] Try travis-ci's new ppc64le and s390x support --- .travis.yml | 7 +++---- .travis/build.sh | 13 ++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7cd3a186a..5b4bc84d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,9 @@ matrix: - os: linux env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux - env: HOST=s390x-linux-gnu MEVAL='export CC="s390x-linux-gnu-gcc-8" && CXX="s390x-linux-gnu-g++-8"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/s390x-linux-gnu QEMU_CPU=max + arch: s390x + - os: linux + arch: ppc64le - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux @@ -39,9 +41,6 @@ matrix: # The sparc64 linux system in the GCC compile farm is non-responsive. # - os: linux # env: HOST=sparc64-linux-gnu -# Having problems getting logs for this one... -# - os: linux -# env: HOST=powerpc64le-unknown-linux-gnu # - os: linux # env: HOST=aarch64-linux-gnu # The mips64 linux system in the GCC compile farm is not allowing logins diff --git a/.travis/build.sh b/.travis/build.sh index db596b3d9..c134f576e 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -11,8 +11,7 @@ fi # Default to podman where available, docker otherwise. # Override by setting the DOCKER environment variable. if test -z "$DOCKER"; then - which podman > /dev/null 2>&1 - if [ $? != 0 ]; then + if command -v podman > /dev/null; then export DOCKER=docker else export DOCKER=podman @@ -50,7 +49,7 @@ function build_linux() function build_foreign_linux() { - ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) @@ -60,7 +59,7 @@ function build_foreign_linux() function build_cross_linux() { - ${DOCKER} run --rm -t -i -v `pwd`:/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) @@ -71,7 +70,7 @@ function build_cross_linux() function build_cross() { ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} - ${DOCKER} run --rm -t -i -v `pwd`:/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l https://rl.gl ID=$(./rlgl start) @@ -112,7 +111,7 @@ case "$HOST" in ./autogen.sh build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest ;; - aarch64-linux-gnu| powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + aarch64-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; bfin-elf ) @@ -131,7 +130,7 @@ case "$HOST" in ./autogen.sh GCC_OPTIONS=-mcpu=547x build_cross_linux ;; - alpha-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) + alpha-linux-gnu | sh4-linux-gnu ) ./autogen.sh build_cross_linux ;; From 932e5bb68a603885e4bd9cf1bd5146542f736ccf Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 24 Nov 2019 16:26:14 -0500 Subject: [PATCH 104/231] Force the use of docker --- .travis/build.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index c134f576e..a0cfcef1d 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -8,15 +8,7 @@ else export SET_QEMU_CPU="-e QEMU_CPU=${QEMU_CPU}" fi -# Default to podman where available, docker otherwise. -# Override by setting the DOCKER environment variable. -if test -z "$DOCKER"; then - if command -v podman > /dev/null; then - export DOCKER=docker - else - export DOCKER=podman - fi -fi +export DOCKER=docker function build_cfarm() { From 66022e52ec0409f9170eb0884c6d0bdd048bc04e Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 24 Nov 2019 16:52:14 -0500 Subject: [PATCH 105/231] Fixes for ppc64le and s390x travis testing --- .travis.yml | 2 ++ .travis/install.sh | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b4bc84d5..1cc686859 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,10 @@ matrix: env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - os: linux arch: s390x + env: HOST=s390x-linux-gnu - os: linux arch: ppc64le + env: HOST=ppc64le-linux-gnu - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux diff --git a/.travis/install.sh b/.travis/install.sh index eb7f80f32..bd168bb37 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -9,20 +9,31 @@ if [[ $TRAVIS_OS_NAME != 'linux' ]]; then # Download and extract the rlgl client wget -qO - https://rl.gl/cli/rlgl-darwin-amd64.tgz | \ - tar --strip-components=2 -xvzf - ./rlgl/rlgl + tar --strip-components=2 -xvzf - ./rlgl/rlgl; else - # Download and extract the rlgl client - wget -qO - http://rl.gl/cli/rlgl-linux-amd64.tgz | \ - tar --strip-components=2 -xvzf - ./rlgl/rlgl + case $HOST in + ppc64le-linux-gnu) + wget -qO - https://rl.gl/cli/rlgl-linux-ppc64le.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl; + ;; + s390x-linux-gnu) + wget -qO - https://rl.gl/cli/rlgl-linux-s390x.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl; + ;; + *) + wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl; + ;; + esac sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - aarch64-linux-gnu | powerpc64le-unknown-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + aarch64-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) ;; - alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu | s390x-linux-gnu ) + alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu) sudo apt-get install qemu-user-static ;; hppa-linux-gnu ) @@ -46,7 +57,7 @@ else ;; esac case $HOST in - arm32v7-linux-gnu | aarch64-linux-gnu | ppc64le-linux-gnu | s390x-linux-gnu) + arm32v7-linux-gnu | aarch64-linux-gnu) # don't install host tools ;; *) From 1ec01ea81cf18e12748082f48f7c279a3fdd505d Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 24 Nov 2019 22:47:48 -0500 Subject: [PATCH 106/231] Run aarch64-linux-gnu tests on travi-ci directly --- .travis.yml | 5 +++-- .travis/build.sh | 2 +- .travis/install.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1cc686859..27d8e8a7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,9 @@ matrix: - os: linux arch: ppc64le env: HOST=ppc64le-linux-gnu + - os: linux + arch: arm64 + env: HOST=aarch64-linux-gnu - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux @@ -43,8 +46,6 @@ matrix: # The sparc64 linux system in the GCC compile farm is non-responsive. # - os: linux # env: HOST=sparc64-linux-gnu -# - os: linux -# env: HOST=aarch64-linux-gnu # The mips64 linux system in the GCC compile farm is not allowing logins # - os: linux # env: HOST=mips64el-linux-gnu diff --git a/.travis/build.sh b/.travis/build.sh index a0cfcef1d..3e4a018ef 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -103,7 +103,7 @@ case "$HOST" in ./autogen.sh build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest ;; - aarch64-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm ;; bfin-elf ) diff --git a/.travis/install.sh b/.travis/install.sh index bd168bb37..242024571 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -14,6 +14,10 @@ if [[ $TRAVIS_OS_NAME != 'linux' ]]; then else # Download and extract the rlgl client case $HOST in + aarch64-linux-gnu) + wget -qO - https://rl.gl/cli/rlgl-linux-arm.tgz | \ + tar --strip-components=2 -xvzf - ./rlgl/rlgl; + ;; ppc64le-linux-gnu) wget -qO - https://rl.gl/cli/rlgl-linux-ppc64le.tgz | \ tar --strip-components=2 -xvzf - ./rlgl/rlgl; @@ -31,7 +35,7 @@ else sudo apt-get clean # clear the cache sudo apt-get update case $HOST in - aarch64-linux-gnu | mips64el-linux-gnu | sparc64-linux-gnu) + mips64el-linux-gnu | sparc64-linux-gnu) ;; alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu) sudo apt-get install qemu-user-static @@ -57,7 +61,7 @@ else ;; esac case $HOST in - arm32v7-linux-gnu | aarch64-linux-gnu) + arm32v7-linux-gnu) # don't install host tools ;; *) From 01a75ed76ea7e57f1b7a5c183e2b1e890e6aa0fd Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 28 Nov 2019 12:42:41 +0000 Subject: [PATCH 107/231] powerpc: fix build failure on power7 and older (#532) Build failure looks as: ``` libtool: compile: powerpc-unknown-linux-gnu-gcc \ -O2 -mcpu=powerpc -mtune=powerpc -pipe ... -c src/powerpc/ffi.c ... In file included from src/powerpc/ffi.c:33: src/powerpc/ffi_powerpc.h:65:9: error: '__int128' is not supported on this target 65 | typedef __int128 float128; | ^~~~~~~~ ``` The fix avoids using __int128 in favour of aligned char[16]. Closes: https://github.com/libffi/libffi/issues/531 Signed-off-by: Sergei Trofimovich --- src/powerpc/ffi_powerpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powerpc/ffi_powerpc.h b/src/powerpc/ffi_powerpc.h index 5ee2a7095..8e2f2f0e7 100644 --- a/src/powerpc/ffi_powerpc.h +++ b/src/powerpc/ffi_powerpc.h @@ -62,7 +62,7 @@ typedef _Float128 float128; #elif defined(__FLOAT128__) typedef __float128 float128; #else -typedef __int128 float128; +typedef char float128[16] __attribute__((aligned(16))); #endif void FFI_HIDDEN ffi_closure_SYSV (void); From 29297445da5c2c9437de0e20f3189799a27f0301 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 28 Nov 2019 17:31:44 -0500 Subject: [PATCH 108/231] Test on powerpc-eabisim --- .travis.yml | 2 ++ .travis/build.sh | 6 +++- .travis/powerpc-eabisim.exp | 58 +++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .travis/powerpc-eabisim.exp diff --git a/.travis.yml b/.travis.yml index 27d8e8a7e..bd908fdfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ language: cpp matrix: include: + - os: linux + env: HOST=powerpc-eabisim RUNTESTFLAGS="--target_board powerpc-eabisim" DEJAGNU="/opt/.travis/site.exp" - os: linux env: HOST=or1k-elf RUNTESTFLAGS="--target_board or1k-sim" DEJAGNU="/opt/.travis/site.exp" - os: linux diff --git a/.travis/build.sh b/.travis/build.sh index 3e4a018ef..68d3e3860 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -28,7 +28,7 @@ function build_cfarm() function build_linux() { ./autogen.sh - ./configure ${HOST+--host=$HOST} ${CONFIGURE_OPTIONS} + ./configure ${HOST+--host=$HOST} ${CONFIGURE_OPTIONS} || cat */config.log make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" @@ -118,6 +118,10 @@ case "$HOST" in ./autogen.sh build_cross ;; + powerpc-eabisim ) + ./autogen.sh + build_cross + ;; m68k-linux-gnu ) ./autogen.sh GCC_OPTIONS=-mcpu=547x build_cross_linux diff --git a/.travis/powerpc-eabisim.exp b/.travis/powerpc-eabisim.exp new file mode 100644 index 000000000..bdc438960 --- /dev/null +++ b/.travis/powerpc-eabisim.exp @@ -0,0 +1,58 @@ +# Copyright (C) 2010, 2019 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# DejaGnu is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This is a list of toolchains that are supported on this board. +set_board_info target_install {powerpc-eabisim} + +# Load the generic configuration for this board. This will define a basic set +# of routines needed by the tool to communicate with the board. +load_generic_config "sim" + +# basic-sim.exp is a basic description for the standard Cygnus simulator. +load_base_board_description "basic-sim" + +# "powerpc" is the name of the sim subdir in devo/sim. +setup_sim powerpc + +# No multilib options needed by default. +process_multilib_options "" + +# We only support newlib on this target. We assume that all multilib +# options have been specified before we get here. + +set_board_info compiler "[find_gcc]" +set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]" +set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]" + +# Configuration settings for testsuites +set_board_info noargs 1 +set_board_info gdb,nosignals 1 +set_board_info gdb,noresults 1 +set_board_info gdb,cannot_call_functions 1 +set_board_info gdb,skip_float_tests 1 +set_board_info gdb,can_reverse 1 +set_board_info gdb,use_precord 1 + +# More time is needed +set_board_info gcc,timeout 800 +set_board_info gdb,timeout 60 + +# Used by a few gcc.c-torture testcases to delimit how large the stack can +# be. +set_board_info gcc,stack_size 5000 + From 43887a9108f10124d05c8e0e67f3942cd980cb86 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 28 Nov 2019 17:44:51 -0500 Subject: [PATCH 109/231] Add powerpc-eabi --- configure.host | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.host b/configure.host index 9a72cda87..055e95566 100644 --- a/configure.host +++ b/configure.host @@ -190,6 +190,9 @@ case "${host}" in powerpc-*-amigaos*) TARGET=POWERPC; TARGETDIR=powerpc ;; + powerpc-*-eabi*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc ;; From 0069526c5adea9e6268b8a0087a6120c9c5c89fa Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 28 Nov 2019 18:58:40 -0500 Subject: [PATCH 110/231] Make build errors easier to debug --- .travis/build-cross-in-container.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh index 11447dbc5..7e2252ce1 100755 --- a/.travis/build-cross-in-container.sh +++ b/.travis/build-cross-in-container.sh @@ -2,14 +2,11 @@ cd /opt -set -x echo $PATH export PATH=/usr/local/bin:$PATH echo $PATH -ls -l /usr/local/bin - -./configure --host=${HOST} +./configure --host=${HOST} || cat */config.log make make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true From 6663047f56c2932a6b10a790f4ac6666dd181326 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 29 Nov 2019 07:00:35 -0500 Subject: [PATCH 111/231] Address platforms with no __int128. --- src/powerpc/ffi_linux64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/powerpc/ffi_linux64.c b/src/powerpc/ffi_linux64.c index de0d03376..736477014 100644 --- a/src/powerpc/ffi_linux64.c +++ b/src/powerpc/ffi_linux64.c @@ -547,9 +547,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) if (next_arg.ul == gpr_end.ul) next_arg.ul = rest.ul; if (vecarg_count < NUM_VEC_ARG_REGISTERS64 && i < nfixedargs) - *vec_base.f128++ = **p_argv.f128; + memcpy (vec_base.f128++, *p_argv.f128, sizeof (float128)); else - *next_arg.f128 = **p_argv.f128; + memcpy (next_arg.f128, *p_argv.f128, sizeof (float128)); if (++next_arg.f128 == gpr_end.f128) next_arg.f128 = rest.f128; vecarg_count++; From 98da256096c63406ef77f92369ada622c50ce388 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 29 Nov 2019 14:29:51 -0500 Subject: [PATCH 112/231] Clean up macosx builds --- .travis/build.sh | 1 + generate-darwin-source-and-headers.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 68d3e3860..fc572fd75 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -87,6 +87,7 @@ function build_macosx() ./generate-darwin-source-and-headers.py --only-osx xcodebuild -showsdks xcodebuild -project libffi.xcodeproj -target "libffi-Mac" -configuration Release -sdk macosx10.13 + echo "Finished build" exit $? } diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py index 3d840b963..b8c28e643 100755 --- a/generate-darwin-source-and-headers.py +++ b/generate-darwin-source-and-headers.py @@ -173,7 +173,6 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): copy_src_platform_files(device_platform) copy_src_platform_files(device64_platform) if generate_osx: -# copy_src_platform_files(desktop32_platform) copy_src_platform_files(desktop64_platform) platform_headers = collections.defaultdict(set) @@ -184,7 +183,6 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): build_target(device_platform, platform_headers) build_target(device64_platform, platform_headers) if generate_osx: -# build_target(desktop32_platform, platform_headers) build_target(desktop64_platform, platform_headers) mkdir_p('darwin_common/include') From 76c0cfea70f78586231d7994492396eebfb12d5f Mon Sep 17 00:00:00 2001 From: Carl Hurd Date: Fri, 29 Nov 2019 14:46:11 -0500 Subject: [PATCH 113/231] Fixed missed #ifndef for __mips_soft_float (#442) Thank you! --- src/mips/o32.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mips/o32.S b/src/mips/o32.S index 44e74cb91..799139b29 100644 --- a/src/mips/o32.S +++ b/src/mips/o32.S @@ -282,9 +282,11 @@ $LCFI12: li $13, 1 # FFI_O32 bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT +#ifndef __mips_soft_float # Store all possible float/double registers. s.d $f12, FA_0_0_OFF2($fp) s.d $f14, FA_1_0_OFF2($fp) +#endif 1: # prepare arguments for ffi_closure_mips_inner_O32 REG_L a0, 4($15) # cif From f9da75e157ab089363d079a781644c3e6f7db2c3 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 30 Nov 2019 07:37:19 -0500 Subject: [PATCH 114/231] Remove 32-bit x86 file references to fix macosx builds --- libffi.xcodeproj/project.pbxproj | 50 ++------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/libffi.xcodeproj/project.pbxproj b/libffi.xcodeproj/project.pbxproj index 9a107b49c..480c4a4e4 100644 --- a/libffi.xcodeproj/project.pbxproj +++ b/libffi.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 43B5D3F81D35473200D1E1FD /* ffiw64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = 43B5D3F71D35473200D1E1FD /* ffiw64_x86_64.c */; }; 43B5D3FA1D3547CE00D1E1FD /* win64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = 43B5D3F91D3547CE00D1E1FD /* win64_x86_64.S */; }; - 43E9A5C71D352C1500926A8F /* sysv_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = 43E9A5C51D352C1500926A8F /* sysv_i386.S */; }; 43E9A5C81D352C1500926A8F /* unix64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = 43E9A5C61D352C1500926A8F /* unix64_x86_64.S */; }; DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; }; @@ -28,26 +27,18 @@ DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; }; DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; }; DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; }; - DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; }; - DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; }; DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; }; - DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; }; DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; }; - DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; }; DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; }; DBFA7194187F1DA100A76262 /* unix64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* unix64_x86_64.S */; }; - DBFA7195187F1DA100A76262 /* sysv_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* sysv_i386.S */; }; DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; }; - DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; }; FDB52FB31F6144FA00AA92E6 /* unix64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = 43E9A5C61D352C1500926A8F /* unix64_x86_64.S */; }; - FDB52FB41F6144FA00AA92E6 /* sysv_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = 43E9A5C51D352C1500926A8F /* sysv_i386.S */; }; FDB52FB51F6144FA00AA92E6 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; }; FDB52FB61F6144FA00AA92E6 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; }; FDB52FB71F6144FA00AA92E6 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; }; FDB52FB81F6144FA00AA92E6 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; }; FDB52FB91F6144FA00AA92E6 /* ffiw64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = 43B5D3F71D35473200D1E1FD /* ffiw64_x86_64.c */; }; FDB52FBA1F6144FA00AA92E6 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; - FDB52FBB1F6144FA00AA92E6 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; }; FDB52FBC1F6144FA00AA92E6 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; FDB52FBD1F6144FA00AA92E6 /* sysv_arm64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716D187F1D9B00A76262 /* sysv_arm64.S */; }; FDB52FBE1F6144FA00AA92E6 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; @@ -56,7 +47,6 @@ FDB52FD01F614A8B00AA92E6 /* ffi.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; FDB52FD11F614AA700AA92E6 /* ffi_arm64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA715E187F1D9B00A76262 /* ffi_arm64.h */; }; FDB52FD21F614AAB00AA92E6 /* ffi_armv7.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA715F187F1D9B00A76262 /* ffi_armv7.h */; }; - FDB52FD31F614AB000AA92E6 /* ffi_i386.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7160187F1D9B00A76262 /* ffi_i386.h */; }; FDB52FD41F614AB500AA92E6 /* ffi_x86_64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */; }; FDB52FD51F614AE200AA92E6 /* ffi.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; }; FDB52FD61F614AEA00AA92E6 /* ffi_arm64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA715E187F1D9B00A76262 /* ffi_arm64.h */; }; @@ -64,7 +54,6 @@ FDB52FD81F614B8700AA92E6 /* ffitarget.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; }; FDB52FD91F614B8E00AA92E6 /* ffitarget_arm64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */; }; FDB52FDA1F614B9300AA92E6 /* ffitarget_armv7.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */; }; - FDB52FDB1F614B9700AA92E6 /* ffitarget_i386.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */; }; FDB52FDD1F614BA900AA92E6 /* ffitarget_x86_64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */; }; FDB52FDE1F6155E300AA92E6 /* ffitarget.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; }; FDB52FDF1F6155EA00AA92E6 /* ffitarget_arm64.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */; }; @@ -76,9 +65,7 @@ FDDB2F411F5D66E200EF414E /* ffiw64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = FDDB2F3F1F5D666900EF414E /* ffiw64_x86_64.c */; }; FDDB2F461F5D691E00EF414E /* win64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = FDDB2F441F5D68C900EF414E /* win64_x86_64.S */; }; FDDB2F4A1F5D846400EF414E /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; }; - FDDB2F4B1F5D846400EF414E /* sysv_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* sysv_i386.S */; }; FDDB2F4C1F5D846400EF414E /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; }; - FDDB2F4D1F5D846400EF414E /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; }; FDDB2F4E1F5D846400EF414E /* ffiw64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = FDDB2F3F1F5D666900EF414E /* ffiw64_x86_64.c */; }; FDDB2F4F1F5D846400EF414E /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; }; FDDB2F501F5D846400EF414E /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; }; @@ -97,12 +84,10 @@ FDB52FD01F614A8B00AA92E6 /* ffi.h in CopyFiles */, FDB52FD11F614AA700AA92E6 /* ffi_arm64.h in CopyFiles */, FDB52FD21F614AAB00AA92E6 /* ffi_armv7.h in CopyFiles */, - FDB52FD31F614AB000AA92E6 /* ffi_i386.h in CopyFiles */, FDB52FD41F614AB500AA92E6 /* ffi_x86_64.h in CopyFiles */, FDB52FD81F614B8700AA92E6 /* ffitarget.h in CopyFiles */, FDB52FD91F614B8E00AA92E6 /* ffitarget_arm64.h in CopyFiles */, FDB52FDA1F614B9300AA92E6 /* ffitarget_armv7.h in CopyFiles */, - FDB52FDB1F614B9700AA92E6 /* ffitarget_i386.h in CopyFiles */, FDB52FDD1F614BA900AA92E6 /* ffitarget_x86_64.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; @@ -140,7 +125,6 @@ /* Begin PBXFileReference section */ 43B5D3F71D35473200D1E1FD /* ffiw64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffiw64_x86_64.c; sourceTree = ""; }; 43B5D3F91D3547CE00D1E1FD /* win64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = win64_x86_64.S; sourceTree = ""; }; - 43E9A5C51D352C1500926A8F /* sysv_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_i386.S; sourceTree = ""; }; 43E9A5C61D352C1500926A8F /* unix64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = unix64_x86_64.S; sourceTree = ""; }; 43E9A5DA1D35373600926A8F /* internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = internal.h; sourceTree = ""; }; 43E9A5DB1D35374400926A8F /* internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = internal.h; sourceTree = ""; }; @@ -159,32 +143,23 @@ DBFA7149187F1D8600A76262 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = types.c; sourceTree = ""; }; DBFA715E187F1D9B00A76262 /* ffi_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_arm64.h; sourceTree = ""; }; DBFA715F187F1D9B00A76262 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = ""; }; - DBFA7160187F1D9B00A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_arm64.h; sourceTree = ""; }; DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = ""; }; - DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm64.h; sourceTree = ""; }; DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = ""; }; - DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; DBFA716C187F1D9B00A76262 /* ffi_arm64.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.c; path = ffi_arm64.c; sourceTree = ""; }; DBFA716D187F1D9B00A76262 /* sysv_arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_arm64.S; sourceTree = ""; }; DBFA716F187F1D9B00A76262 /* ffi_armv7.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.c; path = ffi_armv7.c; sourceTree = ""; }; DBFA7170187F1D9B00A76262 /* sysv_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_armv7.S; sourceTree = ""; }; DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; - DBFA7176187F1D9B00A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; - DBFA7182187F1DA100A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = ""; }; DBFA7183187F1DA100A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = ""; }; - DBFA7184187F1DA100A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = ""; }; DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = ""; }; - DBFA7186187F1DA100A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = ""; }; DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = ""; }; DBFA718A187F1DA100A76262 /* unix64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = unix64_x86_64.S; sourceTree = ""; }; - DBFA718B187F1DA100A76262 /* sysv_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_i386.S; sourceTree = ""; }; DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = ""; }; - DBFA718D187F1DA100A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = ""; }; FDB52FC51F6144FA00AA92E6 /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; }; FDDB2F3E1F5D61BC00EF414E /* asmnames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asmnames.h; sourceTree = ""; }; FDDB2F3F1F5D666900EF414E /* ffiw64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffiw64_x86_64.c; sourceTree = ""; }; @@ -262,15 +237,12 @@ children = ( DBFA715E187F1D9B00A76262 /* ffi_arm64.h */, DBFA715F187F1D9B00A76262 /* ffi_armv7.h */, - DBFA7160187F1D9B00A76262 /* ffi_i386.h */, DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */, DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */, DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */, - DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */, DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */, DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */, DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */, - DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */, DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */, ); path = include; @@ -313,8 +285,6 @@ 43E9A5DD1D35375400926A8F /* internal64.h */, DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */, 43B5D3F71D35473200D1E1FD /* ffiw64_x86_64.c */, - DBFA7176187F1D9B00A76262 /* ffi_i386.c */, - 43E9A5C51D352C1500926A8F /* sysv_i386.S */, 43E9A5C61D352C1500926A8F /* unix64_x86_64.S */, 43B5D3F91D3547CE00D1E1FD /* win64_x86_64.S */, ); @@ -333,11 +303,8 @@ DBFA7181187F1DA100A76262 /* include */ = { isa = PBXGroup; children = ( - DBFA7182187F1DA100A76262 /* ffi_i386.h */, DBFA7183187F1DA100A76262 /* ffi_x86_64.h */, - DBFA7184187F1DA100A76262 /* fficonfig_i386.h */, DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */, - DBFA7186187F1DA100A76262 /* ffitarget_i386.h */, DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */, ); path = include; @@ -359,8 +326,6 @@ FDDB2F3E1F5D61BC00EF414E /* asmnames.h */, DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */, FDDB2F3F1F5D666900EF414E /* ffiw64_x86_64.c */, - DBFA718D187F1DA100A76262 /* ffi_i386.c */, - DBFA718B187F1DA100A76262 /* sysv_i386.S */, DBFA718A187F1DA100A76262 /* unix64_x86_64.S */, FDDB2F441F5D68C900EF414E /* win64_x86_64.S */, ); @@ -379,11 +344,8 @@ DBFA714A187F1D8600A76262 /* ffi.h in Headers */, DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */, DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */, - DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */, - DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */, DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */, DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */, - DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -549,14 +511,12 @@ buildActionMask = 2147483647; files = ( 43E9A5C81D352C1500926A8F /* unix64_x86_64.S in Sources */, - 43E9A5C71D352C1500926A8F /* sysv_i386.S in Sources */, DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */, DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */, DBFA714E187F1D8600A76262 /* closures.c in Sources */, DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */, 43B5D3F81D35473200D1E1FD /* ffiw64_x86_64.c in Sources */, DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */, - DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */, DBFA7158187F1D8600A76262 /* raw_api.c in Sources */, DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */, DBFA715A187F1D8600A76262 /* types.c in Sources */, @@ -570,9 +530,7 @@ buildActionMask = 2147483647; files = ( DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */, - DBFA7195187F1DA100A76262 /* sysv_i386.S in Sources */, DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */, - DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */, FDDB2F411F5D66E200EF414E /* ffiw64_x86_64.c in Sources */, DBFA715B187F1D8600A76262 /* types.c in Sources */, DBFA7159187F1D8600A76262 /* raw_api.c in Sources */, @@ -587,14 +545,12 @@ buildActionMask = 2147483647; files = ( FDB52FB31F6144FA00AA92E6 /* unix64_x86_64.S in Sources */, - FDB52FB41F6144FA00AA92E6 /* sysv_i386.S in Sources */, FDB52FB51F6144FA00AA92E6 /* ffi64_x86_64.c in Sources */, FDB52FB61F6144FA00AA92E6 /* ffi_armv7.c in Sources */, FDB52FB71F6144FA00AA92E6 /* closures.c in Sources */, FDB52FB81F6144FA00AA92E6 /* sysv_armv7.S in Sources */, FDB52FB91F6144FA00AA92E6 /* ffiw64_x86_64.c in Sources */, FDB52FBA1F6144FA00AA92E6 /* prep_cif.c in Sources */, - FDB52FBB1F6144FA00AA92E6 /* ffi_i386.c in Sources */, FDB52FBC1F6144FA00AA92E6 /* raw_api.c in Sources */, FDB52FBD1F6144FA00AA92E6 /* sysv_arm64.S in Sources */, FDB52FBE1F6144FA00AA92E6 /* types.c in Sources */, @@ -608,9 +564,7 @@ buildActionMask = 2147483647; files = ( FDDB2F4A1F5D846400EF414E /* ffi64_x86_64.c in Sources */, - FDDB2F4B1F5D846400EF414E /* sysv_i386.S in Sources */, FDDB2F4C1F5D846400EF414E /* prep_cif.c in Sources */, - FDDB2F4D1F5D846400EF414E /* ffi_i386.c in Sources */, FDDB2F4E1F5D846400EF414E /* ffiw64_x86_64.c in Sources */, FDDB2F4F1F5D846400EF414E /* types.c in Sources */, FDDB2F501F5D846400EF414E /* raw_api.c in Sources */, @@ -712,7 +666,7 @@ PRODUCT_NAME = ffi; SDKROOT = iphoneos; SKIP_INSTALL = YES; - VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; + VALID_ARCHS = "arm64 armv7 armv7s x86_64"; }; name = Debug; }; @@ -746,7 +700,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; VALIDATE_PRODUCT = YES; - VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; + VALID_ARCHS = "arm64 armv7 armv7s x86_64"; }; name = Release; }; From e50b9ef8b910fa642ef158f6642e60d54d7ad740 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 7 Dec 2019 02:34:14 -0800 Subject: [PATCH 115/231] powerpc64: Use memcpy to help platforms with no __int128. (#534) Signed-off-by: Khem Raj --- src/powerpc/ffi_linux64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/powerpc/ffi_linux64.c b/src/powerpc/ffi_linux64.c index 736477014..4d50878e4 100644 --- a/src/powerpc/ffi_linux64.c +++ b/src/powerpc/ffi_linux64.c @@ -680,9 +680,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack) { if (vecarg_count < NUM_VEC_ARG_REGISTERS64 && i < nfixedargs) - *vec_base.f128++ = *arg.f128++; + memcpy (vec_base.f128++, arg.f128, sizeof (float128)); else - *next_arg.f128 = *arg.f128++; + memcpy (next_arg.f128, arg.f128++, sizeof (float128)); if (++next_arg.f128 == gpr_end.f128) next_arg.f128 = rest.f128; vecarg_count++; @@ -986,9 +986,9 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif, do { if (pvec < end_pvec && i < nfixedargs) - *to.f128 = *pvec++; + memcpy (to.f128, pvec++, sizeof (float128)); else - *to.f128 = *from.f128; + memcpy (to.f128, from.f128, sizeof (float128)); to.f128++; from.f128++; } From 1e08a45535d929915e14e48af38e45f8c8e4f8de Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 5 Jan 2020 21:18:23 -0500 Subject: [PATCH 116/231] Use rlgl API key on login --- .travis/build.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index fc572fd75..c9d066844 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -19,7 +19,7 @@ function build_cfarm() echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: curl -u ${CFARM_AUTH} "$(tail build.log | grep '^==LOGFILE==' | cut -b13-)" > libffi.log - ./rlgl l https://rl.gl + ./rlgl l --key=$RLGL_KEY https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git libffi.log exit $? @@ -33,7 +33,7 @@ function build_linux() make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" - ./rlgl l https://rl.gl + ./rlgl l --key=$RLGL_KEY https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -43,7 +43,7 @@ function build_foreign_linux() { ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh - ./rlgl l https://rl.gl + ./rlgl l --key=$RLGL_KEY https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -53,7 +53,7 @@ function build_cross_linux() { ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh - ./rlgl l https://rl.gl + ./rlgl l --key=$RLGL_KEY https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -64,7 +64,7 @@ function build_cross() ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} ${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh - ./rlgl l https://rl.gl + ./rlgl l --key=$RLGL_KEY https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? From 81b5491a4ef46103f2e1be79d368e76dba021ffa Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 5 Jan 2020 21:37:05 -0500 Subject: [PATCH 117/231] Fix script --- .travis/build.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index c9d066844..d013818fb 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -19,7 +19,7 @@ function build_cfarm() echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: curl -u ${CFARM_AUTH} "$(tail build.log | grep '^==LOGFILE==' | cut -b13-)" > libffi.log - ./rlgl l --key=$RLGL_KEY https://rl.gl + ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git libffi.log exit $? @@ -33,7 +33,7 @@ function build_linux() make dist make check RUNTESTFLAGS="-a $RUNTESTFLAGS" - ./rlgl l --key=$RLGL_KEY https://rl.gl + ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -43,7 +43,7 @@ function build_foreign_linux() { ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh - ./rlgl l --key=$RLGL_KEY https://rl.gl + ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -53,7 +53,7 @@ function build_cross_linux() { ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh - ./rlgl l --key=$RLGL_KEY https://rl.gl + ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? @@ -64,7 +64,7 @@ function build_cross() ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} ${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh - ./rlgl l --key=$RLGL_KEY https://rl.gl + ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) ./rlgl e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git */testsuite/libffi.log exit $? From b844a9c7f1ca792a1dfb0c09d5dae576178e6729 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 10 Jan 2020 10:22:10 -0500 Subject: [PATCH 118/231] Update copyright year. --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index acb2f7a07..4f0b76251 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -libffi - Copyright (c) 1996-2019 Anthony Green, Red Hat, Inc and others. +libffi - Copyright (c) 1996-2020 Anthony Green, Red Hat, Inc and others. See source files for details. Permission is hereby granted, free of charge, to any person obtaining From 4d6d2866ae43e55325e8ee96561221804602cd7a Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Fri, 21 Feb 2020 21:06:15 -0600 Subject: [PATCH 119/231] Update powerpc sysv assembly for ffi_powerpc.h changes (#541) Some of the flag bits were moved when adding powerpc64 vector support. Fixes #536 --- src/powerpc/sysv.S | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/powerpc/sysv.S b/src/powerpc/sysv.S index 1474ce702..df9773427 100644 --- a/src/powerpc/sysv.S +++ b/src/powerpc/sysv.S @@ -104,17 +104,16 @@ ENTRY(ffi_call_SYSV) bctrl /* Now, deal with the return value. */ - mtcrf 0x01,%r31 /* cr7 */ + mtcrf 0x03,%r31 /* cr6-cr7 */ bt- 31,L(small_struct_return_value) bt- 30,L(done_return_value) #ifndef __NO_FPRS__ bt- 29,L(fp_return_value) #endif stw %r3,0(%r30) - bf+ 28,L(done_return_value) + bf+ 27,L(done_return_value) stw %r4,4(%r30) - mtcrf 0x02,%r31 /* cr6 */ - bf 27,L(done_return_value) + bf 26,L(done_return_value) stw %r5,8(%r30) stw %r6,12(%r30) /* Fall through... */ @@ -145,10 +144,9 @@ L(done_return_value): #ifndef __NO_FPRS__ L(fp_return_value): .cfi_restore_state - bf 28,L(float_return_value) + bf 27,L(float_return_value) stfd %f1,0(%r30) - mtcrf 0x02,%r31 /* cr6 */ - bf 27,L(done_return_value) + bf 26,L(done_return_value) stfd %f2,8(%r30) b L(done_return_value) L(float_return_value): From 7855656148b96c7070ec362d2a73af840025a2b7 Mon Sep 17 00:00:00 2001 From: hjl-tools Date: Fri, 21 Feb 2020 19:08:06 -0800 Subject: [PATCH 120/231] x86: Add indirect branch tracking support (#540) Intel Control-flow Enforcement Technology (CET): https://software.intel.com/en-us/articles/intel-sdm contains shadow stack (SHSTK) and indirect branch tracking (IBT). When CET is enabled, ELF object files must be marked with .note.gnu.property section. When Intel CET is enabled, include in assembly codes to mark Intel CET support. Also when IBT is enabled, all indirect branch targets must start with ENDBR instruction and notrack prefix can be used to disable IBT on indirect branch. defines _CET_ENDBR which can be used in assembly codes for ENDBR instruction. If isn't included, define _CET_ENDBR as empty so that _CET_ENDBR can be used in assembly codes. Trampoline must be enlarged to add ENDBR instruction unconditionally, which is NOP on non-CET processors. This is required regardless if libffi is enabled with CET since libffi.so will be marked in legacy bitmap, but trampoline won't. Update library version for larger FFI_TRAMPOLINE_SIZE. This fixed: https://github.com/libffi/libffi/issues/474 Tested with $ CC="gcc -Wl,-z,cet-report=error -fcf-protection" CXX="g++ -Wl,-z,cet-report=error -fcf-protection" .../configure on Linux CET machines in i686, x32 and x86-64 modes. --- Makefile.am | 3 ++- libtool-version | 2 +- src/x86/ffi.c | 11 ++++++--- src/x86/ffi64.c | 18 ++++++++------ src/x86/ffitarget.h | 17 +++++++++++-- src/x86/ffiw64.c | 18 ++++++++------ src/x86/sysv.S | 17 ++++++++++--- src/x86/unix64.S | 60 +++++++++++++++++++++++++++++++++++++++++++-- src/x86/win64.S | 5 +++- 9 files changed, 120 insertions(+), 31 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4fd6193d9..563e9f286 100644 --- a/Makefile.am +++ b/Makefile.am @@ -144,7 +144,8 @@ endif libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` libffi.map: $(top_srcdir)/libffi.map.in - $(COMPILE) -D$(TARGET) -E -x assembler-with-cpp -o $@ $< + $(COMPILE) -D$(TARGET) -DGENERATE_LIBFFI_MAP \ + -E -x assembler-with-cpp -o $@ $< libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) diff --git a/libtool-version b/libtool-version index e4f5aa20d..607fee558 100644 --- a/libtool-version +++ b/libtool-version @@ -26,4 +26,4 @@ # release, then set age to 0. # # CURRENT:REVISION:AGE -8:0:1 +9:0:1 diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 9a592185a..e24732204 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -557,13 +557,16 @@ ffi_prep_closure_loc (ffi_closure* closure, return FFI_BAD_ABI; } + /* endbr32. */ + *(UINT32 *) tramp = 0xfb1e0ff3; + /* movl or pushl immediate. */ - tramp[0] = op; - *(void **)(tramp + 1) = codeloc; + tramp[4] = op; + *(void **)(tramp + 5) = codeloc; /* jmp dest */ - tramp[5] = 0xe9; - *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10); + tramp[9] = 0xe9; + *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 10); closure->cif = cif; closure->fun = fun; diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index dec331c95..ed82e235f 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -728,13 +728,15 @@ ffi_prep_closure_loc (ffi_closure* closure, void *user_data, void *codeloc) { - static const unsigned char trampoline[16] = { - /* leaq -0x7(%rip),%r10 # 0x0 */ - 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, - /* jmpq *0x3(%rip) # 0x10 */ - 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, - /* nopl (%rax) */ - 0x0f, 0x1f, 0x00 + static const unsigned char trampoline[24] = { + /* endbr64 */ + 0xf3, 0x0f, 0x1e, 0xfa, + /* leaq -0xb(%rip),%r10 # 0x0 */ + 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff, + /* jmpq *0x7(%rip) # 0x18 */ + 0xff, 0x25, 0x07, 0x00, 0x00, 0x00, + /* nopl 0(%rax) */ + 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00 }; void (*dest)(void); char *tramp = closure->tramp; @@ -752,7 +754,7 @@ ffi_prep_closure_loc (ffi_closure* closure, dest = ffi_closure_unix64; memcpy (tramp, trampoline, sizeof(trampoline)); - *(UINT64 *)(tramp + 16) = (uintptr_t)dest; + *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest; closure->cif = cif; closure->fun = fun; diff --git a/src/x86/ffitarget.h b/src/x86/ffitarget.h index 85ccedfed..a34f3e5b7 100644 --- a/src/x86/ffitarget.h +++ b/src/x86/ffitarget.h @@ -136,12 +136,25 @@ typedef enum ffi_abi { #if defined (X86_64) || defined(X86_WIN64) \ || (defined (__x86_64__) && defined (X86_DARWIN)) -# define FFI_TRAMPOLINE_SIZE 24 +/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP + + 8 bytes of pointer. */ +# define FFI_TRAMPOLINE_SIZE 32 # define FFI_NATIVE_RAW_API 0 #else -# define FFI_TRAMPOLINE_SIZE 12 +/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused + bytes. */ +# define FFI_TRAMPOLINE_SIZE 16 # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ #endif +#if !defined(GENERATE_LIBFFI_MAP) && defined(__ASSEMBLER__) \ + && defined(__CET__) +# include +# define _CET_NOTRACK notrack +#else +# define _CET_ENDBR +# define _CET_NOTRACK +#endif + #endif diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index b68f69ccf..034dffda5 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -196,13 +196,15 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure, void *user_data, void *codeloc) { - static const unsigned char trampoline[16] = { - /* leaq -0x7(%rip),%r10 # 0x0 */ - 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff, - /* jmpq *0x3(%rip) # 0x10 */ - 0xff, 0x25, 0x03, 0x00, 0x00, 0x00, - /* nopl (%rax) */ - 0x0f, 0x1f, 0x00 + static const unsigned char trampoline[FFI_TRAMPOLINE_SIZE - 8] = { + /* endbr64 */ + 0xf3, 0x0f, 0x1e, 0xfa, + /* leaq -0xb(%rip),%r10 # 0x0 */ + 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff, + /* jmpq *0x7(%rip) # 0x18 */ + 0xff, 0x25, 0x07, 0x00, 0x00, 0x00, + /* nopl 0(%rax) */ + 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00 }; char *tramp = closure->tramp; @@ -216,7 +218,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure, } memcpy (tramp, trampoline, sizeof(trampoline)); - *(UINT64 *)(tramp + 16) = (uintptr_t)ffi_closure_win64; + *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64; closure->cif = cif; closure->fun = fun; diff --git a/src/x86/sysv.S b/src/x86/sysv.S index 7c9598c93..6d5648332 100644 --- a/src/x86/sysv.S +++ b/src/x86/sysv.S @@ -92,6 +92,7 @@ ffi_call_i386: L(UW0): # cfi_startproc + _CET_ENDBR #if !HAVE_FASTCALL movl 4(%esp), %ecx movl 8(%esp), %edx @@ -133,7 +134,7 @@ L(pc1): leal L(store_table)(,%ecx, 8), %ebx #endif movl 16(%ebp), %ecx /* load result address */ - jmp *%ebx + _CET_NOTRACK jmp *%ebx .balign 8 L(store_table): @@ -256,7 +257,7 @@ ENDF(ffi_call_i386) andl $X86_RET_TYPE_MASK, %eax; \ leal L(C1(load_table,N))(, %eax, 8), %edx; \ movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx + _CET_NOTRACK jmp *%edx #ifdef __PIC__ # if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE @@ -267,7 +268,7 @@ ENDF(ffi_call_i386) L(C1(pc,N)): \ leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \ movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx + _CET_NOTRACK jmp *%edx # else # define FFI_CLOSURE_CALL_INNER_SAVE_EBX # undef FFI_CLOSURE_CALL_INNER @@ -286,7 +287,7 @@ L(C1(UW,UWN)): \ L(C1(UW,UWN)): \ /* cfi_restore(%ebx); */ \ movl closure_CF(%esp), %eax; /* optimiztic load */ \ - jmp *%edx + _CET_NOTRACK jmp *%edx # endif /* DARWIN || HIDDEN */ #endif /* __PIC__ */ @@ -296,6 +297,7 @@ L(C1(UW,UWN)): \ C(ffi_go_closure_EAX): L(UW6): # cfi_startproc + _CET_ENDBR subl $closure_FS, %esp L(UW7): # cfi_def_cfa_offset(closure_FS + 4) @@ -316,6 +318,7 @@ ENDF(C(ffi_go_closure_EAX)) C(ffi_go_closure_ECX): L(UW9): # cfi_startproc + _CET_ENDBR subl $closure_FS, %esp L(UW10): # cfi_def_cfa_offset(closure_FS + 4) @@ -340,6 +343,7 @@ ENDF(C(ffi_go_closure_ECX)) C(ffi_closure_i386): L(UW12): # cfi_startproc + _CET_ENDBR subl $closure_FS, %esp L(UW13): # cfi_def_cfa_offset(closure_FS + 4) @@ -423,6 +427,7 @@ ENDF(C(ffi_closure_i386)) C(ffi_go_closure_STDCALL): L(UW21): # cfi_startproc + _CET_ENDBR subl $closure_FS, %esp L(UW22): # cfi_def_cfa_offset(closure_FS + 4) @@ -448,6 +453,7 @@ L(UW24): # cfi_startproc # cfi_def_cfa(%esp, 8) # cfi_offset(%eip, -8) + _CET_ENDBR subl $closure_FS-4, %esp L(UW25): # cfi_def_cfa_offset(closure_FS + 4) @@ -470,6 +476,7 @@ ENDF(C(ffi_closure_REGISTER)) C(ffi_closure_STDCALL): L(UW27): # cfi_startproc + _CET_ENDBR subl $closure_FS, %esp L(UW28): # cfi_def_cfa_offset(closure_FS + 4) @@ -576,6 +583,7 @@ ENDF(C(ffi_closure_STDCALL)) C(ffi_closure_raw_SYSV): L(UW32): # cfi_startproc + _CET_ENDBR subl $raw_closure_S_FS, %esp L(UW33): # cfi_def_cfa_offset(raw_closure_S_FS + 4) @@ -679,6 +687,7 @@ ENDF(C(ffi_closure_raw_SYSV)) C(ffi_closure_raw_THISCALL): L(UW41): # cfi_startproc + _CET_ENDBR /* Rearrange the stack such that %ecx is the first argument. This means moving the return address. */ popl %edx diff --git a/src/x86/unix64.S b/src/x86/unix64.S index 41563f5c6..ee3c04fdd 100644 --- a/src/x86/unix64.S +++ b/src/x86/unix64.S @@ -42,7 +42,11 @@ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) # define E(BASE, X) .balign 8 #else -# define E(BASE, X) .balign 8; .org BASE + X * 8 +# ifdef __CET__ +# define E(BASE, X) .balign 8; .org BASE + X * 16 +# else +# define E(BASE, X) .balign 8; .org BASE + X * 8 +# endif #endif /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, @@ -58,6 +62,7 @@ C(ffi_call_unix64): L(UW0): + _CET_ENDBR movq (%rsp), %r10 /* Load return address. */ leaq (%rdi, %rsi), %rax /* Find local stack base. */ movq %rdx, (%rax) /* Save flags. */ @@ -116,6 +121,11 @@ L(UW2): movzbl %cl, %r10d leaq L(store_table)(%rip), %r11 ja L(sa) +#ifdef __CET__ + /* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 + + 4 bytes NOP padding double slot size to 16 bytes. */ + addl %r10d, %r10d +#endif leaq (%r11, %r10, 8), %r10 /* Prep for the structure cases: scratch area in redzone. */ @@ -125,57 +135,73 @@ L(UW2): .balign 8 L(store_table): E(L(store_table), UNIX64_RET_VOID) + _CET_ENDBR ret E(L(store_table), UNIX64_RET_UINT8) + _CET_ENDBR movzbl %al, %eax movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_UINT16) + _CET_ENDBR movzwl %ax, %eax movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_UINT32) + _CET_ENDBR movl %eax, %eax movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_SINT8) + _CET_ENDBR movsbq %al, %rax movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_SINT16) + _CET_ENDBR movswq %ax, %rax movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_SINT32) + _CET_ENDBR cltq movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_INT64) + _CET_ENDBR movq %rax, (%rdi) ret E(L(store_table), UNIX64_RET_XMM32) + _CET_ENDBR movd %xmm0, (%rdi) ret E(L(store_table), UNIX64_RET_XMM64) + _CET_ENDBR movq %xmm0, (%rdi) ret E(L(store_table), UNIX64_RET_X87) + _CET_ENDBR fstpt (%rdi) ret E(L(store_table), UNIX64_RET_X87_2) + _CET_ENDBR fstpt (%rdi) fstpt 16(%rdi) ret E(L(store_table), UNIX64_RET_ST_XMM0_RAX) + _CET_ENDBR movq %rax, 8(%rsi) jmp L(s3) E(L(store_table), UNIX64_RET_ST_RAX_XMM0) + _CET_ENDBR movq %xmm0, 8(%rsi) jmp L(s2) E(L(store_table), UNIX64_RET_ST_XMM0_XMM1) + _CET_ENDBR movq %xmm1, 8(%rsi) jmp L(s3) E(L(store_table), UNIX64_RET_ST_RAX_RDX) + _CET_ENDBR movq %rdx, 8(%rsi) L(s2): movq %rax, (%rsi) @@ -227,6 +253,7 @@ ENDF(C(ffi_call_unix64)) C(ffi_closure_unix64_sse): L(UW5): + _CET_ENDBR subq $ffi_closure_FS, %rsp L(UW6): /* cfi_adjust_cfa_offset(ffi_closure_FS) */ @@ -250,6 +277,7 @@ ENDF(C(ffi_closure_unix64_sse)) C(ffi_closure_unix64): L(UW8): + _CET_ENDBR subq $ffi_closure_FS, %rsp L(UW9): /* cfi_adjust_cfa_offset(ffi_closure_FS) */ @@ -286,6 +314,11 @@ L(UW10): movzbl %al, %r10d leaq L(load_table)(%rip), %r11 ja L(la) +#ifdef __CET__ + /* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 + + 4 bytes NOP padding double slot size to 16 bytes. */ + addl %r10d, %r10d +#endif leaq (%r11, %r10, 8), %r10 leaq ffi_closure_RED_RVALUE(%rsp), %rsi jmp *%r10 @@ -293,51 +326,67 @@ L(UW10): .balign 8 L(load_table): E(L(load_table), UNIX64_RET_VOID) + _CET_ENDBR ret E(L(load_table), UNIX64_RET_UINT8) + _CET_ENDBR movzbl (%rsi), %eax ret E(L(load_table), UNIX64_RET_UINT16) + _CET_ENDBR movzwl (%rsi), %eax ret E(L(load_table), UNIX64_RET_UINT32) + _CET_ENDBR movl (%rsi), %eax ret E(L(load_table), UNIX64_RET_SINT8) + _CET_ENDBR movsbl (%rsi), %eax ret E(L(load_table), UNIX64_RET_SINT16) + _CET_ENDBR movswl (%rsi), %eax ret E(L(load_table), UNIX64_RET_SINT32) + _CET_ENDBR movl (%rsi), %eax ret E(L(load_table), UNIX64_RET_INT64) + _CET_ENDBR movq (%rsi), %rax ret E(L(load_table), UNIX64_RET_XMM32) + _CET_ENDBR movd (%rsi), %xmm0 ret E(L(load_table), UNIX64_RET_XMM64) + _CET_ENDBR movq (%rsi), %xmm0 ret E(L(load_table), UNIX64_RET_X87) + _CET_ENDBR fldt (%rsi) ret E(L(load_table), UNIX64_RET_X87_2) + _CET_ENDBR fldt 16(%rsi) fldt (%rsi) ret E(L(load_table), UNIX64_RET_ST_XMM0_RAX) + _CET_ENDBR movq 8(%rsi), %rax jmp L(l3) E(L(load_table), UNIX64_RET_ST_RAX_XMM0) + _CET_ENDBR movq 8(%rsi), %xmm0 jmp L(l2) E(L(load_table), UNIX64_RET_ST_XMM0_XMM1) + _CET_ENDBR movq 8(%rsi), %xmm1 jmp L(l3) E(L(load_table), UNIX64_RET_ST_RAX_RDX) + _CET_ENDBR movq 8(%rsi), %rdx L(l2): movq (%rsi), %rax @@ -358,6 +407,7 @@ ENDF(C(ffi_closure_unix64)) C(ffi_go_closure_unix64_sse): L(UW12): + _CET_ENDBR subq $ffi_closure_FS, %rsp L(UW13): /* cfi_adjust_cfa_offset(ffi_closure_FS) */ @@ -381,6 +431,7 @@ ENDF(C(ffi_go_closure_unix64_sse)) C(ffi_go_closure_unix64): L(UW15): + _CET_ENDBR subq $ffi_closure_FS, %rsp L(UW16): /* cfi_adjust_cfa_offset(ffi_closure_FS) */ @@ -424,7 +475,12 @@ EHFrame0: #endif /* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */ -#define ADV(N, P) .byte 2, L(N)-L(P) +#ifdef __CET__ +/* Use DW_CFA_advance_loc2 when IBT is enabled. */ +# define ADV(N, P) .byte 3; .2byte L(N)-L(P) +#else +# define ADV(N, P) .byte 2, L(N)-L(P) +#endif .balign 8 L(CIE): diff --git a/src/x86/win64.S b/src/x86/win64.S index 2c334c82f..57c0e656c 100644 --- a/src/x86/win64.S +++ b/src/x86/win64.S @@ -48,6 +48,7 @@ SEH(.seh_proc ffi_call_win64) C(ffi_call_win64): cfi_startproc + _CET_ENDBR /* Set up the local stack frame and install it in rbp/rsp. */ movq (%rsp), %rax movq %rbp, (arg1) @@ -80,7 +81,7 @@ C(ffi_call_win64): cmpl $FFI_TYPE_SMALL_STRUCT_4B, %ecx leaq (%r10, %rcx, 8), %r10 ja 99f - jmp *%r10 + _CET_NOTRACK jmp *%r10 /* Below, we're space constrained most of the time. Thus we eschew the modern "mov, pop, ret" sequence (5 bytes) for "leave, ret" (2 bytes). */ @@ -176,6 +177,7 @@ E(0b, FFI_TYPE_SMALL_STRUCT_4B) SEH(.seh_proc ffi_go_closure_win64) C(ffi_go_closure_win64): cfi_startproc + _CET_ENDBR /* Save all integer arguments into the incoming reg stack space. */ movq %rcx, 8(%rsp) movq %rdx, 16(%rsp) @@ -196,6 +198,7 @@ C(ffi_go_closure_win64): SEH(.seh_proc ffi_closure_win64) C(ffi_closure_win64): cfi_startproc + _CET_ENDBR /* Save all integer arguments into the incoming reg stack space. */ movq %rcx, 8(%rsp) movq %rdx, 16(%rsp) From 4c775d7cd6e914c6a2f66465497106cff360aeb5 Mon Sep 17 00:00:00 2001 From: Moxie Bot Date: Fri, 21 Feb 2020 22:12:34 -0500 Subject: [PATCH 121/231] Update for pending 3.4 release. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7f70902c..c917e8876 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.3 was released on November 23, 2019. Check the libffi web +libffi-3.4 was released on TBD. Check the libffi web page for updates: . @@ -196,6 +196,11 @@ History See the git log for details at http://github.com/libffi/libffi. + 3.4 TBD + Add support for Intel Control-flow Enforcement Technology (CET). + Fix 32-bit PPC regression. + Fix MIPS soft-float problem. + 3.3 Nov-23-19 Add RISC-V support. New API in support of GO closures. From d9abffeabe4f38bac12b864146cf974ede814411 Mon Sep 17 00:00:00 2001 From: hjl-tools Date: Sat, 22 Feb 2020 06:32:22 -0800 Subject: [PATCH 122/231] x86: Fix ffi_prep_closure_loc (#542) Since FFI_TRAMPOLINE_SIZE is increased by 4 bytes to add ENDBR32, adjust jump displacement by 4 bytes. --- src/x86/ffi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index e24732204..346e784e1 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -566,7 +566,7 @@ ffi_prep_closure_loc (ffi_closure* closure, /* jmp dest */ tramp[9] = 0xe9; - *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 10); + *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14); closure->cif = cif; closure->fun = fun; From be815544c1588c6ca70120361c168b196376aa56 Mon Sep 17 00:00:00 2001 From: hjl-tools Date: Sun, 23 Feb 2020 07:45:42 -0800 Subject: [PATCH 123/231] Update the ABI version to LIBFFI_BASE_8.0 (#544) Since x86 and x86-64 FFI_TRAMPOLINE_SIZE have been increased, we must bump the ABI version. This fixes: https://github.com/libffi/libffi/issues/543 --- libffi.map.in | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libffi.map.in b/libffi.map.in index 5553ab024..de8778ae4 100644 --- a/libffi.map.in +++ b/libffi.map.in @@ -6,7 +6,7 @@ /* These version numbers correspond to the libtool-version abi numbers, not to the libffi release numbers. */ -LIBFFI_BASE_7.0 { +LIBFFI_BASE_8.0 { global: /* Exported data variables. */ ffi_type_void; @@ -38,27 +38,23 @@ LIBFFI_BASE_7.0 { ffi_java_raw_to_ptrarray; ffi_java_raw_size; + ffi_get_struct_offsets; local: *; }; -LIBFFI_BASE_7.1 { - global: - ffi_get_struct_offsets; -} LIBFFI_BASE_7.0; - #ifdef FFI_TARGET_HAS_COMPLEX_TYPE -LIBFFI_COMPLEX_7.0 { +LIBFFI_COMPLEX_8.0 { global: /* Exported data variables. */ ffi_type_complex_float; ffi_type_complex_double; ffi_type_complex_longdouble; -} LIBFFI_BASE_7.0; +} LIBFFI_BASE_8.0; #endif #if FFI_CLOSURES -LIBFFI_CLOSURE_7.0 { +LIBFFI_CLOSURE_8.0 { global: ffi_closure_alloc; ffi_closure_free; @@ -68,13 +64,13 @@ LIBFFI_CLOSURE_7.0 { ffi_prep_raw_closure_loc; ffi_prep_java_raw_closure; ffi_prep_java_raw_closure_loc; -} LIBFFI_BASE_7.0; +} LIBFFI_BASE_8.0; #endif #if FFI_GO_CLOSURES -LIBFFI_GO_CLOSURE_7.0 { +LIBFFI_GO_CLOSURE_8.0 { global: ffi_call_go; ffi_prep_go_closure; -} LIBFFI_CLOSURE_7.0; +} LIBFFI_CLOSURE_8.0; #endif From 8eb2d2b05626b1cbbed100725bc440709499e8a6 Mon Sep 17 00:00:00 2001 From: Moxie Bot Date: Mon, 24 Feb 2020 10:29:20 -0500 Subject: [PATCH 124/231] Revamp PA_LINUX and PA_HPUX target closures to use function descriptors. 2020-02-23 John David Anglin * include/ffi.h.in (FFI_CLOSURE_PTR, FFI_RESTORE_PTR): Define. * src/closures.c (ffi_closure_alloc): Convert closure pointer return by malloc to function pointer. (ffi_closure_free): Convert function pointer back to malloc pointer. * src/pa/ffi.c (ffi_closure_inner_pa32): Use union to double word align return address on stack. Adjust statements referencing return address. Convert closure argument from function pointer to standard closure pointer. (ffi_prep_closure_loc): Likewise convert closure argument back to closure pointer. Remove assembler trampolines. Setup simulated function descriptor as on ia64. src/pa/ffitarget.h (FFI_TRAMPOLINE_SIZE): Reduce to 12. src/pa/hpux32.S (ffi_closure_pa32): Retrieve closure pointer and real gp from fake gp value in register %r19. src/pa/linux.S (ffi_closure_pa32): Likewise. --- include/ffi.h.in | 8 +++ src/closures.c | 8 +-- src/pa/ffi.c | 137 +++++++++++++++------------------------------ src/pa/ffitarget.h | 7 +-- src/pa/hpux32.S | 6 +- src/pa/linux.S | 6 +- 6 files changed, 67 insertions(+), 105 deletions(-) diff --git a/include/ffi.h.in b/include/ffi.h.in index 71cc05c9d..38885b0ab 100644 --- a/include/ffi.h.in +++ b/include/ffi.h.in @@ -330,6 +330,14 @@ typedef struct { FFI_API void *ffi_closure_alloc (size_t size, void **code); FFI_API void ffi_closure_free (void *); +#if defined(PA_LINUX) || defined(PA_HPUX) +#define FFI_CLOSURE_PTR(X) ((void *)((unsigned int)(X) | 2)) +#define FFI_RESTORE_PTR(X) ((void *)((unsigned int)(X) & ~3)) +#else +#define FFI_CLOSURE_PTR(X) (X) +#define FFI_RESTORE_PTR(X) (X) +#endif + FFI_API ffi_status ffi_prep_closure (ffi_closure*, ffi_cif *, diff --git a/src/closures.c b/src/closures.c index 512002165..047abcd6b 100644 --- a/src/closures.c +++ b/src/closures.c @@ -921,7 +921,7 @@ ffi_closure_alloc (size_t size, void **code) if (!code) return NULL; - ptr = dlmalloc (size); + ptr = FFI_CLOSURE_PTR (dlmalloc (size)); if (ptr) { @@ -961,7 +961,7 @@ ffi_closure_free (void *ptr) ptr = sub_segment_exec_offset (ptr, seg); #endif - dlfree (ptr); + dlfree (FFI_RESTORE_PTR (ptr)); } # else /* ! FFI_MMAP_EXEC_WRIT */ @@ -977,13 +977,13 @@ ffi_closure_alloc (size_t size, void **code) if (!code) return NULL; - return *code = malloc (size); + return *code = FFI_CLOSURE_PTR (malloc (size)); } void ffi_closure_free (void *ptr) { - free (ptr); + free (FFI_RESTORE_PTR (ptr)); } void * diff --git a/src/pa/ffi.c b/src/pa/ffi.c index 4ce2bc6f0..95e669473 100644 --- a/src/pa/ffi.c +++ b/src/pa/ffi.c @@ -421,12 +421,15 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) ffi_cif *cif; void **avalue; void *rvalue; - UINT32 ret[2]; /* function can return up to 64-bits in registers */ + /* Functions can return up to 64-bits in registers. Return address + must be double word aligned. */ + union { double rd; UINT32 ret[2]; } u; ffi_type **p_arg; char *tmp; int i, avn; unsigned int slot = FIRST_ARG_SLOT; register UINT32 r28 asm("r28"); + ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure); cif = closure->cif; @@ -434,7 +437,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) if (cif->flags == FFI_TYPE_STRUCT) rvalue = (void *)r28; else - rvalue = &ret[0]; + rvalue = &u; avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG); avn = cif->nargs; @@ -529,35 +532,35 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) } /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avalue, closure->user_data); + (c->fun) (cif, rvalue, avalue, c->user_data); - debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0], - ret[1]); + debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", u.ret[0], + u.ret[1]); /* Store the result using the lower 2 bytes of the flags. */ switch (cif->flags) { case FFI_TYPE_UINT8: - *(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24); + *(stack - FIRST_ARG_SLOT) = (UINT8)(u.ret[0] >> 24); break; case FFI_TYPE_SINT8: - *(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24); + *(stack - FIRST_ARG_SLOT) = (SINT8)(u.ret[0] >> 24); break; case FFI_TYPE_UINT16: - *(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16); + *(stack - FIRST_ARG_SLOT) = (UINT16)(u.ret[0] >> 16); break; case FFI_TYPE_SINT16: - *(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16); + *(stack - FIRST_ARG_SLOT) = (SINT16)(u.ret[0] >> 16); break; case FFI_TYPE_INT: case FFI_TYPE_SINT32: case FFI_TYPE_UINT32: - *(stack - FIRST_ARG_SLOT) = ret[0]; + *(stack - FIRST_ARG_SLOT) = u.ret[0]; break; case FFI_TYPE_SINT64: case FFI_TYPE_UINT64: - *(stack - FIRST_ARG_SLOT) = ret[0]; - *(stack - FIRST_ARG_SLOT - 1) = ret[1]; + *(stack - FIRST_ARG_SLOT) = u.ret[0]; + *(stack - FIRST_ARG_SLOT - 1) = u.ret[1]; break; case FFI_TYPE_DOUBLE: @@ -577,7 +580,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) case FFI_TYPE_SMALL_STRUCT4: tmp = (void*)(stack - FIRST_ARG_SLOT); tmp += 4 - cif->rtype->size; - memcpy((void*)tmp, &ret[0], cif->rtype->size); + memcpy((void*)tmp, &u, cif->rtype->size); break; case FFI_TYPE_SMALL_STRUCT5: @@ -598,7 +601,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) } memset (ret2, 0, sizeof (ret2)); - memcpy ((char *)ret2 + off, ret, 8 - off); + memcpy ((char *)ret2 + off, &u, 8 - off); *(stack - FIRST_ARG_SLOT) = ret2[0]; *(stack - FIRST_ARG_SLOT - 1) = ret2[1]; @@ -630,89 +633,41 @@ ffi_prep_closure_loc (ffi_closure* closure, void *user_data, void *codeloc) { - UINT32 *tramp = (UINT32 *)(closure->tramp); -#ifdef PA_HPUX - UINT32 *tmp; -#endif + ffi_closure *c = (ffi_closure *)FFI_RESTORE_PTR (closure); + + /* The layout of a function descriptor. A function pointer with the PLABEL + bit set points to a function descriptor. */ + struct pa32_fd + { + UINT32 code_pointer; + UINT32 gp; + }; + + struct ffi_pa32_trampoline_struct + { + UINT32 code_pointer; /* Pointer to ffi_closure_unix. */ + UINT32 fake_gp; /* Pointer to closure, installed as gp. */ + UINT32 real_gp; /* Real gp value. */ + }; + + struct ffi_pa32_trampoline_struct *tramp; + struct pa32_fd *fd; if (cif->abi != FFI_PA32) return FFI_BAD_ABI; - /* Make a small trampoline that will branch to our - handler function. Use PC-relative addressing. */ - -#ifdef PA_LINUX - tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ - tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ - tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */ - tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ - tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ - tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */ - tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ - tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2); - - /* Flush d/icache -- have to flush up 2 two lines because of - alignment. */ - __asm__ volatile( - "fdc 0(%0)\n\t" - "fdc %1(%0)\n\t" - "fic 0(%%sr4, %0)\n\t" - "fic %1(%%sr4, %0)\n\t" - "sync\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n" - : - : "r"((unsigned long)tramp & ~31), - "r"(32 /* stride */) - : "memory"); -#endif + /* Get function descriptor address for ffi_closure_pa32. */ + fd = (struct pa32_fd *)((UINT32)ffi_closure_pa32 & ~3); -#ifdef PA_HPUX - tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */ - tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */ - tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */ - tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */ - tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */ - tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */ - tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */ - tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */ - tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */ - tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2); - - /* Flush d/icache -- have to flush three lines because of alignment. */ - __asm__ volatile( - "copy %1,%0\n\t" - "fdc,m %2(%0)\n\t" - "fdc,m %2(%0)\n\t" - "fdc,m %2(%0)\n\t" - "ldsid (%1),%0\n\t" - "mtsp %0,%%sr0\n\t" - "copy %1,%0\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "fic,m %2(%%sr0,%0)\n\t" - "sync\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n\t" - "nop\n" - : "=&r" ((unsigned long)tmp) - : "r" ((unsigned long)tramp & ~31), - "r" (32/* stride */) - : "memory"); -#endif + /* Setup trampoline. */ + tramp = (struct ffi_pa32_trampoline_struct *)c->tramp; + tramp->code_pointer = fd->code_pointer; + tramp->fake_gp = (UINT32)codeloc & ~3; + tramp->real_gp = fd->gp; - closure->cif = cif; - closure->user_data = user_data; - closure->fun = fun; + c->cif = cif; + c->user_data = user_data; + c->fun = fun; return FFI_OK; } diff --git a/src/pa/ffitarget.h b/src/pa/ffitarget.h index fff4c6b38..df1209eb1 100644 --- a/src/pa/ffitarget.h +++ b/src/pa/ffitarget.h @@ -68,12 +68,7 @@ typedef enum ffi_abi { #define FFI_CLOSURES 1 #define FFI_NATIVE_RAW_API 0 - -#ifdef PA_LINUX -#define FFI_TRAMPOLINE_SIZE 32 -#else -#define FFI_TRAMPOLINE_SIZE 40 -#endif +#define FFI_TRAMPOLINE_SIZE 12 #define FFI_TYPE_SMALL_STRUCT2 -1 #define FFI_TYPE_SMALL_STRUCT3 -2 diff --git a/src/pa/hpux32.S b/src/pa/hpux32.S index 40528bad7..d0e5f6952 100644 --- a/src/pa/hpux32.S +++ b/src/pa/hpux32.S @@ -259,7 +259,7 @@ L$done L$FE1 /* void ffi_closure_pa32(void); - Called with closure argument in %r21 */ + Called with closure argument in %r19 */ .SPACE $TEXT$ .SUBSPA $CODE$ @@ -285,7 +285,9 @@ L$CFI22 stw %arg2, -44(%r3) stw %arg3, -48(%r3) - copy %r21, %arg0 + /* Retrieve closure pointer and real gp. */ + copy %r19, %arg0 + ldw 8(%r19), %r19 bl ffi_closure_inner_pa32, %r2 copy %r3, %arg1 ldwm -64(%sp), %r3 diff --git a/src/pa/linux.S b/src/pa/linux.S index ab04c75f4..33ef0b137 100644 --- a/src/pa/linux.S +++ b/src/pa/linux.S @@ -252,7 +252,7 @@ ffi_call_pa32: .LFE1: /* void ffi_closure_pa32(void); - Called with closure argument in %r21 */ + Called with closure argument in %r19 */ .export ffi_closure_pa32,code .import ffi_closure_inner_pa32,code @@ -277,7 +277,9 @@ ffi_closure_pa32: stw %arg2, -44(%r3) stw %arg3, -48(%r3) - copy %r21, %arg0 + /* Retrieve closure pointer and real gp. */ + copy %r19, %arg0 + ldw 8(%r19), %r19 bl ffi_closure_inner_pa32, %r2 copy %r3, %arg1 From 211e929df4388a6724b0dba4df4e3a1283dc49e9 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 9 Mar 2020 12:39:22 -0400 Subject: [PATCH 125/231] Try to fix RLGL_KEY nonsense (#547) * Try to fix RLGL_KEY nonsense * Hard code policy bound API key Co-authored-by: Anthony Green --- .travis/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index d013818fb..5f9a86e99 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -2,6 +2,10 @@ set -x +# This is a policy bound API key. It can only be used with +# https://github.com/libffi/rlgl-policy.git. +RLGL_KEY=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI + if [ -z ${QEMU_CPU+x} ]; then export SET_QEMU_CPU= else From 4c7bde32ea3af479babdf527d94f241282951cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Tue, 10 Mar 2020 02:05:42 +0100 Subject: [PATCH 126/231] Port to iOS/arm64e (#548) --- configure.ac | 22 ++++++++++++++++++++++ src/aarch64/ffi.c | 6 ++++++ src/aarch64/sysv.S | 15 +++++++++++++-- src/closures.c | 6 ++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b764368d6..bf9629727 100644 --- a/configure.ac +++ b/configure.ac @@ -176,6 +176,28 @@ case "$TARGET" in ;; esac +AC_CACHE_CHECK([whether compiler supports pointer authentication], + libffi_cv_as_ptrauth, [ + libffi_cv_as_ptrauth=unknown + AC_TRY_COMPILE(,[ +#ifdef __clang__ +# if __has_feature(ptrauth_calls) +# define HAVE_PTRAUTH 1 +# endif +#endif + +#ifndef HAVE_PTRAUTH +# error Pointer authentication not supported +#endif + ], + [libffi_cv_as_ptrauth=yes], + [libffi_cv_as_ptrauth=no]) +]) +if test "x$libffi_cv_as_ptrauth" = xyes; then + AC_DEFINE(HAVE_PTRAUTH, 1, + [Define if your compiler supports pointer authentication.]) +fi + # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. AC_ARG_ENABLE(pax_emutramp, [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC], diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index 1ebf43c19..4cc592508 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -62,6 +62,9 @@ struct call_context #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ +#ifdef HAVE_PTRAUTH +#include +#endif #include #endif @@ -789,6 +792,9 @@ ffi_prep_closure_loc (ffi_closure *closure, #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ +#ifdef HAVE_PTRAUTH + codeloc = ptrauth_strip (codeloc, ptrauth_key_asia); +#endif void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE); config[0] = closure; config[1] = start; diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S index 6761ee1ea..a345439ba 100644 --- a/src/aarch64/sysv.S +++ b/src/aarch64/sysv.S @@ -56,6 +56,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define PTR_SIZE 4 #else #define PTR_SIZE 8 +#endif + +#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH) +# define BR(r) braaz r +# define BLR(r) blraaz r +#else +# define BR(r) br r +# define BLR(r) blr r #endif .text @@ -111,7 +119,7 @@ CNAME(ffi_call_SYSV): /* Deallocate the context, leaving the stacked arguments. */ add sp, sp, #CALL_CONTEXT_SIZE - blr x9 /* call fn */ + BLR(x9) /* call fn */ ldp x3, x4, [x29, #16] /* reload rvalue and flags */ @@ -271,6 +279,9 @@ CNAME(ffi_closure_SYSV): bl CNAME(ffi_closure_SYSV_inner) /* Load the return value as directed. */ +#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH) + autiza x1 +#endif adr x1, 0f and w0, w0, #AARCH64_RET_MASK add x1, x1, x0, lsl #3 @@ -365,7 +376,7 @@ CNAME(ffi_closure_trampoline_table_page): .rept PAGE_MAX_SIZE / FFI_TRAMPOLINE_SIZE adr x16, -PAGE_MAX_SIZE ldp x17, x16, [x16] - br x16 + BR(x16) nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller that 16 bytes */ .endr diff --git a/src/closures.c b/src/closures.c index 047abcd6b..b5eb2bb0a 100644 --- a/src/closures.c +++ b/src/closures.c @@ -148,6 +148,9 @@ ffi_closure_free (void *ptr) #include #include +#ifdef HAVE_PTRAUTH +#include +#endif #include #include @@ -301,6 +304,9 @@ ffi_closure_alloc (size_t size, void **code) /* Initialize the return values */ *code = entry->trampoline; +#ifdef HAVE_PTRAUTH + *code = ptrauth_sign_unauthenticated (*code, ptrauth_key_asia, 0); +#endif closure->trampoline_table = table; closure->trampoline_table_entry = entry; From 909b37ffffe2a0bb08947b07508a3a4eed5f36a8 Mon Sep 17 00:00:00 2001 From: Moxie Bot Date: Mon, 9 Mar 2020 21:10:33 -0400 Subject: [PATCH 127/231] Test on aarch64 Linux with clang --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index bd908fdfd..8db2ddfb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,10 @@ matrix: - os: linux arch: arm64 env: HOST=aarch64-linux-gnu + - os: linux + arch: arm64 + env: HOST=aarch64-linux-gnu + compiler: clang - os: linux env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - os: linux From 4a6414f2785a60f455c91fdd04f7745fe7fc11e0 Mon Sep 17 00:00:00 2001 From: Moxie Bot Date: Mon, 9 Mar 2020 21:10:53 -0400 Subject: [PATCH 128/231] Mention ARM Pointer Authentication --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c917e8876..66c9186ff 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,7 @@ See the git log for details at http://github.com/libffi/libffi. 3.4 TBD Add support for Intel Control-flow Enforcement Technology (CET). + Add support for ARM Pointer Authentication (PA). Fix 32-bit PPC regression. Fix MIPS soft-float problem. From 8c50837f0b58ba5b2bcb1b424a2a4bfa01559fb2 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 10 Mar 2020 04:36:09 -0700 Subject: [PATCH 129/231] Improve read-write .eh_frame check (#546) llvm-objdump -h does not print BFD SEC_* constants like "READONLY", so the check will consider .eh_frame writable. clang 11 (since https://reviews.llvm.org/D73999) will error for mismatching section flags. Use readelf -S and check "WA" instead. --- configure.ac | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index bf9629727..3ca1f4fbb 100644 --- a/configure.ac +++ b/configure.ac @@ -262,17 +262,11 @@ fi if test "x$GCC" = "xyes"; then AC_CACHE_CHECK([whether .eh_frame section should be read-only], libffi_cv_ro_eh_frame, [ - libffi_cv_ro_eh_frame=no + libffi_cv_ro_eh_frame=yes echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then - objdump -h conftest.o > conftest.dump 2>&1 - libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1` - if test "x$libffi_eh_frame_line" != "x"; then - libffi_test_line=`expr $libffi_eh_frame_line + 1`p - sed -n $libffi_test_line conftest.dump > conftest.line - if grep READONLY conftest.line > /dev/null; then - libffi_cv_ro_eh_frame=yes - fi + if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then + libffi_cv_ro_eh_frame=no fi fi rm -f conftest.* From c06468fa6674d3783a0edb1d0fae9afc8bc28513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 26 Apr 2020 04:58:33 +0300 Subject: [PATCH 130/231] Fix building for aarch64 windows with mingw toolchains (#555) * aarch64: Check _WIN32 instead of _M_ARM64 for detecting windows This fixes building for aarch64 with mingw toolchains. _M_ARM64 is predefined by MSVC, while mingw compilers predefine __aarch64__. In aarch64 specific code, change checks for _M_ARM64 into checks for _WIN32. In arch independent code, check for (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32) instead of just _M_ARM64. In src/closures.c, coalesce checks like defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) into plain defined(_WIN32). Technically, this enables code for ARM32 windows where it wasn't, but as far as I can see it, those codepaths should be fine for that architecture variant as well. * aarch64: Only use armasm source when building with MSVC When building for windows/arm64 with clang, the normal gas style .S source works fine. sysv.S and win64_armasm.S seem to be functionally equivalent, with only differences being due to assembler syntax. --- configure.host | 10 ++++++++-- src/aarch64/ffi.c | 14 +++++++------- src/aarch64/ffitarget.h | 8 ++++---- src/closures.c | 12 ++++++------ src/prep_cif.c | 2 +- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/configure.host b/configure.host index 055e95566..7c951a0ff 100644 --- a/configure.host +++ b/configure.host @@ -8,7 +8,9 @@ case "${host}" in aarch64*-*-cygwin* | aarch64*-*-mingw* | aarch64*-*-win* ) TARGET=ARM_WIN64; TARGETDIR=aarch64 - MSVC=1 + if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then + MSVC=1 + fi ;; aarch64*-*-*) @@ -259,7 +261,11 @@ case "${TARGET}" in SOURCES="ffi.c sysv_msvc_arm32.S" ;; ARM_WIN64) - SOURCES="ffi.c win64_armasm.S" + if test "$MSVC" = 1; then + SOURCES="ffi.c win64_armasm.S" + else + SOURCES="ffi.c sysv.S" + fi ;; MIPS) SOURCES="ffi.c o32.S n32.S" diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index 4cc592508..508a62400 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include "internal.h" -#ifdef _M_ARM64 +#ifdef _WIN32 #include /* FlushInstructionCache */ #endif @@ -81,7 +81,7 @@ ffi_clear_cache (void *start, void *end) sys_icache_invalidate (start, (char *)end - (char *)start); #elif defined (__GNUC__) __builtin___clear_cache (start, end); -#elif defined (_M_ARM64) +#elif defined (_WIN32) FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start); #else #error "Missing builtin to flush instruction cache" @@ -668,7 +668,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, if (h) { int elems = 4 - (h & 3); -#ifdef _M_ARM64 /* for handling armasm calling convention */ +#ifdef _WIN32 /* for handling armasm calling convention */ if (cif->is_variadic) { if (state.ngrn + elems <= N_X_ARG_REG) @@ -693,7 +693,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, } state.nsrn = N_V_ARG_REG; dest = allocate_to_stack (&state, stack, ty->alignment, s); -#ifdef _M_ARM64 /* for handling armasm calling convention */ +#ifdef _WIN32 /* for handling armasm calling convention */ } #endif /* for handling armasm calling convention */ } @@ -814,7 +814,7 @@ ffi_prep_closure_loc (ffi_closure *closure, ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE); /* Also flush the cache for code mapping. */ -#ifdef _M_ARM64 +#ifdef _WIN32 // Not using dlmalloc.c for Windows ARM64 builds // so calling ffi_data_to_code_pointer() isn't necessary unsigned char *tramp_code = tramp; @@ -920,7 +920,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, if (h) { n = 4 - (h & 3); -#ifdef _M_ARM64 /* for handling armasm calling convention */ +#ifdef _WIN32 /* for handling armasm calling convention */ if (cif->is_variadic) { if (state.ngrn + n <= N_X_ARG_REG) @@ -960,7 +960,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, avalue[i] = allocate_to_stack(&state, stack, ty->alignment, s); } -#ifdef _M_ARM64 /* for handling armasm calling convention */ +#ifdef _WIN32 /* for handling armasm calling convention */ } #endif /* for handling armasm calling convention */ } diff --git a/src/aarch64/ffitarget.h b/src/aarch64/ffitarget.h index ecb6d2dea..7a8cabe80 100644 --- a/src/aarch64/ffitarget.h +++ b/src/aarch64/ffitarget.h @@ -32,7 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define FFI_SIZEOF_JAVA_RAW 4 typedef unsigned long long ffi_arg; typedef signed long long ffi_sarg; -#elif defined(_M_ARM64) +#elif defined(_WIN32) #define FFI_SIZEOF_ARG 8 typedef unsigned long long ffi_arg; typedef signed long long ffi_sarg; @@ -69,7 +69,7 @@ typedef enum ffi_abi #define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE #endif -#ifdef _M_ARM64 +#ifdef _WIN32 #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic #endif @@ -78,13 +78,13 @@ typedef enum ffi_abi #if defined (__APPLE__) #define FFI_TARGET_SPECIFIC_VARIADIC #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs -#elif !defined(_M_ARM64) +#elif !defined(_WIN32) /* iOS and Windows reserve x18 for the system. Disable Go closures until a new static chain is chosen. */ #define FFI_GO_CLOSURES 1 #endif -#ifndef _M_ARM64 +#ifndef _WIN32 /* No complex type on Windows */ #define FFI_TARGET_HAS_COMPLEX_TYPE #endif diff --git a/src/closures.c b/src/closures.c index b5eb2bb0a..4fe6158d8 100644 --- a/src/closures.c +++ b/src/closures.c @@ -123,7 +123,7 @@ ffi_closure_free (void *ptr) # define FFI_MMAP_EXEC_WRIT 1 # define HAVE_MNTENT 1 # endif -# if defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__) +# if defined(_WIN32) || defined(__OS2__) /* Windows systems may have Data Execution Protection (DEP) enabled, which requires the use of VirtualMalloc/VirtualFree to alloc/free executable memory. */ @@ -392,7 +392,7 @@ ffi_closure_free (void *ptr) #endif #include #include -#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(_M_ARM64) +#if !defined(_WIN32) #ifdef HAVE_MNTENT #include #endif /* HAVE_MNTENT */ @@ -518,11 +518,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED; static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; static void dlmalloc_stats(void) MAYBE_UNUSED; -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* Use these for mmap and munmap within dlmalloc.c. */ static void *dlmmap(void *, size_t, int, int, int, off_t); static int dlmunmap(void *, size_t); -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ #define mmap dlmmap #define munmap dlmunmap @@ -532,7 +532,7 @@ static int dlmunmap(void *, size_t); #undef mmap #undef munmap -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* A mutex used to synchronize access to *exec* variables in this file. */ static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -914,7 +914,7 @@ segment_holding_code (mstate m, char* addr) } #endif -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ /* Allocate a chunk of memory with the given size. Returns a pointer to the writable address, and sets *CODE to the executable diff --git a/src/prep_cif.c b/src/prep_cif.c index 06c654403..1db3804b2 100644 --- a/src/prep_cif.c +++ b/src/prep_cif.c @@ -129,7 +129,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, cif->rtype = rtype; cif->flags = 0; -#ifdef _M_ARM64 +#if (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32) cif->is_variadic = isvariadic; #endif #if HAVE_LONG_DOUBLE_VARIANT From 15d3ea31a53bd0e5b828c90a9f7c4285c58f73e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 26 Apr 2020 04:59:35 +0300 Subject: [PATCH 131/231] Use __builtin_ffs instead of ffs (#554) USE_BUILTIN_FFS is defined to 1 within __GNUC__, and the __builtin_ffs function is available since GCC 3.x at least, while the ffs function only exists on some OSes. This fixes compilation for non-x86 mingw platforms. For x86, USE_BUILTIN_FFS is explicitly disabled for windows targets - but if USE_BUILTIN_FFS is enabled based on __GNUC__, it should also use the builtin which actually is available correspondingly, not dependent on the target OS. --- src/dlmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dlmalloc.c b/src/dlmalloc.c index d63dd36dc..1aba657ed 100644 --- a/src/dlmalloc.c +++ b/src/dlmalloc.c @@ -2371,7 +2371,7 @@ static size_t traverse_and_check(mstate m); #else /* GNUC */ #if USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 +#define compute_bit2idx(X, I) I = __builtin_ffs(X)-1 #else /* USE_BUILTIN_FFS */ #define compute_bit2idx(X, I)\ From c543849c3767cc0f0a84e3ed7b664a63724ed516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 26 Apr 2020 05:01:03 +0300 Subject: [PATCH 132/231] win64_armasm: Fix the spelling of ALIGN (#553) --- src/aarch64/win64_armasm.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aarch64/win64_armasm.S b/src/aarch64/win64_armasm.S index a79f8a8aa..7fc185b3d 100644 --- a/src/aarch64/win64_armasm.S +++ b/src/aarch64/win64_armasm.S @@ -42,7 +42,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ EXPORT ffi_go_closure_SYSV #endif - TEXTAREA, ALLIGN=8 + TEXTAREA, ALIGN=8 /* ffi_call_SYSV extern void ffi_call_SYSV (void *stack, void *frame, From 053b04c525a00abdc25ec646096a44208a1b9423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 26 Apr 2020 05:02:14 +0300 Subject: [PATCH 133/231] arm: Fix the clang specific version of the assembly (#556) Also fix the same error in the comment for the non-clang case. That typo there seems to have existed since the code was written in that form, in e7f15f60e86 - and when the clang specific codepath was added in e3d2812ce43, the typo in the comment made it into the actual code. --- src/arm/sysv.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arm/sysv.S b/src/arm/sysv.S index 63180a463..74bc53fa2 100644 --- a/src/arm/sysv.S +++ b/src/arm/sysv.S @@ -129,11 +129,11 @@ ARM_FUNC_START(ffi_call_VFP) cmp r3, #3 @ load only d0 if possible #ifdef __clang__ - vldrle d0, [sp] - vldmgt sp, {d0-d7} + vldrle d0, [r0] + vldmgt r0, {d0-d7} #else - ldcle p11, cr0, [r0] @ vldrle d0, [sp] - ldcgt p11, cr0, [r0], {16} @ vldmgt sp, {d0-d7} + ldcle p11, cr0, [r0] @ vldrle d0, [r0] + ldcgt p11, cr0, [r0], {16} @ vldmgt r0, {d0-d7} #endif add r0, r0, #64 @ discard the vfp register args /* FALLTHRU */ From 4f9e20ac51ce13d46fed3c869e1deb6d9bb89444 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Fri, 1 May 2020 06:58:30 -0500 Subject: [PATCH 134/231] ffi_powerpc.h: fix build failure with powerpc7 (#561) This is a patch pulled down from the following: https://github.com/buildroot/buildroot/blob/78926f610b1411b03464152472fd430012deb9ac/package/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch This issue is being hit on OpenBMC code when pulling the latest libffi tag and building on a P8 ppc64le machine. I verified this patch fixes the issue we are seeing. Below is the original commit message: Sicne commit 73dd43afc8a447ba98ea02e9aad4c6898dc77fb0, build on powerpc7 fails on: In file included from ../src/powerpc/ffi.c:33:0: ../src/powerpc/ffi_powerpc.h:61:9: error: '_Float128' is not supported on this target typedef _Float128 float128; ^~~~~~~~~ Fix this build failure by checking for __HAVE_FLOAT128 before using _Float128, as _Float128 is enabled only on specific conditions, see output/host/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/floatn.h: /* Defined to 1 if the current compiler invocation provides a floating-point type with the IEEE 754 binary128 format, and this glibc includes corresponding *f128 interfaces for it. */ #if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \ && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH # define __HAVE_FLOAT128 1 #else # define __HAVE_FLOAT128 0 #endif Fixes: - http://autobuild.buildroot.org/results/5c9dd8fb3b6a128882b6250f197c80232d8a3b53 Signed-off-by: Fabrice Fontaine Signed-off-by: Andrew Geissler Co-authored-by: Fabrice Fontaine --- src/powerpc/ffi_powerpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powerpc/ffi_powerpc.h b/src/powerpc/ffi_powerpc.h index 8e2f2f0e7..960a5c422 100644 --- a/src/powerpc/ffi_powerpc.h +++ b/src/powerpc/ffi_powerpc.h @@ -57,7 +57,7 @@ typedef union double d; } ffi_dblfl; -#if defined(__FLOAT128_TYPE__) +#if defined(__FLOAT128_TYPE__) && defined(__HAVE_FLOAT128) typedef _Float128 float128; #elif defined(__FLOAT128__) typedef __float128 float128; From 5e6ca054148dfb4d78e6f79457d48b745f919def Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Fri, 1 May 2020 13:59:11 +0200 Subject: [PATCH 135/231] Add support for Kalray KVX architecture (#559) --- Makefile.am | 6 +- README.md | 1 + configure.host | 5 + src/kvx/asm.h | 5 + src/kvx/ffi.c | 273 ++++++++++++++++++++++++++++++++++++++++++++ src/kvx/ffitarget.h | 75 ++++++++++++ src/kvx/sysv.S | 127 +++++++++++++++++++++ 7 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 src/kvx/asm.h create mode 100644 src/kvx/ffi.c create mode 100644 src/kvx/ffitarget.h create mode 100644 src/kvx/sysv.S diff --git a/Makefile.am b/Makefile.am index 563e9f286..0e66ee97c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -74,7 +74,8 @@ noinst_HEADERS = \ src/vax/ffitarget.h \ src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h src/x86/asmnames.h \ src/xtensa/ffitarget.h \ - src/dlmalloc.c + src/dlmalloc.c \ + src/kvx/ffitarget.h EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \ src/aarch64/win64_armasm.S src/alpha/ffi.c src/alpha/osf.S \ @@ -102,7 +103,8 @@ EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \ src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \ src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \ src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \ - src/xtensa/ffi.c src/xtensa/sysv.S + src/xtensa/ffi.c src/xtensa/sysv.S \ + src/kvx/ffi.c src/kvx/sysv.S TARGET_OBJ = @TARGET_OBJ@ libffi_la_LIBADD = $(TARGET_OBJ) diff --git a/README.md b/README.md index 66c9186ff..4a2fa38cb 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ tested: | AVR32 | Linux | GCC | | Blackfin | uClinux | GCC | | HPPA | HPUX | GCC | +| KVX | Linux | GCC | | IA-64 | Linux | GCC | | M68K | FreeMiNT | GCC | | M68K | Linux | GCC | diff --git a/configure.host b/configure.host index 7c951a0ff..56c80365f 100644 --- a/configure.host +++ b/configure.host @@ -136,6 +136,11 @@ case "${host}" in SOURCES="ffi.c unix.S" ;; + kvx-*-*) + TARGET=KVX; TARGETDIR=kvx + SOURCES="ffi.c sysv.S" + ;; + m32r*-*-*) TARGET=M32R; TARGETDIR=m32r SOURCES="ffi.c sysv.S" diff --git a/src/kvx/asm.h b/src/kvx/asm.h new file mode 100644 index 000000000..4edba410d --- /dev/null +++ b/src/kvx/asm.h @@ -0,0 +1,5 @@ +/* args are passed on registers from r0 up to r11 => 12*8 bytes */ +#define REG_ARGS_SIZE (12*8) +#define KVX_REGISTER_SIZE (8) +#define KVX_ABI_SLOT_SIZE (KVX_REGISTER_SIZE) +#define KVX_ABI_MAX_AGGREGATE_IN_REG_SIZE (4*KVX_ABI_SLOT_SIZE) diff --git a/src/kvx/ffi.c b/src/kvx/ffi.c new file mode 100644 index 000000000..58f6aef5c --- /dev/null +++ b/src/kvx/ffi.c @@ -0,0 +1,273 @@ +/* Copyright (c) 2020 Kalray + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +``Software''), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#if defined(__kvx__) +#include +#include +#include +#include +#include +#include "ffi_common.h" +#include "asm.h" + +#define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) +#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) +#define KVX_ABI_STACK_ALIGNMENT (32) +#define KVX_ABI_STACK_ARG_ALIGNMENT (8) +#define max(a,b) ((a) > (b) ? (a) : (b)) + +#ifdef FFI_DEBUG +#define DEBUG_PRINT(...) do{ fprintf( stderr, __VA_ARGS__ ); } while(0) +#else +#define DEBUG_PRINT(...) +#endif + +struct ret_value { + unsigned long int r0; + unsigned long int r1; + unsigned long int r2; + unsigned long int r3; +}; + +extern struct ret_value ffi_call_SYSV(unsigned total_size, + unsigned size, + extended_cif *ecif, + unsigned *rvalue_addr, + void *fn, + unsigned int_ext_method); + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + cif->flags = cif->rtype->size; + return FFI_OK; +} + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments */ + +void *ffi_prep_args(char *stack, unsigned int arg_slots_size, extended_cif *ecif) +{ + char *stacktemp = stack; + char *current_arg_passed_by_value = stack + arg_slots_size; + int i, s; + ffi_type **arg; + int count = 0; + ffi_cif *cif = ecif->cif; + void **argv = ecif->avalue; + + arg = cif->arg_types; + + DEBUG_PRINT("stack: %p\n", stack); + DEBUG_PRINT("arg_slots_size: %u\n", arg_slots_size); + DEBUG_PRINT("current_arg_passed_by_value: %p\n", current_arg_passed_by_value); + DEBUG_PRINT("ecif: %p\n", ecif); + DEBUG_PRINT("ecif->avalue: %p\n", ecif->avalue); + + for (i = 0; i < cif->nargs; i++) { + + s = KVX_ABI_SLOT_SIZE; + switch((*arg)->type) { + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + case FFI_TYPE_FLOAT: + case FFI_TYPE_DOUBLE: + case FFI_TYPE_UINT64: + case FFI_TYPE_SINT64: + case FFI_TYPE_POINTER: + DEBUG_PRINT("INT64/32/16/8/FLOAT/DOUBLE or POINTER @%p\n", stack); + *(uint64_t *) stack = *(uint64_t *)(* argv); + break; + + case FFI_TYPE_COMPLEX: + if ((*arg)->size == 8) + *(_Complex float *) stack = *(_Complex float *)(* argv); + else if ((*arg)->size == 16) { + *(_Complex double *) stack = *(_Complex double *)(* argv); + s = 16; + } else + abort(); + break; + case FFI_TYPE_STRUCT: { + char *value; + unsigned int written_size = 0; + DEBUG_PRINT("struct by value @%p\n", stack); + if ((*arg)->size > KVX_ABI_MAX_AGGREGATE_IN_REG_SIZE) { + DEBUG_PRINT("big struct\n"); + *(uint64_t *) stack = (uintptr_t)current_arg_passed_by_value; + value = current_arg_passed_by_value; + current_arg_passed_by_value += (*arg)->size; + written_size = KVX_ABI_SLOT_SIZE; + } else { + value = stack; + written_size = (*arg)->size; + } + memcpy(value, *argv, (*arg)->size); + s = ALIGN(written_size, KVX_ABI_STACK_ARG_ALIGNMENT); + break; + } + default: + printf("Error: unsupported arg type %d\n", (*arg)->type); + abort(); + break; + + } + stack += s; + count += s; + argv++; + arg++; + } +#ifdef FFI_DEBUG + FFI_ASSERT(((intptr_t)(stacktemp + REG_ARGS_SIZE) & (KVX_ABI_STACK_ALIGNMENT-1)) == 0); +#endif + return stacktemp + REG_ARGS_SIZE; +} + +/* Perform machine dependent cif processing when we have a variadic function */ + +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, + unsigned int ntotalargs) +{ + cif->flags = cif->rtype->size; + return FFI_OK; +} + +static unsigned long handle_small_int_ext(kvx_intext_method *int_ext_method, + const ffi_type *rtype) +{ + switch (rtype->type) { + case FFI_TYPE_SINT8: + *int_ext_method = KVX_RET_SXBD; + return KVX_REGISTER_SIZE; + + case FFI_TYPE_SINT16: + *int_ext_method = KVX_RET_SXHD; + return KVX_REGISTER_SIZE; + + case FFI_TYPE_SINT32: + *int_ext_method = KVX_RET_SXWD; + return KVX_REGISTER_SIZE; + + case FFI_TYPE_UINT8: + *int_ext_method = KVX_RET_ZXBD; + return KVX_REGISTER_SIZE; + + case FFI_TYPE_UINT16: + *int_ext_method = KVX_RET_ZXHD; + return KVX_REGISTER_SIZE; + + case FFI_TYPE_UINT32: + *int_ext_method = KVX_RET_ZXWD; + return KVX_REGISTER_SIZE; + + default: + *int_ext_method = KVX_RET_NONE; + return rtype->size; + } +} + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + int i; + unsigned long int slot_fitting_args_size = 0; + unsigned long int total_size = 0; + unsigned long int big_struct_size = 0; + kvx_intext_method int_extension_method; + ffi_type **arg; + struct ret_value local_rvalue = {0}; + size_t wb_size; + + + /* Calculate size to allocate on stack */ + for (i = 0, arg = cif->arg_types; i < cif->nargs; i++, arg++) { + DEBUG_PRINT("argument %d, type %d, size %lu\n", i, (*arg)->type, (*arg)->size); + if (((*arg)->type == FFI_TYPE_STRUCT) || ((*arg)->type == FFI_TYPE_COMPLEX)) { + if ((*arg)->size <= KVX_ABI_MAX_AGGREGATE_IN_REG_SIZE) { + slot_fitting_args_size += ALIGN((*arg)->size, KVX_ABI_SLOT_SIZE); + } else { + slot_fitting_args_size += KVX_ABI_SLOT_SIZE; /* aggregate passed by reference */ + big_struct_size += ALIGN((*arg)->size, KVX_ABI_SLOT_SIZE); + } + } else if ((*arg)->size <= KVX_ABI_SLOT_SIZE) { + slot_fitting_args_size += KVX_ABI_SLOT_SIZE; + } else { + printf("Error: unsupported arg size %ld arg type %d\n", (*arg)->size, (*arg)->type); + abort(); /* should never happen? */ + } + } + + extended_cif ecif; + ecif.cif = cif; + ecif.avalue = avalue; + ecif.rvalue = rvalue; + + /* This implementation allocates anyway for all register based args */ + slot_fitting_args_size = max(slot_fitting_args_size, REG_ARGS_SIZE); + total_size = slot_fitting_args_size + big_struct_size; + total_size = ALIGN(total_size, KVX_ABI_STACK_ALIGNMENT); + + /* wb_size: write back size, the size we will need to write back to user + * provided buffer. In theory it should always be cif->flags which is + * cif->rtype->size. But libffi API mandates that for integral types + * of size <= system register size, then we *MUST* write back + * the size of system register size. + * in our case, if size <= 8 bytes we must write back 8 bytes. + * floats, complex and structs are not affected, only integrals. + */ + wb_size = handle_small_int_ext(&int_extension_method, cif->rtype); + + switch (cif->abi) { + case FFI_SYSV: + DEBUG_PRINT("total_size: %lu\n", total_size); + DEBUG_PRINT("slot fitting args size: %lu\n", slot_fitting_args_size); + DEBUG_PRINT("rvalue: %p\n", rvalue); + DEBUG_PRINT("fn: %p\n", fn); + DEBUG_PRINT("rsize: %u\n", cif->flags); + DEBUG_PRINT("wb_size: %u\n", wb_size); + DEBUG_PRINT("int_extension_method: %u\n", int_extension_method); + local_rvalue = ffi_call_SYSV(total_size, slot_fitting_args_size, + &ecif, rvalue, fn, int_extension_method); + if ((cif->flags <= KVX_ABI_MAX_AGGREGATE_IN_REG_SIZE) + && (cif->rtype->type != FFI_TYPE_VOID)) + memcpy(rvalue, &local_rvalue, wb_size); + break; + default: + abort(); + break; + } +} + +/* Closures not supported yet */ +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + return FFI_BAD_ABI; +} + +#endif /* (__kvx__) */ diff --git a/src/kvx/ffitarget.h b/src/kvx/ffitarget.h new file mode 100644 index 000000000..8df8735e3 --- /dev/null +++ b/src/kvx/ffitarget.h @@ -0,0 +1,75 @@ +/* ----------------------------------------------------------------------- + ffitarget.h - Copyright (c) 2020 Kalray + + KVX Target configuration macros + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#ifndef LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +/* ---- System specific configurations ----------------------------------- */ + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV +} ffi_abi; + +/* Those values are set depending on return type + * they are used in the assembly code in sysv.S + */ +typedef enum kvx_intext_method { + KVX_RET_NONE = 0, + KVX_RET_SXBD = 1, + KVX_RET_SXHD = 2, + KVX_RET_SXWD = 3, + KVX_RET_ZXBD = 4, + KVX_RET_ZXHD = 5, + KVX_RET_ZXWD = 6 +} kvx_intext_method; + +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +/* This is only to allow Python to compile + * but closures are not supported yet + */ +#define FFI_CLOSURES 1 +#define FFI_TRAMPOLINE_SIZE 0 + +#define FFI_NATIVE_RAW_API 0 +#define FFI_TARGET_SPECIFIC_VARIADIC 1 +#define FFI_TARGET_HAS_COMPLEX_TYPE + +#endif + diff --git a/src/kvx/sysv.S b/src/kvx/sysv.S new file mode 100644 index 000000000..952afc706 --- /dev/null +++ b/src/kvx/sysv.S @@ -0,0 +1,127 @@ +/* Copyright (c) 2020 Kalray + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +``Software''), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#if defined(__kvx__) +#define LIBFFI_ASM +#include +#include +#include +#include + +.text +.global ffi_call_SYSV +.type ffi_call_SYSV, @function +.type ffi_prep_args, @function +.align 8 + +/* ffi_call_SYSV + + r0: total size to allocate on stack + r1: size of arg slots + r2: extended cif structure, DO NOT REMOVE: it is used by ffi_prep_args() + r3: return value address + r4: function to call + r5: integer sign extension method to be used +*/ +ffi_call_SYSV: + addd $r12 = $r12, -64 + so (-32)[$r12] = $r20r21r22r23 + ;; + sd (0)[$r12] = $r24 + ;; + get $r23 = $ra + copyd $r20 = $r12 + sbfd $r12 = $r0, $r12 + ;; + copyd $r0 = $r12 + copyd $r21 = $r3 + copyd $r22 = $r4 + copyd $r24 = $r5 + call ffi_prep_args + ;; + lo $r8r9r10r11 = (64)[$r12] + ;; + lo $r4r5r6r7 = (32)[$r12] + ;; + lo $r0r1r2r3 = (0)[$r12] + copyd $r12 = $r0 + /* $r15 is the register used by the ABI to return big (>32 bytes) + * structs by value. + * It is also referred to as the "struct register" in the ABI. + */ + copyd $r15 = $r21 + icall $r22 + ;; + pcrel $r4 = @pcrel(.Ltable) + cb.deqz $r24 ? .Lend + ;; + addx8d $r24 = $r24, $r4 + ;; + igoto $r24 + ;; +.Ltable: +0: /* we should never arrive here */ + goto .Lerror + nop + ;; +1: /* Sign extend byte to double */ + sxbd $r0 = $r0 + goto .Lend + ;; +2: /* Sign extend half to double */ + sxhd $r0 = $r0 + goto .Lend + ;; +3: /* Sign extend word to double */ + sxwd $r0 = $r0 + goto .Lend + ;; +4: /* Zero extend byte to double */ + zxbd $r0 = $r0 + goto .Lend + ;; +5: /* Zero extend half to double */ + zxhd $r0 = $r0 + goto .Lend + ;; +6: /* Zero extend word to double */ + zxwd $r0 = $r0 + /* Fallthrough to .Lend */ + ;; +.Lend: + ld $r24 = (0)[$r12] + ;; + set $ra = $r23 + lo $r20r21r22r23 = (32)[$r20] + addd $r12 = $r20, 64 + ;; + ret + ;; +.Lerror: + errop + ;; + +#endif /* __kvx__ */ + +#if defined __ELF__ && defined __linux__ + .section .note.GNU-stack,"",%progbits +#endif + From 2e90bb5577ea1fe3bc1716954e790999bc3549f7 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 7 Jun 2020 14:31:06 -0400 Subject: [PATCH 136/231] Add gcc bug tests back --- testsuite/lib/libffi.exp | 24 ++++++++++++++++++++++-- testsuite/libffi.bhaible/test-call.c | 8 ++++---- testsuite/libffi.bhaible/test-callback.c | 4 ++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index c02adf953..d3c17db48 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -24,6 +24,11 @@ load_lib libgloss.exp load_gcc_lib target-libpath.exp load_gcc_lib wrapper.exp +proc check_effective_target_gccbug { } { + global has_gccbug + return $has_gccbug +} + # Return 1 if the target matches the effective target 'arg', 0 otherwise. # This can be used with any check_* proc that takes no argument and # returns only 1 or 0. It could be used with check_* procs that take @@ -477,6 +482,7 @@ proc libffi-dg-runtest { testcases default-extra-flags } { proc run-many-tests { testcases extra_flags } { global compiler_vendor + global has_gccbug global env switch $compiler_vendor { "clang" { @@ -538,8 +544,22 @@ proc run-many-tests { testcases extra_flags } { foreach opt $optimizations { foreach abi $abis { set options [concat $common $opt $abi] - verbose "Testing $testname, $options" 1 - dg-test $test $options "" + set has_gccbug false; + if { [string match $compiler_vendor "gnu"] \ + && [string match "*MSABI*" $abi] \ + && ( ( [string match "*DGTEST=57 *" $common] \ + && [string match "*call.c*" $testname] ) \ + || ( [string match "*DGTEST=54 *" $common] \ + && [string match "*callback*" $testname] ) \ + || [string match "*DGTEST=55 *" $common] \ + || [string match "*DGTEST=56 *" $common] ) } then { + if [libffi_feature_test "#if (__GNUC__ < 9) || ((__GNUC__ == 9) && (__GNUC_MINOR__ < 3))"] { + set has_gccbug true; + } + } + verbose "Testing $testname, $options" 1 + verbose "has_gccbug = $has_gccbug" 1 + dg-test $test $options "" } } } diff --git a/testsuite/libffi.bhaible/test-call.c b/testsuite/libffi.bhaible/test-call.c index 01a8a2157..cf9219e26 100644 --- a/testsuite/libffi.bhaible/test-call.c +++ b/testsuite/libffi.bhaible/test-call.c @@ -4,7 +4,7 @@ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,7 +16,7 @@ along with this program. If not, see . **/ -/* { dg-do run } */ +/* { dg-do run { xfail gccbug } } */ #include #include @@ -1220,7 +1220,7 @@ void } fprintf(out,"->{%g}\n",Fr.x); fflush(out); -#endif +#endif #if (!defined(DGTEST)) || DGTEST == 56 Dr = D_fDd(f1,D2,d3); fprintf(out,"->{%g}\n",Dr.x); @@ -1243,7 +1243,7 @@ void } fprintf(out,"->{%g}\n",Dr.x); fflush(out); -#endif +#endif #if (!defined(DGTEST)) || DGTEST == 57 Dr = D_Dfd(D1,f2,d3); fprintf(out,"->{%g}\n",Dr.x); diff --git a/testsuite/libffi.bhaible/test-callback.c b/testsuite/libffi.bhaible/test-callback.c index c2633c79b..0b16799d8 100644 --- a/testsuite/libffi.bhaible/test-callback.c +++ b/testsuite/libffi.bhaible/test-callback.c @@ -4,7 +4,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/* { dg-do run } */ +/* { dg-do run { xfail gccbug } } */ #include #include From 5c45c40c04f89cf67ade3fdfa99915ca5409e51a Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Thu, 11 Jun 2020 21:37:41 +0900 Subject: [PATCH 137/231] Fix Free software foundation address (#564) ref. https://www.fsf.org/about/contact/ --- .travis/bfin-sim.exp | 2 +- .travis/m32r-sim.exp | 2 +- .travis/moxie-sim.exp | 2 +- .travis/or1k-sim.exp | 2 +- .travis/powerpc-eabisim.exp | 2 +- .travis/wine-sim.exp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis/bfin-sim.exp b/.travis/bfin-sim.exp index 13cd0ff8e..b36d9f0a8 100644 --- a/.travis/bfin-sim.exp +++ b/.travis/bfin-sim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {bfin-elf} diff --git a/.travis/m32r-sim.exp b/.travis/m32r-sim.exp index b3341f223..c18123f28 100644 --- a/.travis/m32r-sim.exp +++ b/.travis/m32r-sim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {m32r-elf} diff --git a/.travis/moxie-sim.exp b/.travis/moxie-sim.exp index 3a6042ee4..32979ea6b 100644 --- a/.travis/moxie-sim.exp +++ b/.travis/moxie-sim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {moxie-elf} diff --git a/.travis/or1k-sim.exp b/.travis/or1k-sim.exp index 64e1444fe..3920413ee 100644 --- a/.travis/or1k-sim.exp +++ b/.travis/or1k-sim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {or1k-elf} diff --git a/.travis/powerpc-eabisim.exp b/.travis/powerpc-eabisim.exp index bdc438960..285fd4f6f 100644 --- a/.travis/powerpc-eabisim.exp +++ b/.travis/powerpc-eabisim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {powerpc-eabisim} diff --git a/.travis/wine-sim.exp b/.travis/wine-sim.exp index 8bdab6719..1ad603817 100644 --- a/.travis/wine-sim.exp +++ b/.travis/wine-sim.exp @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with DejaGnu; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, MA 02110, USA. # This is a list of toolchains that are supported on this board. set_board_info target_install {i686-w64-mingw32} From b7af8f47d5fff2957521dc269637c00b8a4b6c75 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Thu, 11 Jun 2020 14:38:59 +0200 Subject: [PATCH 138/231] Fixes macOS build on Python 3 (#563) The error was: ``` Traceback (most recent call last): File "_generate-darwin-source-and-headers.py", line 209, in generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx) File "_generate-darwin-source-and-headers.py", line 197, in generate_source_and_headers for header_name, tag_tuples in platform_headers.iteritems(): AttributeError: 'collections.defaultdict' object has no attribute 'iteritems' ``` --- generate-darwin-source-and-headers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py index b8c28e643..516464f52 100755 --- a/generate-darwin-source-and-headers.py +++ b/generate-darwin-source-and-headers.py @@ -186,7 +186,7 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): build_target(desktop64_platform, platform_headers) mkdir_p('darwin_common/include') - for header_name, tag_tuples in platform_headers.iteritems(): + for header_name, tag_tuples in platform_headers.items(): basename, suffix = os.path.splitext(header_name) with open(os.path.join('darwin_common/include', header_name), 'w') as header: for tag_tuple in tag_tuples: From 0027b072627aa9d3ada71c4374561966064ecd5a Mon Sep 17 00:00:00 2001 From: "M. Herdiansyah" Date: Thu, 11 Jun 2020 19:40:24 +0700 Subject: [PATCH 139/231] Makefile: increase compatibility with bmake (#551) --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 0e66ee97c..8b4026c86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -147,7 +147,7 @@ libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` libffi.map: $(top_srcdir)/libffi.map.in $(COMPILE) -D$(TARGET) -DGENERATE_LIBFFI_MAP \ - -E -x assembler-with-cpp -o $@ $< + -E -x assembler-with-cpp -o $@ $(top_srcdir)/libffi.map.in libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) From fbd1de85f6532f8a8f61abbd7892f8cb58b233d0 Mon Sep 17 00:00:00 2001 From: Ma Jun Date: Mon, 29 Jun 2020 08:02:20 -0400 Subject: [PATCH 140/231] Add support for csky --- Makefile.am | 102 +++++------ README.md | 3 + configure.host | 5 + src/csky/ffi.c | 395 +++++++++++++++++++++++++++++++++++++++++++ src/csky/ffitarget.h | 63 +++++++ src/csky/sysv.S | 371 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 882 insertions(+), 57 deletions(-) create mode 100644 src/csky/ffi.c create mode 100644 src/csky/ffitarget.h create mode 100644 src/csky/sysv.S diff --git a/Makefile.am b/Makefile.am index 8b4026c86..7654bf5ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,67 +44,55 @@ if FFI_DEBUG libffi_la_SOURCES += src/debug.c endif -noinst_HEADERS = \ - src/aarch64/ffitarget.h src/aarch64/internal.h \ +noinst_HEADERS = src/aarch64/ffitarget.h src/aarch64/internal.h \ src/alpha/ffitarget.h src/alpha/internal.h \ - src/arc/ffitarget.h \ - src/arm/ffitarget.h src/arm/internal.h \ - src/avr32/ffitarget.h \ - src/bfin/ffitarget.h \ - src/cris/ffitarget.h \ - src/frv/ffitarget.h \ + src/arc/ffitarget.h src/arm/ffitarget.h src/arm/internal.h \ + src/avr32/ffitarget.h src/bfin/ffitarget.h \ + src/cris/ffitarget.h src/csky/ffitarget.h src/frv/ffitarget.h \ src/ia64/ffitarget.h src/ia64/ia64_flags.h \ - src/m32r/ffitarget.h \ - src/m68k/ffitarget.h \ - src/m88k/ffitarget.h \ - src/metag/ffitarget.h \ - src/microblaze/ffitarget.h \ - src/mips/ffitarget.h \ - src/moxie/ffitarget.h \ - src/nios2/ffitarget.h \ - src/or1k/ffitarget.h \ - src/pa/ffitarget.h \ - src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \ - src/riscv/ffitarget.h \ - src/s390/ffitarget.h src/s390/internal.h \ - src/sh/ffitarget.h \ - src/sh64/ffitarget.h \ - src/sparc/ffitarget.h src/sparc/internal.h \ - src/tile/ffitarget.h \ - src/vax/ffitarget.h \ - src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h src/x86/asmnames.h \ - src/xtensa/ffitarget.h \ - src/dlmalloc.c \ + src/m32r/ffitarget.h src/m68k/ffitarget.h \ + src/m88k/ffitarget.h src/metag/ffitarget.h \ + src/microblaze/ffitarget.h src/mips/ffitarget.h \ + src/moxie/ffitarget.h src/nios2/ffitarget.h \ + src/or1k/ffitarget.h src/pa/ffitarget.h \ + src/powerpc/ffitarget.h src/powerpc/asm.h \ + src/powerpc/ffi_powerpc.h src/riscv/ffitarget.h \ + src/s390/ffitarget.h src/s390/internal.h src/sh/ffitarget.h \ + src/sh64/ffitarget.h src/sparc/ffitarget.h \ + src/sparc/internal.h src/tile/ffitarget.h src/vax/ffitarget.h \ + src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \ + src/x86/asmnames.h src/xtensa/ffitarget.h src/dlmalloc.c \ src/kvx/ffitarget.h -EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \ - src/aarch64/win64_armasm.S src/alpha/ffi.c src/alpha/osf.S \ - src/arc/ffi.c src/arc/arcompact.S src/arm/ffi.c \ - src/arm/sysv.S src/arm/ffi.c src/arm/sysv_msvc_arm32.S \ - src/avr32/ffi.c src/avr32/sysv.S src/bfin/ffi.c \ - src/bfin/sysv.S src/cris/ffi.c src/cris/sysv.S src/frv/ffi.c \ - src/frv/eabi.S src/ia64/ffi.c src/ia64/unix.S src/m32r/ffi.c \ - src/m32r/sysv.S src/m68k/ffi.c src/m68k/sysv.S src/m88k/ffi.c \ - src/m88k/obsd.S src/metag/ffi.c src/metag/sysv.S \ - src/microblaze/ffi.c src/microblaze/sysv.S src/mips/ffi.c \ - src/mips/o32.S src/mips/n32.S src/moxie/ffi.c \ - src/moxie/eabi.S src/nios2/ffi.c src/nios2/sysv.S \ - src/or1k/ffi.c src/or1k/sysv.S src/pa/ffi.c src/pa/linux.S \ - src/pa/hpux32.S src/powerpc/ffi.c src/powerpc/ffi_sysv.c \ - src/powerpc/ffi_linux64.c src/powerpc/sysv.S \ - src/powerpc/linux64.S src/powerpc/linux64_closure.S \ - src/powerpc/ppc_closure.S src/powerpc/aix.S \ - src/powerpc/darwin.S src/powerpc/aix_closure.S \ - src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ - src/riscv/ffi.c src/riscv/sysv.S src/s390/ffi.c \ - src/s390/sysv.S src/sh/ffi.c src/sh/sysv.S src/sh64/ffi.c \ - src/sh64/sysv.S src/sparc/ffi.c src/sparc/ffi64.c \ - src/sparc/v8.S src/sparc/v9.S src/tile/ffi.c src/tile/tile.S \ - src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \ - src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \ - src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \ - src/xtensa/ffi.c src/xtensa/sysv.S \ - src/kvx/ffi.c src/kvx/sysv.S +EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \ + src/aarch64/win64_armasm.S src/alpha/ffi.c src/alpha/osf.S \ + src/arc/ffi.c src/arc/arcompact.S src/arm/ffi.c \ + src/arm/sysv.S src/arm/ffi.c src/arm/sysv_msvc_arm32.S \ + src/avr32/ffi.c src/avr32/sysv.S src/bfin/ffi.c \ + src/bfin/sysv.S src/cris/ffi.c src/cris/sysv.S src/frv/ffi.c \ + src/csky/ffi.c src/csky/sysv.S src/frv/eabi.S src/ia64/ffi.c \ + src/ia64/unix.S src/m32r/ffi.c src/m32r/sysv.S src/m68k/ffi.c \ + src/m68k/sysv.S src/m88k/ffi.c src/m88k/obsd.S \ + src/metag/ffi.c src/metag/sysv.S src/microblaze/ffi.c \ + src/microblaze/sysv.S src/mips/ffi.c src/mips/o32.S \ + src/mips/n32.S src/moxie/ffi.c src/moxie/eabi.S \ + src/nios2/ffi.c src/nios2/sysv.S src/or1k/ffi.c \ + src/or1k/sysv.S src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ + src/powerpc/ffi.c src/powerpc/ffi_sysv.c \ + src/powerpc/ffi_linux64.c src/powerpc/sysv.S \ + src/powerpc/linux64.S src/powerpc/linux64_closure.S \ + src/powerpc/ppc_closure.S src/powerpc/aix.S \ + src/powerpc/darwin.S src/powerpc/aix_closure.S \ + src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ + src/riscv/ffi.c src/riscv/sysv.S src/s390/ffi.c \ + src/s390/sysv.S src/sh/ffi.c src/sh/sysv.S src/sh64/ffi.c \ + src/sh64/sysv.S src/sparc/ffi.c src/sparc/ffi64.c \ + src/sparc/v8.S src/sparc/v9.S src/tile/ffi.c src/tile/tile.S \ + src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \ + src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \ + src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \ + src/xtensa/ffi.c src/xtensa/sysv.S src/kvx/ffi.c \ + src/kvx/sysv.S TARGET_OBJ = @TARGET_OBJ@ libffi_la_LIBADD = $(TARGET_OBJ) diff --git a/README.md b/README.md index 4a2fa38cb..4225d8534 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ tested: | ARM | Windows | MSVC | | AVR32 | Linux | GCC | | Blackfin | uClinux | GCC | +| CSKY | Linux | GCC | | HPPA | HPUX | GCC | | KVX | Linux | GCC | | IA-64 | Linux | GCC | @@ -198,6 +199,7 @@ History See the git log for details at http://github.com/libffi/libffi. 3.4 TBD + Add support for Alibaba's CSKY architecture. Add support for Intel Control-flow Enforcement Technology (CET). Add support for ARM Pointer Authentication (PA). Fix 32-bit PPC regression. @@ -435,6 +437,7 @@ developers: avr32 Bradley Smith blackfin Alexandre Keunecke I. de Mendonca cris Simon Posnjak, Hans-Peter Nilsson + csky Ma Jun, Zhang Wenmeng frv Anthony Green ia64 Hans Boehm m32r Kazuhiro Inaoka diff --git a/configure.host b/configure.host index 56c80365f..398c3b554 100644 --- a/configure.host +++ b/configure.host @@ -55,6 +55,11 @@ case "${host}" in SOURCES="ffi.c sysv.S" ;; + csky-*-*) + TARGET=CSKY; TARGETDIR=csky + SOURCES="ffi.c sysv.S" + ;; + frv-*-*) TARGET=FRV; TARGETDIR=frv SOURCES="ffi.c eabi.S" diff --git a/src/csky/ffi.c b/src/csky/ffi.c new file mode 100644 index 000000000..af50b7c64 --- /dev/null +++ b/src/csky/ffi.c @@ -0,0 +1,395 @@ +/* ----------------------------------------------------------------------- + ffi.c + + CSKY Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#include +#include + +#include + +/* ffi_prep_args is called by the assembly routine once stack space + has been allocated for the function's arguments +*/ +void ffi_prep_args(char *stack, extended_cif *ecif) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { + *(void **) argp = ecif->rvalue; + argp += 4; + } + + p_argv = ecif->avalue; + + for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; + (i != 0); + i--, p_arg++) + { + size_t z; + size_t alignment; + + /* Align if necessary */ + alignment = (*p_arg)->alignment; +#ifdef __CSKYABIV1__ + /* + * Adapt ABIV1 bug. + * If struct's size is larger than 8 bytes, then it always alignment as 4 bytes. + */ + if (((*p_arg)->type == FFI_TYPE_STRUCT) && ((*p_arg)->size > 8) && (alignment == 8)) { + alignment = 4; + } +#endif + + if ((alignment - 1) & (unsigned) argp) { + argp = (char *) FFI_ALIGN(argp, alignment); + } + + if ((*p_arg)->type == FFI_TYPE_STRUCT) + argp = (char *) FFI_ALIGN(argp, 4); + + z = (*p_arg)->size; + if (z < sizeof(int)) + { + z = sizeof(int); + switch ((*p_arg)->type) + { + case FFI_TYPE_SINT8: + *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); + break; + + case FFI_TYPE_UINT8: + *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); + break; + + case FFI_TYPE_SINT16: + *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); + break; + + case FFI_TYPE_UINT16: + *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); + break; + + case FFI_TYPE_STRUCT: +#ifdef __CSKYBE__ + memcpy((argp + 4 - (*p_arg)->size), *p_argv, (*p_arg)->size); +#else + memcpy(argp, *p_argv, (*p_arg)->size); +#endif + break; + + default: + FFI_ASSERT(0); + } + } + else if (z == sizeof(int)) + { + *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); + } + else + { + memcpy(argp, *p_argv, z); + } + p_argv++; + argp += z; + } + + return; +} + +/* Perform machine dependent cif processing */ +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + /* Round the stack up to a multiple of 8 bytes. This isn't needed + everywhere, but it is on some platforms, and it doesn't hcsky anything + when it isn't needed. */ + cif->bytes = (cif->bytes + 7) & ~7; + + /* Set the return type flag */ + switch (cif->rtype->type) + { + + case FFI_TYPE_DOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + cif->flags = (unsigned) FFI_TYPE_SINT64; + break; + + case FFI_TYPE_STRUCT: + if (cif->rtype->size <= 4) + /* A Composite Type not larger than 4 bytes is returned in r0. */ + cif->flags = (unsigned)FFI_TYPE_INT; + else if (cif->rtype->size <= 8) + /* A Composite Type not larger than 8 bytes is returned in r0, r1. */ + cif->flags = (unsigned)FFI_TYPE_SINT64; + else + /* A Composite Type larger than 8 bytes, or whose size cannot + be determined statically ... is stored in memory at an + address passed [in r0]. */ + cif->flags = (unsigned)FFI_TYPE_STRUCT; + break; + + default: + cif->flags = FFI_TYPE_INT; + break; + } + + return FFI_OK; +} + +/* Perform machine dependent cif processing for variadic calls */ +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, + unsigned int nfixedargs, + unsigned int ntotalargs) +{ + return ffi_prep_cif_machdep(cif); +} + +/* Prototypes for assembly functions, in sysv.S */ +extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *); + +void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + extended_cif ecif; + + int small_struct = (cif->flags == FFI_TYPE_INT + && cif->rtype->type == FFI_TYPE_STRUCT); + + ecif.cif = cif; + ecif.avalue = avalue; + + unsigned int temp; + + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + + if ((rvalue == NULL) && + (cif->flags == FFI_TYPE_STRUCT)) + { + ecif.rvalue = alloca(cif->rtype->size); + } + else if (small_struct) + ecif.rvalue = &temp; + else + ecif.rvalue = rvalue; + + switch (cif->abi) + { + case FFI_SYSV: + ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); + break; + + default: + FFI_ASSERT(0); + break; + } + if (small_struct) +#ifdef __CSKYBE__ + memcpy (rvalue, ((unsigned char *)&temp + (4 - cif->rtype->size)), cif->rtype->size); +#else + memcpy (rvalue, &temp, cif->rtype->size); +#endif +} + +/** private members **/ + +static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, + void** args, ffi_cif* cif); + +void ffi_closure_SYSV (ffi_closure *); + +/* This function is jumped to by the trampoline */ + +unsigned int +ffi_closure_SYSV_inner (closure, respp, args) + ffi_closure *closure; + void **respp; + void *args; +{ + // our various things... + ffi_cif *cif; + void **arg_area; + + cif = closure->cif; + arg_area = (void**) alloca (cif->nargs * sizeof (void*)); + + /* this call will initialize ARG_AREA, such that each + * element in that array points to the corresponding + * value on the stack; and if the function returns + * a structure, it will re-set RESP to point to the + * structure return address. */ + + ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); + + (closure->fun) (cif, *respp, arg_area, closure->user_data); + +#ifdef __CSKYBE__ + if (cif->flags == FFI_TYPE_INT && cif->rtype->type == FFI_TYPE_STRUCT) { + unsigned int tmp = 0; + tmp = *(unsigned int *)(*respp); + *(unsigned int *)(*respp) = (tmp >> ((4 - cif->rtype->size) * 8)); + } +#endif + + return cif->flags; +} + + +static void +ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, + void **avalue, ffi_cif *cif) +{ + register unsigned int i; + register void **p_argv; + register char *argp; + register ffi_type **p_arg; + + argp = stack; + + if ( cif->flags == FFI_TYPE_STRUCT ) { + *rvalue = *(void **) argp; + argp += 4; + } + + p_argv = avalue; + + for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) + { + size_t z; + size_t alignment; + + alignment = (*p_arg)->alignment; + if (alignment < 4) + alignment = 4; + +#ifdef __CSKYABIV1__ + /* + * Adapt ABIV1 bug. + * If struct's size is larger than 8 bytes, then it always alignment as 4 bytes. + */ + if (((*p_arg)->type == FFI_TYPE_STRUCT) && ((*p_arg)->size > 8) && (alignment == 8)) { + alignment = 4; + } +#endif + + /* Align if necessary */ + if ((alignment - 1) & (unsigned) argp) { + argp = (char *) FFI_ALIGN(argp, alignment); + } + + z = (*p_arg)->size; + +#ifdef __CSKYBE__ + unsigned int tmp = 0; + if ((*p_arg)->size < 4) { + tmp = *(unsigned int *)argp; + memcpy(argp, ((unsigned char *)&tmp + (4 - (*p_arg)->size)), (*p_arg)->size); + } +#else + /* because we're little endian, this is what it turns into. */ +#endif + *p_argv = (void*) argp; + + p_argv++; + argp += z; + } + + return; +} + +/* How to make a trampoline. */ + +extern unsigned char ffi_csky_trampoline[TRAMPOLINE_SIZE]; + +/* + * Since there is no __clear_cache in libgcc in csky toolchain. + * define ffi_csky_cacheflush in sysv.S. + * void ffi_csky_cacheflush(uint32 start_addr, uint32 size, int cache) + */ +#define CACHEFLUSH_IN_FFI 1 +#if CACHEFLUSH_IN_FFI +extern void ffi_csky_cacheflush(unsigned char *__tramp, unsigned int k, + int i); +#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ +({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned char *insns = (unsigned char *)(CTX); \ + memcpy (__tramp, ffi_csky_trampoline, TRAMPOLINE_SIZE); \ + *(unsigned int*) &__tramp[TRAMPOLINE_SIZE] = __ctx; \ + *(unsigned int*) &__tramp[TRAMPOLINE_SIZE + 4] = __fun; \ + ffi_csky_cacheflush(&__tramp[0], TRAMPOLINE_SIZE, 3); /* Clear data mapping. */ \ + ffi_csky_cacheflush(insns, TRAMPOLINE_SIZE, 3); \ + /* Clear instruction \ + mapping. */ \ + }) +#else +#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ +({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned char *insns = (unsigned char *)(CTX); \ + memcpy (__tramp, ffi_csky_trampoline, TRAMPOLINE_SIZE); \ + *(unsigned int*) &__tramp[TRAMPOLINE_SIZE] = __ctx; \ + *(unsigned int*) &__tramp[TRAMPOLINE_SIZE + 4] = __fun; \ + __clear_cache((&__tramp[0]), (&__tramp[TRAMPOLINE_SIZE-1])); /* Clear data mapping. */ \ + __clear_cache(insns, insns + TRAMPOLINE_SIZE); \ + /* Clear instruction \ + mapping. */ \ + }) +#endif + +/* the cif must already be prep'ed */ + +ffi_status +ffi_prep_closure_loc (ffi_closure* closure, + ffi_cif* cif, + void (*fun)(ffi_cif*,void*,void**,void*), + void *user_data, + void *codeloc) +{ + void (*closure_func)(ffi_closure*) = NULL; + + if (cif->abi == FFI_SYSV) + closure_func = &ffi_closure_SYSV; + else + return FFI_BAD_ABI; + + FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ + closure_func, \ + codeloc); + + closure->cif = cif; + closure->user_data = user_data; + closure->fun = fun; + + return FFI_OK; +} + + diff --git a/src/csky/ffitarget.h b/src/csky/ffitarget.h new file mode 100644 index 000000000..f770aac66 --- /dev/null +++ b/src/csky/ffitarget.h @@ -0,0 +1,63 @@ +/* -----------------------------------------------------------------*-C-*- + ffitarget.h - Copyright (c) 2012 Anthony Green + Copyright (c) 2010 CodeSourcery + Copyright (c) 1996-2003 Red Hat, Inc. + + Target configuration macros for CSKY. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + ----------------------------------------------------------------------- */ + +#ifndef LIBFFI_TARGET_H +#define LIBFFI_TARGET_H + +#ifndef LIBFFI_H +#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." +#endif + +#ifndef LIBFFI_ASM +typedef unsigned long ffi_arg; +typedef signed long ffi_sarg; + +typedef enum ffi_abi { + FFI_FIRST_ABI = 0, + FFI_SYSV, + FFI_LAST_ABI, + FFI_DEFAULT_ABI = FFI_SYSV, +} ffi_abi; +#endif + +#ifdef __CSKYABIV2__ +#define FFI_ASM_ARGREG_SIZE 16 +#define TRAMPOLINE_SIZE 16 +#define FFI_TRAMPOLINE_SIZE 24 +#else +#define FFI_ASM_ARGREG_SIZE 24 +#define TRAMPOLINE_SIZE 20 +#define FFI_TRAMPOLINE_SIZE 28 +#endif + +/* ---- Definitions for closures ----------------------------------------- */ + +#define FFI_CLOSURES 1 +#define FFI_NATIVE_RAW_API 0 +#endif diff --git a/src/csky/sysv.S b/src/csky/sysv.S new file mode 100644 index 000000000..21670bfd3 --- /dev/null +++ b/src/csky/sysv.S @@ -0,0 +1,371 @@ +/* ----------------------------------------------------------------------- + sysv.S + + CSKY Foreign Function Interface + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#define LIBFFI_ASM +#include +#include + +.macro CSKY_FUNC_START name + .text + .align 2 + .globl \name + .type \name, @function + \name: +.endm + +#ifdef __CSKYABIV2__ + + /* + * a0: fn + * a1: &ecif + * a2: cif->bytes + * a3: fig->flags + * sp+0: ecif.rvalue + */ +CSKY_FUNC_START ffi_call_SYSV + /* Save registers */ + .cfi_startproc + subi sp, 28 + .cfi_def_cfa_offset 28 + stw a0, (sp, 0x0) + .cfi_offset 0, -28 + stw a1, (sp, 0x4) + .cfi_offset 1, -24 + stw a2, (sp, 0x8) + .cfi_offset 2, -20 + stw a3, (sp, 0xC) + .cfi_offset 3, -16 + stw l0, (sp, 0x10) + .cfi_offset 4, -12 + stw l1, (sp, 0x14) + .cfi_offset 5, -8 + stw lr, (sp, 0x18) + .cfi_offset 15, -4 + + mov l0, sp + .cfi_def_cfa_register 4 + + /* Make room for all of the new args. */ + subu sp, sp, a2 + + /* Place all of the ffi_prep_args in position */ + mov a0, sp + /* a1 already set */ + + /* Call ffi_prep_args(stack, &ecif) */ + jsri ffi_prep_args + + /* move first 4 parameters in registers */ + ldw a0, (sp, 0x0) + ldw a1, (sp, 0x4) + ldw a2, (sp, 0x8) + ldw a3, (sp, 0xC) + + /* and adjust stack */ + subu lr, l0, sp /* cif->bytes == l0 - sp */ + cmphsi lr, 16 + movi l1, 16 + movt lr, l1 + addu sp, sp, lr + + ldw l1, (l0, 0) /* load fn() in advance */ + + /* call (fn) (...) */ + jsr l1 + + /* Remove the space we pushed for the args */ + mov sp, l0 + + /* Load r2 with the pointer to storage for the return value */ + ldw a2, (sp, 0x1C) + + /* Load r3 with the return type code */ + ldw a3, (sp, 0xC) + + /* If the return value pointer is NULL, assume no return value. */ + cmpnei a2, 0 + bf .Lepilogue + + cmpnei a3, FFI_TYPE_STRUCT + bf .Lepilogue + + /* return INT64 */ + cmpnei a3, FFI_TYPE_SINT64 + bt .Lretint + /* stw a0, (a2, 0x0) at .Lretint */ + stw a1, (a2, 0x4) + +.Lretint: + /* return INT */ + stw a0, (a2, 0x0) + +.Lepilogue: + ldw a0, (sp, 0x0) + ldw a1, (sp, 0x4) + ldw a2, (sp, 0x8) + ldw a3, (sp, 0xC) + ldw l0, (sp, 0x10) + ldw l1, (sp, 0x14) + ldw lr, (sp, 0x18) + addi sp, sp, 28 + rts + .cfi_endproc + .size ffi_call_SYSV, .-ffi_call_SYSV + + + /* + * unsigned int FFI_HIDDEN + * ffi_closure_SYSV_inner (closure, respp, args) + * ffi_closure *closure; + * void **respp; + * void *args; + */ +CSKY_FUNC_START ffi_closure_SYSV + .cfi_startproc + mov a2, sp + addi a1, sp, 16 + subi sp, sp, 24 + .cfi_def_cfa_offset 40 + stw a1, (sp, 0x10) + .cfi_offset 1, -24 + stw lr, (sp, 0x14) + .cfi_offset 15, -20 + stw sp, (sp, 0x8) + addi a1, sp, 8 + jsri ffi_closure_SYSV_inner + ldw a0, (sp, 0x0) + /* + * if FFI_TYPE_SINT64, need a1. + * if FFI_TYPE_INT, ignore a1. + */ + ldw a1, (sp, 0x4) + + ldw lr, (sp, 0x14) + addi sp, sp, 40 + rts + .cfi_endproc + .size ffi_closure_SYSV, .-ffi_closure_SYSV + +CSKY_FUNC_START ffi_csky_trampoline + subi sp, sp, 16 + stw a0, (sp, 0x0) + stw a1, (sp, 0x4) + stw a2, (sp, 0x8) + stw a3, (sp, 0xC) + lrw a0, [.Lctx] + lrw a1, [.Lfun] + jmp a1 +.Lctx: + mov a0, a0 + mov a0, a0 +.Lfun: + + .size ffi_csky_trampoline, .-ffi_csky_trampoline + +CSKY_FUNC_START ffi_csky_cacheflush + mov t0, r7 + movi r7, 123 + trap 0 + mov r7, t0 + rts + + .size ffi_csky_cacheflush, .-ffi_csky_cacheflush + +#else /* !__CSKYABIV2__ */ + + /* + * a0: fn + * a1: &ecif + * a2: cif->bytes + * a3: fig->flags + * a4: ecif.rvalue + */ +CSKY_FUNC_START ffi_call_SYSV + /* Save registers */ + .cfi_startproc + subi sp, 32 + subi sp, 8 + .cfi_def_cfa_offset 40 + stw a0, (sp, 0x0) + .cfi_offset 2, -40 + stw a1, (sp, 0x4) + .cfi_offset 3, -36 + stw a2, (sp, 0x8) + .cfi_offset 4, -32 + stw a3, (sp, 0xC) + .cfi_offset 5, -28 + stw a4, (sp, 0x10) + .cfi_offset 6, -24 + stw a5, (sp, 0x14) + .cfi_offset 7, -20 + stw l0, (sp, 0x18) + .cfi_offset 8, -16 + stw l1, (sp, 0x1C) + .cfi_offset 9, -12 + stw lr, (sp, 0x20) + .cfi_offset 15, -8 + + mov l0, sp + .cfi_def_cfa_register 8 + + /* Make room for all of the new args. */ + subu sp, sp, a2 + + /* Place all of the ffi_prep_args in position */ + mov a0, sp + /* a1 already set */ + + /* Call ffi_prep_args(stack, &ecif) */ + jsri ffi_prep_args + + /* move first 4 parameters in registers */ + ldw a0, (sp, 0x0) + ldw a1, (sp, 0x4) + ldw a2, (sp, 0x8) + ldw a3, (sp, 0xC) + ldw a4, (sp, 0x10) + ldw a5, (sp, 0x14) + + /* and adjust stack */ + mov lr, l0 + subu lr, sp /* cif->bytes == l0 - sp */ + movi l1, 24 + cmphs lr, l1 + movt lr, l1 + addu sp, sp, lr + + ldw l1, (l0, 0) /* load fn() in advance */ + + /* call (fn) (...) */ + jsr l1 + + /* Remove the space we pushed for the args */ + mov sp, l0 + + /* Load r2 with the pointer to storage for the return value */ + ldw a2, (sp, 0x10) + + /* Load r3 with the return type code */ + ldw a3, (sp, 0xC) + + /* If the return value pointer is NULL, assume no return value. */ + cmpnei a2, 0 + bf .Lepilogue + + cmpnei a3, FFI_TYPE_STRUCT + bf .Lepilogue + + /* return INT64 */ + cmpnei a3, FFI_TYPE_SINT64 + bt .Lretint + /* stw a0, (a2, 0x0) at .Lretint */ + stw a1, (a2, 0x4) + +.Lretint: + /* return INT */ + stw a0, (a2, 0x0) + +.Lepilogue: + ldw a0, (sp, 0x0) + ldw a1, (sp, 0x4) + ldw a2, (sp, 0x8) + ldw a3, (sp, 0xC) + ldw a4, (sp, 0x10) + ldw a5, (sp, 0x14) + ldw l0, (sp, 0x18) + ldw l1, (sp, 0x1C) + ldw lr, (sp, 0x20) + addi sp, sp, 32 + addi sp, sp, 8 + rts + .cfi_endproc + + .size ffi_call_SYSV, .-ffi_call_SYSV + + + /* + * unsigned int FFI_HIDDEN + * ffi_closure_SYSV_inner (closure, respp, args) + * ffi_closure *closure; + * void **respp; + * void *args; + */ +CSKY_FUNC_START ffi_closure_SYSV + .cfi_startproc + mov a2, sp + mov a1, sp + addi a1, 24 + subi sp, sp, 24 + .cfi_def_cfa_offset 48 + stw a1, (sp, 0x10) + .cfi_offset 3, -32 + stw lr, (sp, 0x14) + .cfi_offset 15, -28 + stw sp, (sp, 0x8) + mov a1, sp + addi a1, 8 + jsri ffi_closure_SYSV_inner + ldw a0, (sp, 0x0) + /* + * if FFI_TYPE_SINT64, need a1. + * if FFI_TYPE_INT, ignore a1. + */ + ldw a1, (sp, 0x4) + + ldw lr, (sp, 0x14) + addi sp, sp, 24 + addi sp, sp, 24 + rts + .cfi_endproc + + .size ffi_closure_SYSV, .-ffi_closure_SYSV + +CSKY_FUNC_START ffi_csky_trampoline + subi sp, 24 + stw a0, (sp, 0x0) + stw a1, (sp, 0x4) + stw a2, (sp, 0x8) + stw a3, (sp, 0xC) + stw a4, (sp, 0x10) + stw a5, (sp, 0x14) + lrw a0, [.Lctx] + lrw a1, [.Lfun] + jmp a1 +.Lctx: + mov a0, a0 + mov a0, a0 +.Lfun: + + .size ffi_csky_trampoline, .-ffi_csky_trampoline + +CSKY_FUNC_START ffi_csky_cacheflush + lrw r1, 123 + trap 0 + rts + + .size ffi_csky_cacheflush, .-ffi_csky_cacheflush + +#endif /* __CSKYABIV2__ */ From 8e58f88d33eb878b0fbca1433f83bbf872d5d0f3 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Tue, 30 Jun 2020 22:59:28 +0200 Subject: [PATCH 141/231] aarch64: Fix typo --- src/aarch64/sysv.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S index a345439ba..b720a92e1 100644 --- a/src/aarch64/sysv.S +++ b/src/aarch64/sysv.S @@ -377,7 +377,7 @@ CNAME(ffi_closure_trampoline_table_page): adr x16, -PAGE_MAX_SIZE ldp x17, x16, [x16] BR(x16) - nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller that 16 bytes */ + nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller than 16 bytes */ .endr .globl CNAME(ffi_closure_trampoline_table_page) From 1a4b786df34b61af7b6738a2ce7b8d34f5377a71 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 4 Aug 2020 12:17:04 -0400 Subject: [PATCH 142/231] update config.{guess,sub} This change is primarily for aarch64 macOS support, since that configuration is now properly supported upstream. --- config.guess | 883 ++++++++++------- config.sub | 2627 +++++++++++++++++++++++++------------------------- 2 files changed, 1873 insertions(+), 1637 deletions(-) diff --git a/config.guess b/config.guess index faa63aa94..e94095c5f 100644 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2017-05-11' +timestamp='2020-07-12' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2017-05-11' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2017-05-11' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,34 +94,40 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -132,14 +136,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc @@ -149,13 +153,20 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -169,30 +180,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -208,10 +219,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -219,45 +230,60 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in @@ -310,28 +336,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -343,7 +360,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -370,19 +387,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. @@ -395,13 +412,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -410,25 +427,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -439,44 +456,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -485,23 +502,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -527,17 +544,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -554,7 +571,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -566,14 +583,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -584,7 +601,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -598,7 +615,7 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -607,18 +624,18 @@ EOF IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -633,28 +650,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -687,13 +704,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -712,15 +729,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -745,11 +762,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -758,7 +775,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -766,9 +783,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -793,131 +810,123 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -928,140 +937,178 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + set_cc_for_build + LIBCABI=$LIBC + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1075,34 +1122,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1112,12 +1159,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1127,9 +1174,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1149,9 +1196,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1171,9 +1218,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1182,28 +1229,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1214,7 +1261,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1234,23 +1281,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1269,60 +1316,71 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + arm64:Darwin:*:*) + echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` @@ -1330,22 +1388,25 @@ EOF UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1354,18 +1415,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. + # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1386,14 +1448,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1402,32 +1464,190 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.sub b/config.sub index 40ea5dfe1..3d9a8dc3d 100644 --- a/config.sub +++ b/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2017-04-02' +timestamp='2020-07-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2017-04-02' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2017-04-02' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -57,7 +57,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1252 +110,1167 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola + cpu=m68k + vendor=motorola ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + cpu=m68000 + vendor=convergent ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + cpu=m68k + vendor=tti ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=pn + vendor=gould ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + cpu=romp + vendor=ibm ;; sde) - basic_machine=mipsisa32-sde - os=-elf + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sei) - basic_machine=mips-sei - os=-seiux + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sequent) - basic_machine=i386-sequent + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sh) - basic_machine=sh-hitachi - os=-hms + w65) + cpu=w65 + vendor=wdc ;; - sh5el) - basic_machine=sh5le-unknown + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh64) - basic_machine=sh64-unknown + none) + cpu=none + vendor=none ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - spur) - basic_machine=spur-unknown + + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv64 \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1363,203 +1278,215 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$basic_os != x ] then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'` + ;; + nto-qnx*) + kernel=nto + os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1572,264 +1499,352 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; pru-*) - os=-elf + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-abi", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-libc" + eabi | eabihf | gnueabi | gnueabihf) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + nto-qnx*) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" From e08eb1ced18598a26cd7f14fea05693e89638ed2 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 5 Aug 2020 17:59:59 -0400 Subject: [PATCH 143/231] Add support for eabisim back. This was removed upstream. --- config.sub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.sub b/config.sub index 3d9a8dc3d..14b5150c4 100644 --- a/config.sub +++ b/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2020 Free Software Foundation, Inc. -timestamp='2020-07-10' +timestamp='2020-08-05' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -1687,7 +1687,7 @@ case $os in musl* | newlib* | uclibc*) ;; # Likewise for "kernel-libc" - eabi | eabihf | gnueabi | gnueabihf) + eabi | eabisim | eabihf | gnueabi | gnueabihf) ;; # Now accept the basic system types. # The portable systems comes first. From 392afbaf60663e530bd740da0b5a39ee9f4ba052 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 5 Aug 2020 21:38:51 -0400 Subject: [PATCH 144/231] Don't test s390. Travis-ci is broken. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8db2ddfb2..8dfa0c2fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,9 @@ matrix: env: HOST=alpha-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - - os: linux - arch: s390x - env: HOST=s390x-linux-gnu +# - os: linux +# arch: s390x +# env: HOST=s390x-linux-gnu - os: linux arch: ppc64le env: HOST=ppc64le-linux-gnu From 8276f812a99b10d1f2c387dbd6ef2ca4f597c733 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Fri, 7 Aug 2020 21:05:23 +0200 Subject: [PATCH 145/231] Upstream local FreeBSD patches (#567) * Add support for FreeBSD mips Add support for FreeBSD mips, this has been a local patch in the FreeBSD ports tree for quite some time. Originally submitted by sson, and committed by sbruno AT FreeBSD DOT org See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191909 for background details. Signed-off-by: Niclas Zeising * Add support for FreeBSD powerpcspe Add support for powerpcspe on FreeBSD This has been in the FreeBSD ports tree for some time. Originally submitted by jhibbits AT FreeBSD DOT org. Signed-off-by: Niclas Zeising * Fix abort() on FreeBSD arm related to __clear_cache() This patch has been in the FreeBSD ports tree for a number of years. Original commit by koobs AT FreeBSD DOT org Original commit message: > devel/libffi: Fix abort() on ARM related to __clear_cache() > > The current FreeBSD/ARM __clear_cache() implementation does nothing #if > __i386__ || __x86_64__ #else abort(); > > cognet@ advises this is an issue for anything !Apple that is using the > libcompiler_rt provided by Clang on ARM, and requires upstreaming. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=149167 for some background details. Signed-off-by: Niclas Zeising --- configure.host | 6 +++++- src/arm/ffi.c | 15 +++++++++++++++ src/mips/ffi.c | 6 +++++- src/mips/ffitarget.h | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/configure.host b/configure.host index 398c3b554..c7d63fd94 100644 --- a/configure.host +++ b/configure.host @@ -179,7 +179,7 @@ case "${host}" in mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) TARGET=MIPS; TARGETDIR=mips ;; - mips*-*linux* | mips*-*-openbsd*) + mips*-*linux* | mips*-*-openbsd* | mips*-*-freebsd*) # Support 128-bit long double for NewABI. HAVE_LONG_DOUBLE='defined(__mips64)' TARGET=MIPS; TARGETDIR=mips @@ -218,6 +218,10 @@ case "${host}" in TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc HAVE_LONG_DOUBLE_VARIANT=1 ;; + powerpcspe-*-freebsd*) + TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc + CFLAGS="$CFLAGS -D__NO_FPRS__" + ;; powerpc64-*-freebsd*) TARGET=POWERPC; TARGETDIR=powerpc ;; diff --git a/src/arm/ffi.c b/src/arm/ffi.c index 4e270718a..efea031f7 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -55,6 +55,11 @@ extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN; #endif #endif +#if defined(__FreeBSD__) && defined(__arm__) +#include +#include +#endif + /* Forward declares. */ static int vfp_type_p (const ffi_type *); static void layout_vfp_args (ffi_cif *); @@ -569,6 +574,16 @@ void ffi_go_closure_VFP (void) FFI_HIDDEN; /* the cif must already be prep'ed */ +#if defined(__FreeBSD__) && defined(__arm__) +#define __clear_cache(start, end) do { \ + struct arm_sync_icache_args ua; \ + \ + ua.addr = (uintptr_t)(start); \ + ua.len = (char *)(end) - (char *)start; \ + sysarch(ARM_SYNC_ICACHE, &ua); \ + } while (0); +#endif + ffi_status ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif, diff --git a/src/mips/ffi.c b/src/mips/ffi.c index 057b04669..979ca49f1 100644 --- a/src/mips/ffi.c +++ b/src/mips/ffi.c @@ -39,7 +39,9 @@ #endif #ifndef USE__BUILTIN___CLEAR_CACHE -# if defined(__OpenBSD__) +# if defined(__FreeBSD__) +# include +# elif defined(__OpenBSD__) # include # else # include @@ -777,11 +779,13 @@ ffi_prep_closure_loc (ffi_closure *closure, closure->fun = fun; closure->user_data = user_data; +#if !defined(__FreeBSD__) #ifdef USE__BUILTIN___CLEAR_CACHE __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE); #else cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE); #endif +#endif /* ! __FreeBSD__ */ return FFI_OK; } diff --git a/src/mips/ffitarget.h b/src/mips/ffitarget.h index fffdb977b..fdd5ca90a 100644 --- a/src/mips/ffitarget.h +++ b/src/mips/ffitarget.h @@ -41,7 +41,7 @@ #define _MIPS_SIM_ABI32 1 #define _MIPS_SIM_NABI32 2 #define _MIPS_SIM_ABI64 3 -#elif !defined(__OpenBSD__) +#elif !defined(__OpenBSD__) && !defined(__FreeBSD__) # include #endif From ead65ca8711aa07efc0453f67136aff82f33c01f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 19 Aug 2020 08:34:09 -0400 Subject: [PATCH 146/231] Re-enable s390x testing --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8dfa0c2fb..8db2ddfb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,9 @@ matrix: env: HOST=alpha-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - os: linux env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e -# - os: linux -# arch: s390x -# env: HOST=s390x-linux-gnu + - os: linux + arch: s390x + env: HOST=s390x-linux-gnu - os: linux arch: ppc64le env: HOST=ppc64le-linux-gnu From 407394c0aac2db4a1978a7691035889db9924a01 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Sun, 11 Oct 2020 15:07:40 +1100 Subject: [PATCH 147/231] docs: fix simple typo, paramters -> parameters (#589) There is a small typo in src/x86/ffi.c. Should read `parameters` rather than `paramters`. --- src/x86/ffi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 346e784e1..5903793d3 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -353,7 +353,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, size_t align = FFI_SIZEOF_ARG; /* Issue 434: For thiscall and fastcall, if the paramter passed - as 64-bit integer or struct, all following integer paramters + as 64-bit integer or struct, all following integer parameters will be passed on stack. */ if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL) && (t == FFI_TYPE_SINT64 @@ -492,7 +492,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack) align = 16; /* Issue 434: For thiscall and fastcall, if the paramter passed - as 64-bit integer or struct, all following integer paramters + as 64-bit integer or struct, all following integer parameters will be passed on stack. */ if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL) && (t == FFI_TYPE_SINT64 From f4435980fa2da335fe388db431d4a7946a99a2b9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 27 Oct 2020 23:36:21 +1030 Subject: [PATCH 148/231] Power10 libffi fixes (#585) Power10 pc-relative code doesn't use or preserve r2 as a TOC pointer. That means calling between pc-relative and TOC using code can't be done without intervening linker stubs, and a call from TOC code to pc-relative code must have a nop after the bl in order to restore r2. Now the PowerPC libffi assembly code doesn't use r2 except for the implicit use when making calls back to C, ffi_closure_helper_LINUX64 and ffi_prep_args64. So changing the assembly to interoperate with pc-relative code without stubs is easily done. * src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global entry when __PCREL__. Call using @notoc. Add nops. * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise. (ffi_go_closure_linux64): Likewise. --- src/powerpc/linux64.S | 8 ++++++++ src/powerpc/linux64_closure.S | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/powerpc/linux64.S b/src/powerpc/linux64.S index c99889c1c..e92d64af3 100644 --- a/src/powerpc/linux64.S +++ b/src/powerpc/linux64.S @@ -36,8 +36,10 @@ .cfi_startproc # if _CALL_ELF == 2 ffi_call_LINUX64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha addi %r2, %r2, .TOC.-ffi_call_LINUX64@l +# endif .localentry ffi_call_LINUX64, . - ffi_call_LINUX64 # else .section ".opd","aw" @@ -89,9 +91,15 @@ ffi_call_LINUX64: /* Call ffi_prep_args64. */ mr %r4, %r1 # if defined _CALL_LINUX || _CALL_ELF == 2 +# ifdef __PCREL__ + bl ffi_prep_args64@notoc +# else bl ffi_prep_args64 + nop +# endif # else bl .ffi_prep_args64 + nop # endif # if _CALL_ELF == 2 diff --git a/src/powerpc/linux64_closure.S b/src/powerpc/linux64_closure.S index d67e4bbbd..3469a2cbb 100644 --- a/src/powerpc/linux64_closure.S +++ b/src/powerpc/linux64_closure.S @@ -37,8 +37,10 @@ .cfi_startproc # if _CALL_ELF == 2 ffi_closure_LINUX64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l +# endif .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64 # else .section ".opd","aw" @@ -190,11 +192,19 @@ ffi_closure_LINUX64: # make the call # if defined _CALL_LINUX || _CALL_ELF == 2 +# ifdef __PCREL__ + bl ffi_closure_helper_LINUX64@notoc +.Lret: +# else bl ffi_closure_helper_LINUX64 +.Lret: + nop +# endif # else bl .ffi_closure_helper_LINUX64 -# endif .Lret: + nop +# endif # now r3 contains the return type # so use it to look up in a table @@ -460,8 +470,10 @@ ffi_closure_LINUX64: .cfi_startproc # if _CALL_ELF == 2 ffi_go_closure_linux64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_go_closure_linux64@ha addi %r2, %r2, .TOC.-ffi_go_closure_linux64@l +# endif .localentry ffi_go_closure_linux64, . - ffi_go_closure_linux64 # else .section ".opd","aw" From 2d86809db6d1d626a9df40c283ec564ac98ff85d Mon Sep 17 00:00:00 2001 From: jacobly0 Date: Tue, 27 Oct 2020 10:00:03 -0400 Subject: [PATCH 149/231] Fix read-only .eh_frame section test when CFLAGS contains -flto. (#590) --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3ca1f4fbb..790274ea9 100644 --- a/configure.ac +++ b/configure.ac @@ -260,11 +260,13 @@ EOF fi if test "x$GCC" = "xyes"; then + AX_CHECK_COMPILE_FLAG(-fno-lto, libffi_cv_no_lto=-fno-lto) + AC_CACHE_CHECK([whether .eh_frame section should be read-only], libffi_cv_ro_eh_frame, [ libffi_cv_ro_eh_frame=yes echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c - if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then + if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then libffi_cv_ro_eh_frame=no fi From c78fcf88ab13a5cc414826a018dd46c3f886adee Mon Sep 17 00:00:00 2001 From: petersn Date: Tue, 27 Oct 2020 07:02:36 -0700 Subject: [PATCH 150/231] Removing unnecessary instruction from ffi_call_unix64 (#588) unix64.S's `ffi_call_unix64` looks like it used to take six parameters, where the sixth said the number of SSE register arguments. However, currently the function only takes five parameters, and the number of SSE register arguments is encoded in the `struct register_args *` passed as the first parameter to `ffi_call_unix64`. This change removes an instruction that tries to use this missing sixth parameter as the number of SSE arguments. This fix should not change any behavior, nor fix any bugs, because a few instructions later the value moved from %r9d into %eax is overwritten by the correct value anyway. This change merely makes the code a tad less confusing, because currently the assembly moves from a register (r9) whose value is never set. --- src/x86/unix64.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/x86/unix64.S b/src/x86/unix64.S index ee3c04fdd..89d7db11f 100644 --- a/src/x86/unix64.S +++ b/src/x86/unix64.S @@ -84,7 +84,6 @@ L(UW1): movq %rdi, %r10 /* Save a copy of the register area. */ movq %r8, %r11 /* Save a copy of the target fn. */ - movl %r9d, %eax /* Set number of SSE registers. */ /* Load up all argument registers. */ movq (%r10), %rdi @@ -93,7 +92,7 @@ L(UW1): movq 0x18(%r10), %rcx movq 0x20(%r10), %r8 movq 0x28(%r10), %r9 - movl 0xb0(%r10), %eax + movl 0xb0(%r10), %eax /* Set number of SSE registers. */ testl %eax, %eax jnz L(load_sse) L(ret_from_load_sse): From 93cf288ddd59c7cb203c1aba25de5e5b8f308da6 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Tue, 27 Oct 2020 07:05:28 -0700 Subject: [PATCH 151/231] testsuite: Add a missing include of to fix build failure in test suite (#587) Signed-off-by: Jeremy Huddleston Sequoia --- testsuite/libffi.closures/huge_struct.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testsuite/libffi.closures/huge_struct.c b/testsuite/libffi.closures/huge_struct.c index 1915c3f1e..e8e1d8601 100644 --- a/testsuite/libffi.closures/huge_struct.c +++ b/testsuite/libffi.closures/huge_struct.c @@ -9,6 +9,8 @@ /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ /* { dg-options -Wformat=0 { target moxie*-*-elf or1k-*-* } } */ +#include + #include "ffitest.h" typedef struct BigStruct{ From 032b3cd6f7850f3ebc1269eeab7d1db3ea518d29 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Tue, 27 Oct 2020 07:06:21 -0700 Subject: [PATCH 152/231] Support building x86 and arm64 without FFI_GO_CLOSURES (#586) * x86: Support building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia * arm: Support building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia --- src/arm/ffi.c | 7 +++++++ src/x86/ffi.c | 6 ++++++ src/x86/ffi64.c | 7 +++++++ src/x86/ffiw64.c | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/src/arm/ffi.c b/src/arm/ffi.c index efea031f7..005839006 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -426,12 +426,14 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) ffi_call_int (cif, fn, rvalue, avalue, NULL); } +#ifdef FFI_GO_CLOSURES void ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue, void *closure) { ffi_call_int (cif, fn, rvalue, avalue, closure); } +#endif static void * ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue, @@ -569,8 +571,11 @@ ffi_closure_inner_VFP (ffi_cif *cif, void ffi_closure_SYSV (void) FFI_HIDDEN; void ffi_closure_VFP (void) FFI_HIDDEN; + +#ifdef FFI_GO_CLOSURES void ffi_go_closure_SYSV (void) FFI_HIDDEN; void ffi_go_closure_VFP (void) FFI_HIDDEN; +#endif /* the cif must already be prep'ed */ @@ -637,6 +642,7 @@ ffi_prep_closure_loc (ffi_closure * closure, return FFI_OK; } +#ifdef FFI_GO_CLOSURES ffi_status ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, void (*fun) (ffi_cif *, void *, void **, void *)) @@ -658,6 +664,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, return FFI_OK; } +#endif /* Below are routines for VFP hard-float support. */ diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 5903793d3..5f7fd81d9 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -397,12 +397,14 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) ffi_call_int (cif, fn, rvalue, avalue, NULL); } +#ifdef FFI_GO_CLOSURES void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, void *closure) { ffi_call_int (cif, fn, rvalue, avalue, closure); } +#endif /** private members **/ @@ -575,6 +577,8 @@ ffi_prep_closure_loc (ffi_closure* closure, return FFI_OK; } +#ifdef FFI_GO_CLOSURES + void FFI_HIDDEN ffi_go_closure_EAX(void); void FFI_HIDDEN ffi_go_closure_ECX(void); void FFI_HIDDEN ffi_go_closure_STDCALL(void); @@ -611,6 +615,8 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, return FFI_OK; } +#endif /* FFI_GO_CLOSURES */ + /* ------- Native raw API support -------------------------------- */ #if !FFI_NO_RAW_API diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index ed82e235f..39f95981b 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -688,6 +688,8 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) ffi_call_int (cif, fn, rvalue, avalue, NULL); } +#ifdef FFI_GO_CLOSURES + #ifndef __ILP32__ extern void ffi_call_go_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue, @@ -708,6 +710,7 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_call_int (cif, fn, rvalue, avalue, closure); } +#endif /* FFI_GO_CLOSURES */ extern void ffi_closure_unix64(void) FFI_HIDDEN; extern void ffi_closure_unix64_sse(void) FFI_HIDDEN; @@ -856,6 +859,8 @@ ffi_closure_unix64_inner(ffi_cif *cif, return flags; } +#ifdef FFI_GO_CLOSURES + extern void ffi_go_closure_unix64(void) FFI_HIDDEN; extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN; @@ -885,4 +890,6 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, return FFI_OK; } +#endif /* FFI_GO_CLOSURES */ + #endif /* __x86_64__ */ diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index 034dffda5..a43a9ebe9 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -187,7 +187,10 @@ EFI64(ffi_call_go)(ffi_cif *cif, void (*fn)(void), void *rvalue, extern void ffi_closure_win64(void) FFI_HIDDEN; + +#ifdef FFI_GO_CLOSURES extern void ffi_go_closure_win64(void) FFI_HIDDEN; +#endif ffi_status EFI64(ffi_prep_closure_loc)(ffi_closure* closure, @@ -227,6 +230,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure, return FFI_OK; } +#ifdef FFI_GO_CLOSURES ffi_status EFI64(ffi_prep_go_closure)(ffi_go_closure* closure, ffi_cif* cif, void (*fun)(ffi_cif*, void*, void**, void*)) @@ -246,6 +250,7 @@ EFI64(ffi_prep_go_closure)(ffi_go_closure* closure, ffi_cif* cif, return FFI_OK; } +#endif struct win64_closure_frame { From 484c1a0d7536be60002473f7bb82223efe139883 Mon Sep 17 00:00:00 2001 From: Ken <21211439+kencu@users.noreply.github.com> Date: Tue, 27 Oct 2020 07:07:07 -0700 Subject: [PATCH 153/231] darwin powerpc: use go closures only if enabled (#583) SHA: 0ff9419f2e75652426469e256cb7d0748064ad58 added go closures for darwin powerpc AIX, but these have not yet been implemented for non-AIX systems use the go closures only if enabled --- src/powerpc/ffi_darwin.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/powerpc/ffi_darwin.c b/src/powerpc/ffi_darwin.c index 61a18c491..64bb94dfa 100644 --- a/src/powerpc/ffi_darwin.c +++ b/src/powerpc/ffi_darwin.c @@ -33,7 +33,10 @@ #include extern void ffi_closure_ASM (void); + +#if defined (FFI_GO_CLOSURES) extern void ffi_go_closure_ASM (void); +#endif enum { /* The assembly depends on these exact flags. @@ -909,8 +912,10 @@ ffi_prep_cif_machdep (ffi_cif *cif) extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *, void (*fn)(void), void (*fn2)(void)); +#if defined (FFI_GO_CLOSURES) extern void ffi_call_go_AIX(extended_cif *, long, unsigned, unsigned *, void (*fn)(void), void (*fn2)(void), void *closure); +#endif extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *, void (*fn)(void), void (*fn2)(void), ffi_type*); @@ -950,6 +955,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) } } +#if defined (FFI_GO_CLOSURES) void ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue, void *closure) @@ -981,6 +987,7 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue, break; } } +#endif static void flush_icache(char *); static void flush_range(char *, int); @@ -1110,6 +1117,7 @@ ffi_prep_closure_loc (ffi_closure* closure, return FFI_OK; } +#if defined (FFI_GO_CLOSURES) ffi_status ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, @@ -1133,6 +1141,7 @@ ffi_prep_go_closure (ffi_go_closure* closure, } return FFI_OK; } +#endif static void flush_icache(char *addr) @@ -1168,9 +1177,11 @@ ffi_type * ffi_closure_helper_DARWIN (ffi_closure *, void *, unsigned long *, ffi_dblfl *); +#if defined (FFI_GO_CLOSURES) ffi_type * ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *, unsigned long *, ffi_dblfl *); +#endif /* Basically the trampoline invokes ffi_closure_ASM, and on entry, r11 holds the address of the closure. @@ -1430,6 +1441,7 @@ ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue, closure->user_data, rvalue, pgr, pfr); } +#if defined (FFI_GO_CLOSURES) ffi_type * ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue, unsigned long *pgr, ffi_dblfl *pfr) @@ -1437,4 +1449,4 @@ ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue, return ffi_closure_helper_common (closure->cif, closure->fun, closure, rvalue, pgr, pfr); } - +#endif From 8111cd06921e80d5d7192ce8d1f64733072fdbcd Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Tue, 27 Oct 2020 09:07:38 -0500 Subject: [PATCH 154/231] Add support for powerpc64le-*-freebsd*. (#581) Tests pass with no additional changes needed, tested on hardware. --- configure.host | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.host b/configure.host index c7d63fd94..d9623e92f 100644 --- a/configure.host +++ b/configure.host @@ -222,7 +222,7 @@ case "${host}" in TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc CFLAGS="$CFLAGS -D__NO_FPRS__" ;; - powerpc64-*-freebsd*) + powerpc64-*-freebsd* | powerpc64le-*-freebsd*) TARGET=POWERPC; TARGETDIR=powerpc ;; powerpc*-*-rtems*) From 56f7df711f70414d4f3663b34e54b122b38bab88 Mon Sep 17 00:00:00 2001 From: AndreRH Date: Tue, 10 Nov 2020 12:27:59 +0100 Subject: [PATCH 155/231] aarch64: Allow FFI_WIN64 for winelib (#593) --- src/aarch64/ffi.c | 70 +++++++++++++++++++++++------------------ src/aarch64/ffitarget.h | 7 ++++- src/aarch64/internal.h | 1 + 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index 508a62400..ef09f4d06 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -564,6 +564,14 @@ ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, cif->aarch64_nfixedargs = nfixedargs; return status; } +#else +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs) +{ + ffi_status status = ffi_prep_cif_machdep (cif); + cif->flags |= AARCH64_FLAG_VARARG; + return status; +} #endif /* __APPLE__ */ extern void ffi_call_SYSV (struct call_context *context, void *frame, @@ -580,7 +588,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, void *stack, *frame, *rvalue; struct arg_state state; size_t stack_bytes, rtype_size, rsize; - int i, nargs, flags; + int i, nargs, flags, isvariadic = 0; ffi_type *rtype; flags = cif->flags; @@ -588,6 +596,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, rtype_size = rtype->size; stack_bytes = cif->bytes; + if (flags & AARCH64_FLAG_VARARG) + { + isvariadic = 1; + flags &= ~AARCH64_FLAG_VARARG; + } + /* If the target function returns a structure via hidden pointer, then we cannot allow a null rvalue. Otherwise, mash a null rvalue to void return type. */ @@ -667,35 +681,31 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, h = is_vfp_type (ty); if (h) { - int elems = 4 - (h & 3); -#ifdef _WIN32 /* for handling armasm calling convention */ - if (cif->is_variadic) - { - if (state.ngrn + elems <= N_X_ARG_REG) - { - dest = &context->x[state.ngrn]; - state.ngrn += elems; - extend_hfa_type(dest, a, h); - break; - } - state.nsrn = N_X_ARG_REG; - dest = allocate_to_stack(&state, stack, ty->alignment, s); - } - else - { -#endif /* for handling armasm calling convention */ - if (state.nsrn + elems <= N_V_ARG_REG) - { - dest = &context->v[state.nsrn]; - state.nsrn += elems; - extend_hfa_type (dest, a, h); - break; - } - state.nsrn = N_V_ARG_REG; - dest = allocate_to_stack (&state, stack, ty->alignment, s); -#ifdef _WIN32 /* for handling armasm calling convention */ - } -#endif /* for handling armasm calling convention */ + int elems = 4 - (h & 3); + if (cif->abi == FFI_WIN64 && isvariadic) + { + if (state.ngrn + elems <= N_X_ARG_REG) + { + dest = &context->x[state.ngrn]; + state.ngrn += elems; + extend_hfa_type(dest, a, h); + break; + } + state.nsrn = N_X_ARG_REG; + dest = allocate_to_stack(&state, stack, ty->alignment, s); + } + else + { + if (state.nsrn + elems <= N_V_ARG_REG) + { + dest = &context->v[state.nsrn]; + state.nsrn += elems; + extend_hfa_type (dest, a, h); + break; + } + state.nsrn = N_V_ARG_REG; + dest = allocate_to_stack (&state, stack, ty->alignment, s); + } } else if (s > 16) { diff --git a/src/aarch64/ffitarget.h b/src/aarch64/ffitarget.h index 7a8cabe80..d5622e133 100644 --- a/src/aarch64/ffitarget.h +++ b/src/aarch64/ffitarget.h @@ -45,8 +45,13 @@ typedef enum ffi_abi { FFI_FIRST_ABI = 0, FFI_SYSV, + FFI_WIN64, FFI_LAST_ABI, +#if defined(_WIN32) + FFI_DEFAULT_ABI = FFI_WIN64 +#else FFI_DEFAULT_ABI = FFI_SYSV +#endif } ffi_abi; #endif @@ -72,11 +77,11 @@ typedef enum ffi_abi #ifdef _WIN32 #define FFI_EXTRA_CIF_FIELDS unsigned is_variadic #endif +#define FFI_TARGET_SPECIFIC_VARIADIC /* ---- Internal ---- */ #if defined (__APPLE__) -#define FFI_TARGET_SPECIFIC_VARIADIC #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs #elif !defined(_WIN32) /* iOS and Windows reserve x18 for the system. Disable Go closures until diff --git a/src/aarch64/internal.h b/src/aarch64/internal.h index 9c3e07725..3d4d0355b 100644 --- a/src/aarch64/internal.h +++ b/src/aarch64/internal.h @@ -61,6 +61,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define AARCH64_FLAG_ARG_V_BIT 7 #define AARCH64_FLAG_ARG_V (1 << AARCH64_FLAG_ARG_V_BIT) +#define AARCH64_FLAG_VARARG (1 << 8) #define N_X_ARG_REG 8 #define N_V_ARG_REG 8 From d817d0daa312c58548d7a081aa876027ca103766 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 10 Nov 2020 20:39:25 +0900 Subject: [PATCH 156/231] Don't use FFI_TYPE_LONGDOUBLE in the jump table in win64*.S (#580) It may have the same value as FFI_TYPE_DOUBLE per ffi.h, which possibly can make things go wrong with .org/ORG. For instance, GCC complains about "Error: attempt to move .org backwards" --- src/x86/win64.S | 5 +++-- src/x86/win64_intel.S | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/x86/win64.S b/src/x86/win64.S index 57c0e656c..8315e8b75 100644 --- a/src/x86/win64.S +++ b/src/x86/win64.S @@ -30,7 +30,7 @@ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) # define E(BASE, X) .balign 8 #else -# define E(BASE, X) .balign 8; .org BASE + X * 8 +# define E(BASE, X) .balign 8; .org BASE + (X) * 8 #endif .text @@ -108,7 +108,8 @@ E(0b, FFI_TYPE_FLOAT) E(0b, FFI_TYPE_DOUBLE) movsd %xmm0, (%r8) epilogue -E(0b, FFI_TYPE_LONGDOUBLE) +// FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here. +E(0b, FFI_TYPE_DOUBLE + 1) call PLT(C(abort)) E(0b, FFI_TYPE_UINT8) movzbl %al, %eax diff --git a/src/x86/win64_intel.S b/src/x86/win64_intel.S index 7df78b30e..970a4f997 100644 --- a/src/x86/win64_intel.S +++ b/src/x86/win64_intel.S @@ -29,7 +29,7 @@ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) # define E(BASE, X) ALIGN 8 #else -# define E(BASE, X) ALIGN 8; ORG BASE + X * 8 +# define E(BASE, X) ALIGN 8; ORG BASE + (X) * 8 #endif .CODE @@ -107,7 +107,8 @@ E(0b, FFI_TYPE_FLOAT) E(0b, FFI_TYPE_DOUBLE) movsd qword ptr[r8], xmm0; movsd %xmm0, (%r8) epilogue -E(0b, FFI_TYPE_LONGDOUBLE) +// FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here. +E(0b, FFI_TYPE_DOUBLE + 1) call PLT(C(abort)) E(0b, FFI_TYPE_UINT8) movzx eax, al ;movzbl %al, %eax From 8cc8f446f5aac13e107161dffbc15d1ee1a58878 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 10 Nov 2020 20:41:33 +0900 Subject: [PATCH 157/231] Allow to build with mingw-clang (#579) For some reason, compiling sysv.S with mingw-clang fails with: ``` error: invalid variant 'ffi_closure_inner@8' ``` This can be fixed (worked around?) by quoting the symbol. This works fine with mingw-gcc too. --- src/x86/sysv.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x86/sysv.S b/src/x86/sysv.S index 6d5648332..d8ab4b026 100644 --- a/src/x86/sysv.S +++ b/src/x86/sysv.S @@ -56,8 +56,8 @@ /* Handle win32 fastcall name mangling. */ #ifdef X86_WIN32 -# define ffi_call_i386 @ffi_call_i386@8 -# define ffi_closure_inner @ffi_closure_inner@8 +# define ffi_call_i386 "@ffi_call_i386@8" +# define ffi_closure_inner "@ffi_closure_inner@8" #else # define ffi_call_i386 C(ffi_call_i386) # define ffi_closure_inner C(ffi_closure_inner) From e70bf987daa7b7b5df2de7579d5c51a888e8bf7d Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Tue, 24 Nov 2020 19:13:57 -0500 Subject: [PATCH 158/231] Properly quote and resolve msvcc.sh params (#596) --- msvcc.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/msvcc.sh b/msvcc.sh index 97facd698..7cfc5097f 100755 --- a/msvcc.sh +++ b/msvcc.sh @@ -165,24 +165,24 @@ do shift 1 ;; -I) - p=$(cygpath -m $2) - args="$args -I$p" - includes="$includes -I$p" + p=$(cygpath -ma "$2") + args="$args -I\"$p\"" + includes="$includes -I\"$p\"" shift 2 ;; -I*) - p=$(cygpath -m ${1#-I}) - args="$args -I$p" - includes="$includes -I$p" + p=$(cygpath -ma "${1#-I}") + args="$args -I\"$p\"" + includes="$includes -I\"$p\"" shift 1 ;; -L) - p=$(cygpath -m $2) + p=$(cygpath -ma $2) linkargs="$linkargs -LIBPATH:$p" shift 2 ;; -L*) - p=$(cygpath -m ${1#-L}) + p=$(cygpath -ma ${1#-L}) linkargs="$linkargs -LIBPATH:$p" shift 1 ;; @@ -256,12 +256,12 @@ do shift 2 ;; *.S) - src=$1 + src="$(cygpath -ma $1)" assembly="true" shift 1 ;; *.c) - args="$args $1" + args="$args $(cygpath -ma $1)" shift 1 ;; *) @@ -312,7 +312,7 @@ if [ -n "$assembly" ]; then echo "$cl -nologo -EP $includes $defines $src > $ppsrc" fi - "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $? + eval "\"$cl\" -nologo -EP $includes $defines $src" > $ppsrc || exit $? output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')" if [ $ml = "armasm" ]; then args="-nologo -g -oldit $armasm_output $ppsrc -errorReport:prompt" From cb8474368cdef3207638d047bd6c707ad8fcb339 Mon Sep 17 00:00:00 2001 From: hjl-tools Date: Wed, 2 Dec 2020 12:52:12 -0800 Subject: [PATCH 159/231] libffi/x86: Always check __x86_64__ for x32 hosts (#601) (#602) Since for x86_64-*x32 and x86_64-x32-* hosts, -m32 generates ia32 codes. We should always check __x86_64__ for x32 hosts. --- configure.host | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/configure.host b/configure.host index d9623e92f..257b78487 100644 --- a/configure.host +++ b/configure.host @@ -115,22 +115,14 @@ case "${host}" in i?86-*-* | x86_64-*-* | amd64-*) TARGETDIR=x86 if test $ac_cv_sizeof_size_t = 4; then - case "$host" in - x86_64-*x32|x86_64-x32-*) - TARGET_X32=yes - TARGET=X86_64 - ;; - *) - echo 'int foo (void) { return __x86_64__; }' > conftest.c - if $CC $CFLAGS -Werror -S conftest.c -o conftest.s > /dev/null 2>&1; then - TARGET_X32=yes - TARGET=X86_64 - else - TARGET=X86; - fi - rm -f conftest.* - ;; - esac + echo 'int foo (void) { return __x86_64__; }' > conftest.c + if $CC $CFLAGS -Werror -S conftest.c -o conftest.s > /dev/null 2>&1; then + TARGET_X32=yes + TARGET=X86_64 + else + TARGET=X86; + fi + rm -f conftest.* else TARGET=X86_64; fi From 5c63b463b87d3c06102a4a7f05f395929d9ea79b Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 2 Dec 2020 16:14:27 -0500 Subject: [PATCH 160/231] Use memfd_create() (#604) memfd_create creates a file in a memory-only filesystem that may bypass strict security protocols in filesystem-based temporary files. --- configure.ac | 3 +++ src/closures.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac index 790274ea9..093b87d4f 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,9 @@ EOF AM_MAINTAINER_MODE +AC_CHECK_HEADERS(sys/memfd.h) +AC_CHECK_FUNCS([memfd_create]) + AC_CHECK_HEADERS(sys/mman.h) AC_CHECK_FUNCS([mmap mkostemp]) AC_FUNC_MMAP_BLACKLIST diff --git a/src/closures.c b/src/closures.c index 4fe6158d8..dfc2f68b2 100644 --- a/src/closures.c +++ b/src/closures.c @@ -45,6 +45,9 @@ #include #include +#ifdef HAVE_SYS_MEMFD_H +#include +#endif static const size_t overhead = (sizeof(max_align_t) > sizeof(void *) + sizeof(size_t)) ? @@ -544,6 +547,17 @@ static int execfd = -1; /* The amount of space already allocated from the temporary file. */ static size_t execsize = 0; +#ifdef HAVE_MEMFD_CREATE +/* Open a temporary file name, and immediately unlink it. */ +static int +open_temp_exec_file_memfd (const char *name) +{ + int fd; + fd = memfd_create (name, MFD_CLOEXEC); + return fd; +} +#endif + /* Open a temporary file name, and immediately unlink it. */ static int open_temp_exec_file_name (char *name, int flags) @@ -671,6 +685,9 @@ static struct const char *arg; int repeat; } open_temp_exec_file_opts[] = { +#ifdef HAVE_MEMFD_CREATE + { open_temp_exec_file_memfd, "libffi", 0 }, +#endif { open_temp_exec_file_env, "TMPDIR", 0 }, { open_temp_exec_file_dir, "/tmp", 0 }, { open_temp_exec_file_dir, "/var/tmp", 0 }, From 9ba559217bea0803263a9a9a0bafcf9203606f5b Mon Sep 17 00:00:00 2001 From: "Madhavan T. Venkataraman" <75220914+madvenka786@users.noreply.github.com> Date: Fri, 5 Mar 2021 10:07:30 -0600 Subject: [PATCH 161/231] Static tramp v5 (#624) * Static Trampolines Closure Trampoline Security Issue ================================= Currently, the trampoline code used in libffi is not statically defined in a source file (except for MACH). The trampoline is either pre-defined machine code in a data buffer. Or, it is generated at runtime. In order to execute a trampoline, it needs to be placed in a page with executable permissions. Executable data pages are attack surfaces for attackers who may try to inject their own code into the page and contrive to have it executed. The security settings in a system may prevent various tricks used in user land to write code into a page and to have it executed somehow. On such systems, libffi trampolines would not be able to run. Static Trampoline ================= To solve this problem, the trampoline code needs to be defined statically in a source file, compiled and placed in the text segment so it can be mapped and executed naturally without any tricks. However, the trampoline needs to be able to access the closure pointer at runtime. PC-relative data referencing ============================ The solution implemented in this patch set uses PC-relative data references. The trampoline is mapped in a code page. Adjacent to the code page, a data page is mapped that contains the parameters of the trampoline: - the closure pointer - pointer to the ABI handler to jump to The trampoline code uses an offset relative to its current PC to access its data. Some architectures support PC-relative data references in the ISA itself. E.g., X64 supports RIP-relative references. For others, the PC has to somehow be loaded into a general purpose register to do PC-relative data referencing. To do this, we need to define a get_pc() kind of function and call it to load the PC in a desired register. There are two cases: 1. The call instruction pushes the return address on the stack. In this case, get_pc() will extract the return address from the stack and load it in the desired register and return. 2. The call instruction stores the return address in a designated register. In this case, get_pc() will copy the return address to the desired register and return. Either way, the PC next to the call instruction is obtained. Scratch register ================ In order to do its job, the trampoline code would need to use a scratch register. Depending on the ABI, there may not be a register available for scratch. This problem needs to be solved so that all ABIs will work. The trampoline will save two values on the stack: - the closure pointer - the original value of the scratch register This is what the stack will look like: sp before trampoline ------> -------------------- | closure pointer | -------------------- | scratch register | sp after trampoline -------> -------------------- The ABI handler can do the following as needed by the ABI: - the closure pointer can be loaded in a desired register - the scratch register can be restored to its original value - the stack pointer can be restored to its original value (the value when the trampoline was invoked) To do this, I have defined prolog code for each ABI handler. The legacy trampoline jumps to the ABI handler directly. But the static trampoline defined in this patch jumps tp the prolog code which performs the above actions before jumping to the ABI handler. Trampoline Table ================ In order to reduce the trampoline memory footprint, the trampoline code would be defined as a code array in the text segment. This array would be mapped into the address space of the caller. The mapping would, therefore, contain a trampoline table. Adjacent to the trampoline table mapping, there will be a data mapping that contains a parameter table, one parameter block for each trampoline. The parameter block will contain: - a pointer to the closure - a pointer to the ABI handler The static trampoline code would finally look like this: - Make space on the stack for the closure and the scratch register by moving the stack pointer down - Store the original value of the scratch register on the stack - Using PC-relative reference, get the closure pointer - Store the closure pointer on the stack - Using PC-relative reference, get the ABI handler pointer - Jump to the ABI handler Mapping size ============ The size of the code mapping that contains the trampoline table needs to be determined on a per architecture basis. If a particular architecture supports multiple base page sizes, then the largest supported base page size needs to be chosen. E.g., we choose 16K for ARM64. Trampoline allocation and free ============================== Static trampolines are allocated in ffi_closure_alloc() and freed in ffi_closure_free(). Normally, applications use these functions. But there are some cases out there where the user of libffi allocates and manages its own closure memory. In such cases, static trampolines cannot be used. These will fall back to using legacy trampolines. The user has to make sure that the memory is executable. ffi_closure structure ===================== I did not want to make any changes to the size of the closure structure for this feature to guarantee compatibility. But the opaque static trampoline handle needs to be stored in the closure. I have defined it as follows: - char tramp[FFI_TRAMPOLINE_SIZE]; + union { + char tramp[FFI_TRAMPOLINE_SIZE]; + void *ftramp; + }; If static trampolines are used, then tramp[] is not needed to store a dynamic trampoline. That space can be reused to store the handle. Hence, the union. Architecture Support ==================== Support has been added for x64, i386, aarch64 and arm. Support for other architectures can be added very easily in the future. OS Support ========== Support has been added for Linux. Support for other OSes can be added very easily. Signed-off-by: Madhavan T. Venkataraman * x86: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. Define two tables, actually, one with CET and one without. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_unix64 - ffi_closure_unix64_sse - ffi_closure_win64 The prolog functions are called: - ffi_closure_unix64_alt - ffi_closure_unix64_sse_alt - ffi_closure_win64_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman * i386: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code table statically. Define two tables, actually, one with CET and one without. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_i386 - ffi_closure_STDCALL - ffi_closure_REGISTER The prolog functions are called: - ffi_closure_i386_alt - ffi_closure_STDCALL_alt - ffi_closure_REGISTER_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman * arm64: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_SYSV - ffi_closure_SYSV_V The prolog functions are called: - ffi_closure_SYSV_alt - ffi_closure_SYSV_V_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman * arm: Support for Static Trampolines - Define the arch-specific initialization function ffi_tramp_arch () that returns trampoline size information to common code. - Define the trampoline code mapping and data mapping sizes. - Define the trampoline code table statically. - Introduce a tiny prolog for each ABI handling function. The ABI handlers addressed are: - ffi_closure_SYSV - ffi_closure_VFP The prolog functions are called: - ffi_closure_SYSV_alt - ffi_closure_VFP_alt The legacy trampoline jumps to the ABI handler. The static trampoline jumps to the prolog function. The prolog function uses the information provided by the static trampoline, sets things up for the ABI handler and then jumps to the ABI handler. - Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to initialize static trampoline parameters. Signed-off-by: Madhavan T. Venkataraman --- Makefile.am | 3 +- configure.ac | 11 +- include/ffi.h.in | 5 +- include/ffi_common.h | 4 + include/tramp.h | 24 + src/aarch64/ffi.c | 34 +- src/aarch64/internal.h | 10 + src/aarch64/sysv.S | 70 ++ src/arm/ffi.c | 32 + src/arm/internal.h | 10 + src/arm/sysv.S | 47 ++ src/closures.c | 47 +- src/tramp.c | 729 ++++++++++++++++++++ src/x86/ffi.c | 36 + src/x86/ffi64.c | 32 + src/x86/ffitarget.h | 6 +- src/x86/ffiw64.c | 15 + src/x86/internal.h | 14 + src/x86/internal64.h | 14 + src/x86/sysv.S | 89 +++ src/x86/unix64.S | 75 ++ src/x86/win64.S | 14 + testsuite/libffi.closures/closure_loc_fn0.c | 3 + 23 files changed, 1316 insertions(+), 8 deletions(-) create mode 100644 include/tramp.h create mode 100644 src/tramp.c diff --git a/Makefile.am b/Makefile.am index 7654bf5ac..1b18198ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,7 +38,8 @@ toolexeclib_LTLIBRARIES = libffi.la noinst_LTLIBRARIES = libffi_convenience.la libffi_la_SOURCES = src/prep_cif.c src/types.c \ - src/raw_api.c src/java_raw_api.c src/closures.c + src/raw_api.c src/java_raw_api.c src/closures.c \ + src/tramp.c if FFI_DEBUG libffi_la_SOURCES += src/debug.c diff --git a/configure.ac b/configure.ac index 093b87d4f..0f141f48b 100644 --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,7 @@ AC_CHECK_HEADERS(sys/memfd.h) AC_CHECK_FUNCS([memfd_create]) AC_CHECK_HEADERS(sys/mman.h) -AC_CHECK_FUNCS([mmap mkostemp]) +AC_CHECK_FUNCS([mmap mkostemp mkstemp]) AC_FUNC_MMAP_BLACKLIST dnl The -no-testsuite modules omit the test subdir. @@ -363,6 +363,15 @@ AC_ARG_ENABLE(raw-api, AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) fi) +case "$target" in + *-cygwin*) + ;; + *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-*) + AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1, + [Define this if you want statically defined trampolines]) + ;; +esac + AC_ARG_ENABLE(purify-safety, [ --enable-purify-safety purify-safe mode], if test "$enable_purify_safety" = "yes"; then diff --git a/include/ffi.h.in b/include/ffi.h.in index 38885b0ab..14ec807d9 100644 --- a/include/ffi.h.in +++ b/include/ffi.h.in @@ -310,7 +310,10 @@ typedef struct { void *trampoline_table; void *trampoline_table_entry; #else - char tramp[FFI_TRAMPOLINE_SIZE]; + union { + char tramp[FFI_TRAMPOLINE_SIZE]; + void *ftramp; + }; #endif ffi_cif *cif; void (*fun)(ffi_cif*,void*,void**,void*); diff --git a/include/ffi_common.h b/include/ffi_common.h index 76b9dd6fa..d3db33ada 100644 --- a/include/ffi_common.h +++ b/include/ffi_common.h @@ -103,6 +103,10 @@ ffi_status ffi_prep_cif_core(ffi_cif *cif, some targets. */ void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN; +/* The arch code calls this to determine if a given closure has a + static trampoline. */ +int ffi_tramp_is_present (void *closure); + /* Extended cif, used in callback from assembly routine */ typedef struct { diff --git a/include/tramp.h b/include/tramp.h new file mode 100644 index 000000000..cc096a4b9 --- /dev/null +++ b/include/tramp.h @@ -0,0 +1,24 @@ +/* ----------------------------------------------------------------------- + ffi_tramp.h - Copyright (C) 2021 Microsoft, Inc. + + Static trampoline definitions. + ----------------------------------------------------------------------- */ + +#ifndef FFI_TRAMP_H +#define FFI_TRAMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +int ffi_tramp_is_supported(void); +void *ffi_tramp_alloc (int flags); +void ffi_tramp_set_parms (void *tramp, void *data, void *code); +void *ffi_tramp_get_addr (void *tramp); +void ffi_tramp_free (void *tramp); + +#ifdef __cplusplus +} +#endif + +#endif /* FFI_TRAMP_H */ diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index ef09f4d06..8e24a96ba 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -30,6 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef _WIN32 #include /* FlushInstructionCache */ #endif +#include /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; all further uses in this file will refer to the 128-bit type. */ @@ -782,6 +783,10 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, extern void ffi_closure_SYSV (void) FFI_HIDDEN; extern void ffi_closure_SYSV_V (void) FFI_HIDDEN; +#if defined(FFI_EXEC_STATIC_TRAMP) +extern void ffi_closure_SYSV_alt (void) FFI_HIDDEN; +extern void ffi_closure_SYSV_V_alt (void) FFI_HIDDEN; +#endif ffi_status ffi_prep_closure_loc (ffi_closure *closure, @@ -816,7 +821,21 @@ ffi_prep_closure_loc (ffi_closure *closure, 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ }; char *tramp = closure->tramp; - + +#if defined(FFI_EXEC_STATIC_TRAMP) + if (ffi_tramp_is_present(closure)) + { + /* Initialize the static trampoline's parameters. */ + if (start == ffi_closure_SYSV_V) + start = ffi_closure_SYSV_V_alt; + else + start = ffi_closure_SYSV_alt; + ffi_tramp_set_parms (closure->ftramp, start, closure); + goto out; + } +#endif + + /* Initialize the dynamic trampoline. */ memcpy (tramp, trampoline, sizeof(trampoline)); *(UINT64 *)(tramp + 16) = (uintptr_t)start; @@ -832,6 +851,7 @@ ffi_prep_closure_loc (ffi_closure *closure, unsigned char *tramp_code = ffi_data_to_code_pointer (tramp); #endif ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE); +out: #endif closure->cif = cif; @@ -1022,4 +1042,16 @@ ffi_closure_SYSV_inner (ffi_cif *cif, return flags; } +#if defined(FFI_EXEC_STATIC_TRAMP) +void * +ffi_tramp_arch (size_t *tramp_size, size_t *map_size) +{ + extern void *trampoline_code_table; + + *tramp_size = AARCH64_TRAMP_SIZE; + *map_size = AARCH64_TRAMP_MAP_SIZE; + return &trampoline_code_table; +} +#endif + #endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/ diff --git a/src/aarch64/internal.h b/src/aarch64/internal.h index 3d4d0355b..de55755f9 100644 --- a/src/aarch64/internal.h +++ b/src/aarch64/internal.h @@ -66,3 +66,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define N_X_ARG_REG 8 #define N_V_ARG_REG 8 #define CALL_CONTEXT_SIZE (N_V_ARG_REG * 16 + N_X_ARG_REG * 8) + +#if defined(FFI_EXEC_STATIC_TRAMP) +/* + * For the trampoline code table mapping, a mapping size of 16K is chosen to + * cover the base page sizes of 4K and 16K. + */ +#define AARCH64_TRAMP_MAP_SHIFT 14 +#define AARCH64_TRAMP_MAP_SIZE (1 << AARCH64_TRAMP_MAP_SHIFT) +#define AARCH64_TRAMP_SIZE 32 +#endif diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S index b720a92e1..a3c15086a 100644 --- a/src/aarch64/sysv.S +++ b/src/aarch64/sysv.S @@ -367,6 +367,76 @@ CNAME(ffi_closure_SYSV): .size CNAME(ffi_closure_SYSV), . - CNAME(ffi_closure_SYSV) #endif +#if defined(FFI_EXEC_STATIC_TRAMP) + .align 4 +CNAME(ffi_closure_SYSV_V_alt): + /* See the comments above trampoline_code_table. */ + ldr x17, [sp, #8] /* Load closure in x17 */ + add sp, sp, #16 /* Restore the stack */ + b CNAME(ffi_closure_SYSV_V) + + .globl CNAME(ffi_closure_SYSV_V_alt) + FFI_HIDDEN(CNAME(ffi_closure_SYSV_V_alt)) +#ifdef __ELF__ + .type CNAME(ffi_closure_SYSV_V_alt), #function + .size CNAME(ffi_closure_SYSV_V_alt), . - CNAME(ffi_closure_SYSV_V_alt) +#endif + + .align 4 +CNAME(ffi_closure_SYSV_alt): + /* See the comments above trampoline_code_table. */ + ldr x17, [sp, #8] /* Load closure in x17 */ + add sp, sp, #16 /* Restore the stack */ + b CNAME(ffi_closure_SYSV) + + .globl CNAME(ffi_closure_SYSV_alt) + FFI_HIDDEN(CNAME(ffi_closure_SYSV_alt)) +#ifdef __ELF__ + .type CNAME(ffi_closure_SYSV_alt), #function + .size CNAME(ffi_closure_SYSV_alt), . - CNAME(ffi_closure_SYSV_alt) +#endif + +/* + * Below is the definition of the trampoline code table. Each element in + * the code table is a trampoline. + */ +/* + * The trampoline uses register x17. It saves the original value of x17 on + * the stack. + * + * The trampoline has two parameters - target code to jump to and data for + * the target code. The trampoline extracts the parameters from its parameter + * block (see tramp_table_map()). The trampoline saves the data address on + * the stack. Finally, it jumps to the target code. + * + * The target code can choose to: + * + * - restore the value of x17 + * - load the data address in a register + * - restore the stack pointer to what it was when the trampoline was invoked. + */ + .align AARCH64_TRAMP_MAP_SHIFT +CNAME(trampoline_code_table): + .rept AARCH64_TRAMP_MAP_SIZE / AARCH64_TRAMP_SIZE + sub sp, sp, #16 /* Make space on the stack */ + str x17, [sp] /* Save x17 on stack */ + adr x17, #16376 /* Get data address */ + ldr x17, [x17] /* Copy data into x17 */ + str x17, [sp, #8] /* Save data on stack */ + adr x17, #16372 /* Get code address */ + ldr x17, [x17] /* Load code address into x17 */ + br x17 /* Jump to code */ + .endr + + .globl CNAME(trampoline_code_table) + FFI_HIDDEN(CNAME(trampoline_code_table)) +#ifdef __ELF__ + .type CNAME(trampoline_code_table), #function + .size CNAME(trampoline_code_table), . - CNAME(trampoline_code_table) +#endif + .align AARCH64_TRAMP_MAP_SHIFT +#endif /* FFI_EXEC_STATIC_TRAMP */ + #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ diff --git a/src/arm/ffi.c b/src/arm/ffi.c index 005839006..5ad59ce77 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "internal.h" #if defined(_MSC_VER) && defined(_M_ARM) @@ -571,6 +572,10 @@ ffi_closure_inner_VFP (ffi_cif *cif, void ffi_closure_SYSV (void) FFI_HIDDEN; void ffi_closure_VFP (void) FFI_HIDDEN; +#if defined(FFI_EXEC_STATIC_TRAMP) +void ffi_closure_SYSV_alt (void) FFI_HIDDEN; +void ffi_closure_VFP_alt (void) FFI_HIDDEN; +#endif #ifdef FFI_GO_CLOSURES void ffi_go_closure_SYSV (void) FFI_HIDDEN; @@ -612,6 +617,20 @@ ffi_prep_closure_loc (ffi_closure * closure, config[1] = closure_func; #else +#if defined(FFI_EXEC_STATIC_TRAMP) + if (ffi_tramp_is_present(closure)) + { + /* Initialize the static trampoline's parameters. */ + if (closure_func == ffi_closure_SYSV) + closure_func = ffi_closure_SYSV_alt; + else + closure_func = ffi_closure_VFP_alt; + ffi_tramp_set_parms (closure->ftramp, closure_func, closure); + goto out; + } +#endif + + /* Initialize the dynamic trampoline. */ #ifndef _M_ARM memcpy(closure->tramp, ffi_arm_trampoline, 8); #else @@ -633,6 +652,7 @@ ffi_prep_closure_loc (ffi_closure * closure, #else *(void (**)(void))(closure->tramp + 8) = closure_func; #endif +out: #endif closure->cif = cif; @@ -873,4 +893,16 @@ layout_vfp_args (ffi_cif * cif) } } +#if defined(FFI_EXEC_STATIC_TRAMP) +void * +ffi_tramp_arch (size_t *tramp_size, size_t *map_size) +{ + extern void *trampoline_code_table; + + *tramp_size = ARM_TRAMP_SIZE; + *map_size = ARM_TRAMP_MAP_SIZE; + return &trampoline_code_table; +} +#endif + #endif /* __arm__ or _M_ARM */ diff --git a/src/arm/internal.h b/src/arm/internal.h index 6cf0b2ae5..fa8ab0b6e 100644 --- a/src/arm/internal.h +++ b/src/arm/internal.h @@ -5,3 +5,13 @@ #define ARM_TYPE_INT 4 #define ARM_TYPE_VOID 5 #define ARM_TYPE_STRUCT 6 + +#if defined(FFI_EXEC_STATIC_TRAMP) +/* + * For the trampoline table mapping, a mapping size of 4K (base page size) + * is chosen. + */ +#define ARM_TRAMP_MAP_SHIFT 12 +#define ARM_TRAMP_MAP_SIZE (1 << ARM_TRAMP_MAP_SHIFT) +#define ARM_TRAMP_SIZE 20 +#endif diff --git a/src/arm/sysv.S b/src/arm/sysv.S index 74bc53fa2..49c561eee 100644 --- a/src/arm/sysv.S +++ b/src/arm/sysv.S @@ -354,6 +354,53 @@ E(ARM_TYPE_STRUCT) cfi_endproc ARM_FUNC_END(ffi_closure_ret) +#if defined(FFI_EXEC_STATIC_TRAMP) +ARM_FUNC_START(ffi_closure_SYSV_alt) + /* See the comments above trampoline_code_table. */ + ldr ip, [sp, #4] /* Load closure in ip */ + add sp, sp, 8 /* Restore the stack */ + b CNAME(ffi_closure_SYSV) +ARM_FUNC_END(ffi_closure_SYSV_alt) + +ARM_FUNC_START(ffi_closure_VFP_alt) + /* See the comments above trampoline_code_table. */ + ldr ip, [sp, #4] /* Load closure in ip */ + add sp, sp, 8 /* Restore the stack */ + b CNAME(ffi_closure_VFP) +ARM_FUNC_END(ffi_closure_VFP_alt) + +/* + * Below is the definition of the trampoline code table. Each element in + * the code table is a trampoline. + */ +/* + * The trampoline uses register ip (r12). It saves the original value of ip + * on the stack. + * + * The trampoline has two parameters - target code to jump to and data for + * the target code. The trampoline extracts the parameters from its parameter + * block (see tramp_table_map()). The trampoline saves the data address on + * the stack. Finally, it jumps to the target code. + * + * The target code can choose to: + * + * - restore the value of ip + * - load the data address in a register + * - restore the stack pointer to what it was when the trampoline was invoked. + */ + .align ARM_TRAMP_MAP_SHIFT +ARM_FUNC_START(trampoline_code_table) + .rept ARM_TRAMP_MAP_SIZE / ARM_TRAMP_SIZE + sub sp, sp, #8 /* Make space on the stack */ + str ip, [sp] /* Save ip on stack */ + ldr ip, [pc, #4080] /* Copy data into ip */ + str ip, [sp, #4] /* Save data on stack */ + ldr pc, [pc, #4076] /* Copy code into PC */ + .endr +ARM_FUNC_END(trampoline_code_table) + .align ARM_TRAMP_MAP_SHIFT +#endif /* FFI_EXEC_STATIC_TRAMP */ + #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ diff --git a/src/closures.c b/src/closures.c index dfc2f68b2..3a63c32da 100644 --- a/src/closures.c +++ b/src/closures.c @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef __NetBSD__ #include @@ -112,6 +113,12 @@ ffi_closure_free (void *ptr) munmap(dataseg, rounded_size); munmap(codeseg, rounded_size); } + +int +ffi_tramp_is_present (__attribute__((unused)) void *ptr) +{ + return 0; +} #else /* !NetBSD with PROT_MPROTECT */ #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE @@ -860,6 +867,12 @@ dlmmap (void *start, size_t length, int prot, && flags == (MAP_PRIVATE | MAP_ANONYMOUS) && fd == -1 && offset == 0); + if (execfd == -1 && ffi_tramp_is_supported ()) + { + ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); + return ptr; + } + if (execfd == -1 && is_emutramp_enabled ()) { ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset); @@ -939,7 +952,7 @@ segment_holding_code (mstate m, char* addr) void * ffi_closure_alloc (size_t size, void **code) { - void *ptr; + void *ptr, *ftramp; if (!code) return NULL; @@ -951,6 +964,17 @@ ffi_closure_alloc (size_t size, void **code) msegmentptr seg = segment_holding (gm, ptr); *code = add_segment_exec_offset (ptr, seg); + if (!ffi_tramp_is_supported ()) + return ptr; + + ftramp = ffi_tramp_alloc (0); + if (ftramp == NULL) + { + dlfree (FFI_RESTORE_PTR (ptr)); + return NULL; + } + *code = ffi_tramp_get_addr (ftramp); + ((ffi_closure *) ptr)->ftramp = ftramp; } return ptr; @@ -965,7 +989,11 @@ ffi_data_to_code_pointer (void *data) burden of managing this memory themselves, in which case this we'll just return data. */ if (seg) - return add_segment_exec_offset (data, seg); + { + if (!ffi_tramp_is_supported ()) + return add_segment_exec_offset (data, seg); + return ffi_tramp_get_addr (((ffi_closure *) data)->ftramp); + } else return data; } @@ -983,10 +1011,19 @@ ffi_closure_free (void *ptr) if (seg) ptr = sub_segment_exec_offset (ptr, seg); #endif + if (ffi_tramp_is_supported ()) + ffi_tramp_free (((ffi_closure *) ptr)->ftramp); dlfree (FFI_RESTORE_PTR (ptr)); } +int +ffi_tramp_is_present (void *ptr) +{ + msegmentptr seg = segment_holding (gm, ptr); + return seg != NULL && ffi_tramp_is_supported(); +} + # else /* ! FFI_MMAP_EXEC_WRIT */ /* On many systems, memory returned by malloc is writable and @@ -1015,6 +1052,12 @@ ffi_data_to_code_pointer (void *data) return data; } +int +ffi_tramp_is_present (__attribute__((unused)) void *ptr) +{ + return 0; +} + # endif /* ! FFI_MMAP_EXEC_WRIT */ #endif /* FFI_CLOSURES */ diff --git a/src/tramp.c b/src/tramp.c new file mode 100644 index 000000000..265aeaa3c --- /dev/null +++ b/src/tramp.c @@ -0,0 +1,729 @@ +/* ----------------------------------------------------------------------- + tramp.c - Copyright (c) 2020 Madhavan T. Venkataraman + + API and support functions for managing statically defined closure + trampolines. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ + +#include + +#ifdef FFI_EXEC_STATIC_TRAMP + +/* -------------------------- Headers and Definitions ---------------------*/ +/* + * Add support for other OSes later. For now, it is just Linux. + */ + +#if defined __linux__ +#ifdef __linux__ +#define _GNU_SOURCE 1 +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __linux__ +#include +#include +#endif +#endif /* __linux__ */ + +/* + * Each architecture defines static code for a trampoline code table. The + * trampoline code table is mapped into the address space of a process. + * + * The following architecture specific function returns: + * + * - the address of the trampoline code table in the text segment + * - the size of each trampoline in the trampoline code table + * - the size of the mapping for the whole trampoline code table + */ +void __attribute__((weak)) *ffi_tramp_arch (size_t *tramp_size, + size_t *map_size); + +/* ------------------------- Trampoline Data Structures --------------------*/ + +struct tramp; + +/* + * Trampoline table. Manages one trampoline code table and one trampoline + * parameter table. + * + * prev, next Links in the global trampoline table list. + * code_table Trampoline code table mapping. + * parm_table Trampoline parameter table mapping. + * array Array of trampolines malloced. + * free List of free trampolines. + * nfree Number of free trampolines. + */ +struct tramp_table +{ + struct tramp_table *prev; + struct tramp_table *next; + void *code_table; + void *parm_table; + struct tramp *array; + struct tramp *free; + int nfree; +}; + +/* + * Parameters for each trampoline. + * + * data + * Data for the target code that the trampoline jumps to. + * target + * Target code that the trampoline jumps to. + */ +struct tramp_parm +{ + void *data; + void *target; +}; + +/* + * Trampoline structure for each trampoline. + * + * prev, next Links in the trampoline free list of a trampoline table. + * table Trampoline table to which this trampoline belongs. + * code Address of this trampoline in the code table mapping. + * parm Address of this trampoline's parameters in the parameter + * table mapping. + */ +struct tramp +{ + struct tramp *prev; + struct tramp *next; + struct tramp_table *table; + void *code; + struct tramp_parm *parm; +}; + +enum tramp_globals_status { + TRAMP_GLOBALS_UNINITIALIZED = 0, + TRAMP_GLOBALS_PASSED, + TRAMP_GLOBALS_FAILED, +}; + +/* + * Trampoline globals. + * + * fd + * File descriptor of binary file that contains the trampoline code table. + * offset + * Offset of the trampoline code table in that file. + * text + * Address of the trampoline code table in the text segment. + * map_size + * Size of the trampoline code table mapping. + * size + * Size of one trampoline in the trampoline code table. + * ntramp + * Total number of trampolines in the trampoline code table. + * free_tables + * List of trampoline tables that contain free trampolines. + * nfree_tables + * Number of trampoline tables that contain free trampolines. + * status + * Initialization status. + */ +struct tramp_globals +{ + int fd; + off_t offset; + void *text; + size_t map_size; + size_t size; + int ntramp; + struct tramp_table *free_tables; + int nfree_tables; + enum tramp_globals_status status; +}; + +static struct tramp_globals tramp_globals; + +/* --------------------- Trampoline File Initialization --------------------*/ + +/* + * The trampoline file is the file used to map the trampoline code table into + * the address space of a process. There are two ways to get this file: + * + * - From the OS. E.g., on Linux, /proc//maps lists all the memory + * mappings for . For file-backed mappings, maps supplies the file name + * and the file offset. Using this, we can locate the mapping that maps + * libffi and get the path to the libffi binary. And, we can compute the + * offset of the trampoline code table within that binary. + * + * - Else, if we can create a temporary file, we can write the trampoline code + * table from the text segment into the temporary file. + * + * The first method is the preferred one. If the OS security subsystem + * disallows mapping unsigned files with PROT_EXEC, then the second method + * will fail. + * + * If an OS allows the trampoline code table in the text segment to be + * directly remapped (e.g., MACH vm_remap ()), then we don't need the + * trampoline file. + */ +static int tramp_table_alloc (void); + +#if defined __linux__ + +static int +ffi_tramp_get_libffi (void) +{ + FILE *fp; + char file[PATH_MAX], line[PATH_MAX+100], perm[10], dev[10]; + unsigned long start, end, offset, inode; + uintptr_t addr = (uintptr_t) tramp_globals.text; + int nfields, found; + + snprintf (file, PATH_MAX, "/proc/%d/maps", getpid()); + fp = fopen (file, "r"); + if (fp == NULL) + return 0; + + found = 0; + while (feof (fp) == 0) { + if (fgets (line, sizeof (line), fp) == 0) + break; + + nfields = sscanf (line, "%lx-%lx %9s %lx %9s %ld %s", + &start, &end, perm, &offset, dev, &inode, file); + if (nfields != 7) + continue; + + if (addr >= start && addr < end) { + tramp_globals.offset = offset + (addr - start); + found = 1; + break; + } + } + fclose (fp); + + if (!found) + return 0; + + tramp_globals.fd = open (file, O_RDONLY); + if (tramp_globals.fd == -1) + return 0; + + /* + * Allocate a trampoline table just to make sure that the trampoline code + * table can be mapped. + */ + if (!tramp_table_alloc ()) + { + close (tramp_globals.fd); + tramp_globals.fd = -1; + return 0; + } + return 1; +} + +#endif /* __linux__ */ + +#if defined __linux__ + +#if defined HAVE_MKSTEMP + +static int +ffi_tramp_get_temp_file (void) +{ + char template[12] = "/tmp/XXXXXX"; + ssize_t count; + + tramp_globals.offset = 0; + tramp_globals.fd = mkstemp (template); + if (tramp_globals.fd == -1) + return 0; + + unlink (template); + /* + * Write the trampoline code table into the temporary file and allocate a + * trampoline table to make sure that the temporary file can be mapped. + */ + count = write(tramp_globals.fd, tramp_globals.text, tramp_globals.map_size); + if (count == tramp_globals.map_size && tramp_table_alloc ()) + return 1; + + close (tramp_globals.fd); + tramp_globals.fd = -1; + return 0; +} + +#else /* !defined HAVE_MKSTEMP */ + +/* + * TODO: + * src/closures.c contains code for finding temp file that has EXEC + * permissions. May be, some of that code can be shared with static + * trampolines. + */ +static int +ffi_tramp_get_temp_file (void) +{ + tramp_globals.offset = 0; + tramp_globals.fd = -1; + return 0; +} + +#endif /* defined HAVE_MKSTEMP */ + +#endif /* __linux__ */ + +/* ------------------------ OS-specific Initialization ----------------------*/ + +#if defined __linux__ + +static int +ffi_tramp_init_os (void) +{ + if (ffi_tramp_get_libffi ()) + return 1; + return ffi_tramp_get_temp_file (); +} + +#endif /* __linux__ */ + +/* --------------------------- OS-specific Locking -------------------------*/ + +#if defined __linux__ + +static pthread_mutex_t tramp_globals_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void +ffi_tramp_lock(void) +{ + pthread_mutex_lock (&tramp_globals_mutex); +} + +static void +ffi_tramp_unlock() +{ + pthread_mutex_unlock (&tramp_globals_mutex); +} + +#endif /* __linux__ */ + +/* ------------------------ OS-specific Memory Mapping ----------------------*/ + +/* + * Create a trampoline code table mapping and a trampoline parameter table + * mapping. The two mappings must be adjacent to each other for PC-relative + * access. + * + * For each trampoline in the code table, there is a corresponding parameter + * block in the parameter table. The size of the parameter block is the same + * as the size of the trampoline. This means that the parameter block is at + * a fixed offset from its trampoline making it easy for a trampoline to find + * its parameters using PC-relative access. + * + * The parameter block will contain a struct tramp_parm. This means that + * sizeof (struct tramp_parm) cannot exceed the size of a parameter block. + */ + +#if defined __linux__ + +static int +tramp_table_map (struct tramp_table *table) +{ + char *addr; + + /* + * Create an anonymous mapping twice the map size. The top half will be used + * for the code table. The bottom half will be used for the parameter table. + */ + addr = mmap (NULL, tramp_globals.map_size * 2, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (addr == MAP_FAILED) + return 0; + + /* + * Replace the top half of the anonymous mapping with the code table mapping. + */ + table->code_table = mmap (addr, tramp_globals.map_size, PROT_READ | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, tramp_globals.fd, tramp_globals.offset); + if (table->code_table == MAP_FAILED) + { + (void) munmap (addr, tramp_globals.map_size * 2); + return 0; + } + table->parm_table = table->code_table + tramp_globals.map_size; + return 1; +} + +static void +tramp_table_unmap (struct tramp_table *table) +{ + (void) munmap (table->code_table, tramp_globals.map_size); + (void) munmap (table->parm_table, tramp_globals.map_size); +} + +#endif /* __linux__ */ + +/* ------------------------ Trampoline Initialization ----------------------*/ + +/* + * Initialize the static trampoline feature. + */ +static int +ffi_tramp_init (void) +{ + if (tramp_globals.status == TRAMP_GLOBALS_PASSED) + return 1; + + if (tramp_globals.status == TRAMP_GLOBALS_FAILED) + return 0; + + if (ffi_tramp_arch == NULL) + { + tramp_globals.status = TRAMP_GLOBALS_FAILED; + return 0; + } + + tramp_globals.free_tables = NULL; + tramp_globals.nfree_tables = 0; + + /* + * Get trampoline code table information from the architecture. + */ + tramp_globals.text = ffi_tramp_arch (&tramp_globals.size, + &tramp_globals.map_size); + tramp_globals.ntramp = tramp_globals.map_size / tramp_globals.size; + + if (sysconf (_SC_PAGESIZE) > tramp_globals.map_size) + return 0; + + if (ffi_tramp_init_os ()) + { + tramp_globals.status = TRAMP_GLOBALS_PASSED; + return 1; + } + + tramp_globals.status = TRAMP_GLOBALS_FAILED; + return 0; +} + +/* ---------------------- Trampoline Table functions ---------------------- */ + +/* This code assumes that malloc () is available on all OSes. */ + +static void tramp_add (struct tramp *tramp); + +/* + * Allocate and initialize a trampoline table. + */ +static int +tramp_table_alloc (void) +{ + struct tramp_table *table; + struct tramp *tramp_array, *tramp; + size_t size; + char *code, *parm; + int i; + + /* + * If we already have tables with free trampolines, there is no need to + * allocate a new table. + */ + if (tramp_globals.nfree_tables > 0) + return 1; + + /* + * Allocate a new trampoline table structure. + */ + table = malloc (sizeof (*table)); + if (table == NULL) + return 0; + + /* + * Allocate new trampoline structures. + */ + tramp_array = malloc (sizeof (*tramp) * tramp_globals.ntramp); + if (tramp_array == NULL) + goto free_table; + + /* + * Map a code table and a parameter table into the caller's address space. + */ + if (!tramp_table_map (table)) + { + /* + * Failed to map the code and parameter tables. + */ + goto free_tramp_array; + } + + /* + * Initialize the trampoline table. + */ + table->array = tramp_array; + table->free = NULL; + table->nfree = 0; + + /* + * Populate the trampoline table free list. This will also add the trampoline + * table to the global list of trampoline tables. + */ + size = tramp_globals.size; + code = table->code_table; + parm = table->parm_table; + for (i = 0; i < tramp_globals.ntramp; i++) + { + tramp = &tramp_array[i]; + tramp->table = table; + tramp->code = code; + tramp->parm = (struct tramp_parm *) parm; + tramp_add (tramp); + + code += size; + parm += size; + } + /* Success */ + return 1; + +/* Failure */ +free_tramp_array: + free (tramp_array); +free_table: + free (table); + return 0; +} + +/* + * Free a trampoline table. + */ +static void +tramp_table_free (struct tramp_table *table) +{ + tramp_table_unmap (table); + free (table->array); + free (table); +} + +/* + * Add a new trampoline table to the global table list. + */ +static void +tramp_table_add (struct tramp_table *table) +{ + table->next = tramp_globals.free_tables; + table->prev = NULL; + if (tramp_globals.free_tables != NULL) + tramp_globals.free_tables->prev = table; + tramp_globals.free_tables = table; + tramp_globals.nfree_tables++; +} + +/* + * Delete a trampoline table from the global table list. + */ +static void +tramp_table_del (struct tramp_table *table) +{ + tramp_globals.nfree_tables--; + if (table->prev != NULL) + table->prev->next = table->next; + if (table->next != NULL) + table->next->prev = table->prev; + if (tramp_globals.free_tables == table) + tramp_globals.free_tables = table->next; +} + +/* ------------------------- Trampoline functions ------------------------- */ + +/* + * Add a trampoline to its trampoline table. + */ +static void +tramp_add (struct tramp *tramp) +{ + struct tramp_table *table = tramp->table; + + tramp->next = table->free; + tramp->prev = NULL; + if (table->free != NULL) + table->free->prev = tramp; + table->free = tramp; + table->nfree++; + + if (table->nfree == 1) + tramp_table_add (table); + + /* + * We don't want to keep too many free trampoline tables lying around. + */ + if (table->nfree == tramp_globals.ntramp && + tramp_globals.nfree_tables > 1) + { + tramp_table_del (table); + tramp_table_free (table); + } +} + +/* + * Remove a trampoline from its trampoline table. + */ +static void +tramp_del (struct tramp *tramp) +{ + struct tramp_table *table = tramp->table; + + table->nfree--; + if (tramp->prev != NULL) + tramp->prev->next = tramp->next; + if (tramp->next != NULL) + tramp->next->prev = tramp->prev; + if (table->free == tramp) + table->free = tramp->next; + + if (table->nfree == 0) + tramp_table_del (table); +} + +/* ------------------------ Trampoline API functions ------------------------ */ + +int +ffi_tramp_is_supported(void) +{ + int ret; + + ffi_tramp_lock(); + ret = ffi_tramp_init (); + ffi_tramp_unlock(); + return ret; +} + +/* + * Allocate a trampoline and return its opaque address. + */ +void * +ffi_tramp_alloc (int flags) +{ + struct tramp *tramp; + + ffi_tramp_lock(); + + if (!ffi_tramp_init () || flags != 0) + { + ffi_tramp_unlock(); + return NULL; + } + + if (!tramp_table_alloc ()) + { + ffi_tramp_unlock(); + return NULL; + } + + tramp = tramp_globals.free_tables->free; + tramp_del (tramp); + + ffi_tramp_unlock(); + + return tramp; +} + +/* + * Set the parameters for a trampoline. + */ +void +ffi_tramp_set_parms (void *arg, void *target, void *data) +{ + struct tramp *tramp = arg; + + ffi_tramp_lock(); + tramp->parm->target = target; + tramp->parm->data = data; + ffi_tramp_unlock(); +} + +/* + * Get the invocation address of a trampoline. + */ +void * +ffi_tramp_get_addr (void *arg) +{ + struct tramp *tramp = arg; + void *addr; + + ffi_tramp_lock(); + addr = tramp->code; + ffi_tramp_unlock(); + + return addr; +} + +/* + * Free a trampoline. + */ +void +ffi_tramp_free (void *arg) +{ + struct tramp *tramp = arg; + + ffi_tramp_lock(); + tramp_add (tramp); + ffi_tramp_unlock(); +} + +/* ------------------------------------------------------------------------- */ + +#else /* !FFI_EXEC_STATIC_TRAMP */ + +#include + +int +ffi_tramp_is_supported(void) +{ + return 0; +} + +void * +ffi_tramp_alloc (int flags) +{ + return NULL; +} + +void +ffi_tramp_set_parms (void *arg, void *target, void *data) +{ +} + +void * +ffi_tramp_get_addr (void *arg) +{ + return NULL; +} + +void +ffi_tramp_free (void *arg) +{ +} + +#endif /* FFI_EXEC_STATIC_TRAMP */ diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 5f7fd81d9..b4d0d3908 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "internal.h" /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE; @@ -411,6 +412,11 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, void FFI_HIDDEN ffi_closure_i386(void); void FFI_HIDDEN ffi_closure_STDCALL(void); void FFI_HIDDEN ffi_closure_REGISTER(void); +#if defined(FFI_EXEC_STATIC_TRAMP) +void FFI_HIDDEN ffi_closure_i386_alt(void); +void FFI_HIDDEN ffi_closure_STDCALL_alt(void); +void FFI_HIDDEN ffi_closure_REGISTER_alt(void); +#endif struct closure_frame { @@ -559,6 +565,22 @@ ffi_prep_closure_loc (ffi_closure* closure, return FFI_BAD_ABI; } +#if defined(FFI_EXEC_STATIC_TRAMP) + if (ffi_tramp_is_present(closure)) + { + /* Initialize the static trampoline's parameters. */ + if (dest == ffi_closure_i386) + dest = ffi_closure_i386_alt; + else if (dest == ffi_closure_STDCALL) + dest = ffi_closure_STDCALL_alt; + else + dest = ffi_closure_REGISTER_alt; + ffi_tramp_set_parms (closure->ftramp, dest, closure); + goto out; + } +#endif + + /* Initialize the dynamic trampoline. */ /* endbr32. */ *(UINT32 *) tramp = 0xfb1e0ff3; @@ -570,6 +592,7 @@ ffi_prep_closure_loc (ffi_closure* closure, tramp[9] = 0xe9; *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14); +out: closure->cif = cif; closure->fun = fun; closure->user_data = user_data; @@ -767,4 +790,17 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue) ffi_call_i386 (frame, stack); } #endif /* !FFI_NO_RAW_API */ + +#if defined(FFI_EXEC_STATIC_TRAMP) +void * +ffi_tramp_arch (size_t *tramp_size, size_t *map_size) +{ + extern void *trampoline_code_table; + + *map_size = X86_TRAMP_MAP_SIZE; + *tramp_size = X86_TRAMP_SIZE; + return &trampoline_code_table; +} +#endif + #endif /* __i386__ */ diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index 39f95981b..5264cdf2f 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "internal64.h" #ifdef __x86_64__ @@ -714,6 +715,10 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, extern void ffi_closure_unix64(void) FFI_HIDDEN; extern void ffi_closure_unix64_sse(void) FFI_HIDDEN; +#if defined(FFI_EXEC_STATIC_TRAMP) +extern void ffi_closure_unix64_alt(void) FFI_HIDDEN; +extern void ffi_closure_unix64_sse_alt(void) FFI_HIDDEN; +#endif #ifndef __ILP32__ extern ffi_status @@ -756,9 +761,24 @@ ffi_prep_closure_loc (ffi_closure* closure, else dest = ffi_closure_unix64; +#if defined(FFI_EXEC_STATIC_TRAMP) + if (ffi_tramp_is_present(closure)) + { + /* Initialize the static trampoline's parameters. */ + if (dest == ffi_closure_unix64_sse) + dest = ffi_closure_unix64_sse_alt; + else + dest = ffi_closure_unix64_alt; + ffi_tramp_set_parms (closure->ftramp, dest, closure); + goto out; + } +#endif + + /* Initialize the dynamic trampoline. */ memcpy (tramp, trampoline, sizeof(trampoline)); *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest; +out: closure->cif = cif; closure->fun = fun; closure->user_data = user_data; @@ -892,4 +912,16 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, #endif /* FFI_GO_CLOSURES */ +#if defined(FFI_EXEC_STATIC_TRAMP) +void * +ffi_tramp_arch (size_t *tramp_size, size_t *map_size) +{ + extern void *trampoline_code_table; + + *map_size = UNIX64_TRAMP_MAP_SIZE; + *tramp_size = UNIX64_TRAMP_SIZE; + return &trampoline_code_table; +} +#endif + #endif /* __x86_64__ */ diff --git a/src/x86/ffitarget.h b/src/x86/ffitarget.h index a34f3e5b7..f454341a2 100644 --- a/src/x86/ffitarget.h +++ b/src/x86/ffitarget.h @@ -147,9 +147,11 @@ typedef enum ffi_abi { # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ #endif -#if !defined(GENERATE_LIBFFI_MAP) && defined(__ASSEMBLER__) \ - && defined(__CET__) +#if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__) # include +# if (__CET__ & 1) != 0 +# define ENDBR_PRESENT +# endif # define _CET_NOTRACK notrack #else # define _CET_ENDBR diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index a43a9ebe9..6c28d59b1 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef X86_WIN64 #define EFI64(name) name @@ -187,6 +188,9 @@ EFI64(ffi_call_go)(ffi_cif *cif, void (*fn)(void), void *rvalue, extern void ffi_closure_win64(void) FFI_HIDDEN; +#if defined(FFI_EXEC_STATIC_TRAMP) +extern void ffi_closure_win64_alt(void) FFI_HIDDEN; +#endif #ifdef FFI_GO_CLOSURES extern void ffi_go_closure_win64(void) FFI_HIDDEN; @@ -220,9 +224,20 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure, return FFI_BAD_ABI; } +#if defined(FFI_EXEC_STATIC_TRAMP) + if (ffi_tramp_is_present(closure)) + { + /* Initialize the static trampoline's parameters. */ + ffi_tramp_set_parms (closure->ftramp, ffi_closure_win64_alt, closure); + goto out; + } +#endif + + /* Initialize the dynamic trampoline. */ memcpy (tramp, trampoline, sizeof(trampoline)); *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64; +out: closure->cif = cif; closure->fun = fun; closure->user_data = user_data; diff --git a/src/x86/internal.h b/src/x86/internal.h index 09771ba8c..23be7a223 100644 --- a/src/x86/internal.h +++ b/src/x86/internal.h @@ -27,3 +27,17 @@ #else # define HAVE_FASTCALL 1 #endif + +#if defined(FFI_EXEC_STATIC_TRAMP) +/* + * For the trampoline code table mapping, a mapping size of 4K (base page size) + * is chosen. + */ +#define X86_TRAMP_MAP_SHIFT 12 +#define X86_TRAMP_MAP_SIZE (1 << X86_TRAMP_MAP_SHIFT) +#ifdef ENDBR_PRESENT +#define X86_TRAMP_SIZE 44 +#else +#define X86_TRAMP_SIZE 40 +#endif +#endif diff --git a/src/x86/internal64.h b/src/x86/internal64.h index 512e95523..282b40802 100644 --- a/src/x86/internal64.h +++ b/src/x86/internal64.h @@ -20,3 +20,17 @@ #define UNIX64_FLAG_RET_IN_MEM (1 << 10) #define UNIX64_FLAG_XMM_ARGS (1 << 11) #define UNIX64_SIZE_SHIFT 12 + +#if defined(FFI_EXEC_STATIC_TRAMP) +/* + * For the trampoline code table mapping, a mapping size of 4K (base page size) + * is chosen. + */ +#define UNIX64_TRAMP_MAP_SHIFT 12 +#define UNIX64_TRAMP_MAP_SIZE (1 << UNIX64_TRAMP_MAP_SHIFT) +#ifdef ENDBR_PRESENT +#define UNIX64_TRAMP_SIZE 40 +#else +#define UNIX64_TRAMP_SIZE 32 +#endif +#endif diff --git a/src/x86/sysv.S b/src/x86/sysv.S index d8ab4b026..7110f02f5 100644 --- a/src/x86/sysv.S +++ b/src/x86/sysv.S @@ -573,6 +573,94 @@ L(UW31): # cfi_endproc ENDF(C(ffi_closure_STDCALL)) +#if defined(FFI_EXEC_STATIC_TRAMP) + .balign 16 + .globl C(ffi_closure_i386_alt) + FFI_HIDDEN(C(ffi_closure_i386_alt)) +C(ffi_closure_i386_alt): + /* See the comments above trampoline_code_table. */ + _CET_ENDBR + movl 4(%esp), %eax /* Load closure in eax */ + add $8, %esp /* Restore the stack */ + jmp C(ffi_closure_i386) +ENDF(C(ffi_closure_i386_alt)) + + .balign 16 + .globl C(ffi_closure_REGISTER_alt) + FFI_HIDDEN(C(ffi_closure_REGISTER_alt)) +C(ffi_closure_REGISTER_alt): + /* See the comments above trampoline_code_table. */ + _CET_ENDBR + movl (%esp), %eax /* Restore eax */ + add $4, %esp /* Leave closure on stack */ + jmp C(ffi_closure_REGISTER) +ENDF(C(ffi_closure_REGISTER_alt)) + + .balign 16 + .globl C(ffi_closure_STDCALL_alt) + FFI_HIDDEN(C(ffi_closure_STDCALL_alt)) +C(ffi_closure_STDCALL_alt): + /* See the comments above trampoline_code_table. */ + _CET_ENDBR + movl 4(%esp), %eax /* Load closure in eax */ + add $8, %esp /* Restore the stack */ + jmp C(ffi_closure_STDCALL) +ENDF(C(ffi_closure_STDCALL_alt)) + +/* + * Below is the definition of the trampoline code table. Each element in + * the code table is a trampoline. + * + * Because we jump to the trampoline, we place a _CET_ENDBR at the + * beginning of the trampoline to mark it as a valid branch target. This is + * part of the the Intel CET (Control Flow Enforcement Technology). + */ +/* + * The trampoline uses register eax. It saves the original value of eax on + * the stack. + * + * The trampoline has two parameters - target code to jump to and data for + * the target code. The trampoline extracts the parameters from its parameter + * block (see tramp_table_map()). The trampoline saves the data address on + * the stack. Finally, it jumps to the target code. + * + * The target code can choose to: + * + * - restore the value of eax + * - load the data address in a register + * - restore the stack pointer to what it was when the trampoline was invoked. + */ +#ifdef ENDBR_PRESENT +#define X86_DATA_OFFSET 4081 +#define X86_CODE_OFFSET 4070 +#else +#define X86_DATA_OFFSET 4085 +#define X86_CODE_OFFSET 4074 +#endif + + .align X86_TRAMP_MAP_SIZE + .globl C(trampoline_code_table) + FFI_HIDDEN(C(trampoline_code_table)) +C(trampoline_code_table): + .rept X86_TRAMP_MAP_SIZE / X86_TRAMP_SIZE + _CET_ENDBR + sub $8, %esp + movl %eax, (%esp) /* Save %eax on stack */ + call 1f /* Get next PC into %eax */ + movl X86_DATA_OFFSET(%eax), %eax /* Copy data into %eax */ + movl %eax, 4(%esp) /* Save data on stack */ + call 1f /* Get next PC into %eax */ + movl X86_CODE_OFFSET(%eax), %eax /* Copy code into %eax */ + jmp *%eax /* Jump to code */ +1: + mov (%esp), %eax + ret + .align 4 + .endr +ENDF(C(trampoline_code_table)) + .align X86_TRAMP_MAP_SIZE +#endif /* FFI_EXEC_STATIC_TRAMP */ + #if !FFI_NO_RAW_API #define raw_closure_S_FS (16+16+12) @@ -1131,6 +1219,7 @@ L(EFDE9): #endif /* __APPLE__ */ #endif /* ifndef _MSC_VER */ + #endif /* ifdef __i386__ */ #if defined __ELF__ && defined __linux__ diff --git a/src/x86/unix64.S b/src/x86/unix64.S index 89d7db11f..ca6fe0cb4 100644 --- a/src/x86/unix64.S +++ b/src/x86/unix64.S @@ -456,6 +456,81 @@ L(sse_entry2): L(UW17): ENDF(C(ffi_go_closure_unix64)) +#if defined(FFI_EXEC_STATIC_TRAMP) + .balign 8 + .globl C(ffi_closure_unix64_sse_alt) + FFI_HIDDEN(C(ffi_closure_unix64_sse_alt)) + +C(ffi_closure_unix64_sse_alt): + /* See the comments above trampoline_code_table. */ + _CET_ENDBR + movq 8(%rsp), %r10 /* Load closure in r10 */ + addq $16, %rsp /* Restore the stack */ + jmp C(ffi_closure_unix64_sse) +ENDF(C(ffi_closure_unix64_sse_alt)) + + .balign 8 + .globl C(ffi_closure_unix64_alt) + FFI_HIDDEN(C(ffi_closure_unix64_alt)) + +C(ffi_closure_unix64_alt): + /* See the comments above trampoline_code_table. */ + _CET_ENDBR + movq 8(%rsp), %r10 /* Load closure in r10 */ + addq $16, %rsp /* Restore the stack */ + jmp C(ffi_closure_unix64) + ENDF(C(ffi_closure_unix64_alt)) + +/* + * Below is the definition of the trampoline code table. Each element in + * the code table is a trampoline. + * + * Because we jump to the trampoline, we place a _CET_ENDBR at the + * beginning of the trampoline to mark it as a valid branch target. This is + * part of the the Intel CET (Control Flow Enforcement Technology). + */ +/* + * The trampoline uses register r10. It saves the original value of r10 on + * the stack. + * + * The trampoline has two parameters - target code to jump to and data for + * the target code. The trampoline extracts the parameters from its parameter + * block (see tramp_table_map()). The trampoline saves the data address on + * the stack. Finally, it jumps to the target code. + * + * The target code can choose to: + * + * - restore the value of r10 + * - load the data address in a register + * - restore the stack pointer to what it was when the trampoline was invoked. + */ +#ifdef ENDBR_PRESENT +#define X86_DATA_OFFSET 4077 +#define X86_CODE_OFFSET 4073 +#else +#define X86_DATA_OFFSET 4081 +#define X86_CODE_OFFSET 4077 +#endif + + .align UNIX64_TRAMP_MAP_SIZE + .globl trampoline_code_table + FFI_HIDDEN(C(trampoline_code_table)) + +C(trampoline_code_table): + .rept UNIX64_TRAMP_MAP_SIZE / UNIX64_TRAMP_SIZE + _CET_ENDBR + subq $16, %rsp /* Make space on the stack */ + movq %r10, (%rsp) /* Save %r10 on stack */ + movq X86_DATA_OFFSET(%rip), %r10 /* Copy data into %r10 */ + movq %r10, 8(%rsp) /* Save data on stack */ + movq X86_CODE_OFFSET(%rip), %r10 /* Copy code into %r10 */ + jmp *%r10 /* Jump to code */ + .align 8 + .endr +ENDF(C(trampoline_code_table)) + .align UNIX64_TRAMP_MAP_SIZE +#endif /* FFI_EXEC_STATIC_TRAMP */ + /* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ #ifdef __APPLE__ diff --git a/src/x86/win64.S b/src/x86/win64.S index 8315e8b75..f3ace8d07 100644 --- a/src/x86/win64.S +++ b/src/x86/win64.S @@ -234,6 +234,20 @@ C(ffi_closure_win64): cfi_endproc SEH(.seh_endproc) + +#if defined(FFI_EXEC_STATIC_TRAMP) + .align 8 + .globl C(ffi_closure_win64_alt) + FFI_HIDDEN(C(ffi_closure_win64_alt)) + + SEH(.seh_proc ffi_closure_win64_alt) +C(ffi_closure_win64_alt): + _CET_ENDBR + movq 8(%rsp), %r10 + addq $16, %rsp + jmp C(ffi_closure_win64) + SEH(.seh_endproc) +#endif #endif /* __x86_64__ */ #if defined __ELF__ && defined __linux__ diff --git a/testsuite/libffi.closures/closure_loc_fn0.c b/testsuite/libffi.closures/closure_loc_fn0.c index b3afa0bbd..ad488acaa 100644 --- a/testsuite/libffi.closures/closure_loc_fn0.c +++ b/testsuite/libffi.closures/closure_loc_fn0.c @@ -83,7 +83,10 @@ int main (void) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0, (void *) 3 /* userdata */, codeloc) == FFI_OK); +#ifndef FFI_EXEC_STATIC_TRAMP + /* With static trampolines, the codeloc does not point to closure */ CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0); +#endif res = (*((closure_loc_test_type0)codeloc)) (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13, From bae695da367b6abd83152f8f1e9b1a8b79794c8d Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 6 Mar 2021 00:09:17 +0800 Subject: [PATCH 162/231] Add configuration generator for tvOS and watchOS. (#625) --- generate-darwin-source-and-headers.py | 107 ++++++++++++++++++++------ 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py index 516464f52..9921b0d99 100755 --- a/generate-darwin-source-and-headers.py +++ b/generate-darwin-source-and-headers.py @@ -6,15 +6,14 @@ import glob import argparse + class Platform(object): pass + class simulator_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphonesimulator' arch = 'i386' triple = 'i386-apple-darwin11' - version_min = '-miphoneos-version-min=7.0' prefix = "#ifdef __i386__\n\n" suffix = "\n\n#endif" @@ -23,11 +22,8 @@ class simulator_platform(Platform): class simulator64_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphonesimulator' arch = 'x86_64' triple = 'x86_64-apple-darwin13' - version_min = '-miphoneos-version-min=7.0' prefix = "#ifdef __x86_64__\n\n" suffix = "\n\n#endif" @@ -36,11 +32,8 @@ class simulator64_platform(Platform): class device_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphoneos' arch = 'armv7' triple = 'arm-apple-darwin11' - version_min = '-miphoneos-version-min=7.0' prefix = "#ifdef __arm__\n\n" suffix = "\n\n#endif" @@ -49,11 +42,8 @@ class device_platform(Platform): class device64_platform(Platform): - directory = 'darwin_ios' - sdk = 'iphoneos' arch = 'arm64' triple = 'aarch64-apple-darwin13' - version_min = '-miphoneos-version-min=7.0' prefix = "#ifdef __arm64__\n\n" suffix = "\n\n#endif" @@ -61,6 +51,30 @@ class device64_platform(Platform): src_files = ['sysv.S', 'ffi.c', 'internal.h'] +class ios_simulator_platform(simulator_platform): + directory = 'darwin_ios' + sdk = 'iphonesimulator' + version_min = '-miphoneos-version-min=7.0' + + +class ios_simulator64_platform(simulator64_platform): + directory = 'darwin_ios' + sdk = 'iphonesimulator' + version_min = '-miphoneos-version-min=7.0' + + +class ios_device_platform(device_platform): + directory = 'darwin_ios' + sdk = 'iphoneos' + version_min = '-miphoneos-version-min=7.0' + + +class ios_device64_platform(device64_platform): + directory = 'darwin_ios' + sdk = 'iphoneos' + version_min = '-miphoneos-version-min=7.0' + + class desktop32_platform(Platform): directory = 'darwin_osx' sdk = 'macosx' @@ -87,6 +101,31 @@ class desktop64_platform(Platform): src_files = ['unix64.S', 'ffi64.c', 'ffiw64.c', 'win64.S', 'internal64.h', 'asmnames.h'] +class tvos_simulator64_platform(simulator64_platform): + directory = 'darwin_tvos' + sdk = 'appletvsimulator' + version_min = '-mtvos-version-min=9.0' + + +class tvos_device64_platform(device64_platform): + directory = 'darwin_tvos' + sdk = 'appletvos' + version_min = '-mtvos-version-min=9.0' + + +class watchos_simulator_platform(simulator_platform): + directory = 'darwin_watchos' + sdk = 'watchsimulator' + version_min = '-mwatchos-version-min=4.0' + + +class watchos_device_platform(device_platform): + directory = 'darwin_watchos' + sdk = 'watchos' + arch = 'armv7k' + version_min = '-mwatchos-version-min=4.0' + + def mkdir_p(path): try: os.makedirs(path) @@ -163,27 +202,44 @@ def xcrun_cmd(cmd): platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix)) -def generate_source_and_headers(generate_osx=True, generate_ios=True): +def generate_source_and_headers( + generate_osx=True, + generate_ios=True, + generate_tvos=True, + generate_watchos=True, +): copy_files('src', 'darwin_common/src', pattern='*.c') copy_files('include', 'darwin_common/include', pattern='*.h') if generate_ios: - copy_src_platform_files(simulator_platform) - copy_src_platform_files(simulator64_platform) - copy_src_platform_files(device_platform) - copy_src_platform_files(device64_platform) + copy_src_platform_files(ios_simulator_platform) + copy_src_platform_files(ios_simulator64_platform) + copy_src_platform_files(ios_device_platform) + copy_src_platform_files(ios_device64_platform) if generate_osx: copy_src_platform_files(desktop64_platform) + if generate_tvos: + copy_src_platform_files(tvos_simulator64_platform) + copy_src_platform_files(tvos_device64_platform) + if generate_watchos: + copy_src_platform_files(watchos_simulator_platform) + copy_src_platform_files(watchos_device_platform) platform_headers = collections.defaultdict(set) if generate_ios: - build_target(simulator_platform, platform_headers) - build_target(simulator64_platform, platform_headers) - build_target(device_platform, platform_headers) - build_target(device64_platform, platform_headers) + build_target(ios_simulator_platform, platform_headers) + build_target(ios_simulator64_platform, platform_headers) + build_target(ios_device_platform, platform_headers) + build_target(ios_device64_platform, platform_headers) if generate_osx: build_target(desktop64_platform, platform_headers) + if generate_tvos: + build_target(tvos_simulator64_platform, platform_headers) + build_target(tvos_device64_platform, platform_headers) + if generate_watchos: + build_target(watchos_simulator_platform, platform_headers) + build_target(watchos_device_platform, platform_headers) mkdir_p('darwin_common/include') for header_name, tag_tuples in platform_headers.items(): @@ -196,6 +252,13 @@ def generate_source_and_headers(generate_osx=True, generate_ios=True): parser = argparse.ArgumentParser() parser.add_argument('--only-ios', action='store_true', default=False) parser.add_argument('--only-osx', action='store_true', default=False) + parser.add_argument('--only-tvos', action='store_true', default=False) + parser.add_argument('--only-watchos', action='store_true', default=False) args = parser.parse_args() - generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx) + generate_source_and_headers( + generate_osx=not args.only_ios and not args.only_tvos and not args.only_watchos, + generate_ios=not args.only_osx and not args.only_tvos and not args.only_watchos, + generate_tvos=not args.only_ios and not args.only_osx and not args.only_watchos, + generate_watchos=not args.only_ios and not args.only_osx and not args.only_tvos, + ) From d271dbe0a8b230e566fa3385babdc9cc0ca214ea Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Sat, 20 Mar 2021 06:06:28 -0700 Subject: [PATCH 163/231] Add some missing #if conditionals from Apple's code drop (#620) * arm/aarch64: Add FFI_CLOSURES conditionals where appropriate Signed-off-by: Jeremy Huddleston Sequoia * aarch64: Don't emit the do_closure label when building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia --- src/aarch64/ffi.c | 4 ++++ src/aarch64/sysv.S | 5 +++++ src/arm/ffi.c | 4 ++++ src/arm/sysv.S | 3 +++ 4 files changed, 16 insertions(+) diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index 8e24a96ba..fccc7f262 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -770,6 +770,8 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue) ffi_call_int (cif, fn, rvalue, avalue, NULL); } +#if FFI_CLOSURES + #ifdef FFI_GO_CLOSURES void ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, @@ -1054,4 +1056,6 @@ ffi_tramp_arch (size_t *tramp_size, size_t *map_size) } #endif +#endif /* FFI_CLOSURES */ + #endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/ diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S index a3c15086a..bc10da840 100644 --- a/src/aarch64/sysv.S +++ b/src/aarch64/sysv.S @@ -213,6 +213,8 @@ CNAME(ffi_call_SYSV): .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV) #endif +#if FFI_CLOSURES + /* ffi_closure_SYSV Closure invocation glue. This is the low level code invoked directly by @@ -271,7 +273,9 @@ CNAME(ffi_closure_SYSV): /* Load ffi_closure_inner arguments. */ ldp PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */ ldr PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2] /* load user_data */ +#ifdef FFI_GO_CLOSURES .Ldo_closure: +#endif add x3, sp, #16 /* load context */ add x4, sp, #ffi_closure_SYSV_FS /* load stack */ add x5, sp, #16+CALL_CONTEXT_SIZE /* load rvalue */ @@ -513,6 +517,7 @@ CNAME(ffi_go_closure_SYSV): .size CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV) #endif #endif /* FFI_GO_CLOSURES */ +#endif /* FFI_CLOSURES */ #endif /* __arm64__ */ #if defined __ELF__ && defined __linux__ diff --git a/src/arm/ffi.c b/src/arm/ffi.c index 5ad59ce77..b2f60d16a 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -537,6 +537,8 @@ ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack, return rvalue; } +#if FFI_CLOSURES + struct closure_frame { char vfp_space[8*8] __attribute__((aligned(8))); @@ -686,6 +688,8 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif, } #endif +#endif /* FFI_CLOSURES */ + /* Below are routines for VFP hard-float support. */ /* A subroutine of vfp_type_p. Given a structure type, return the type code diff --git a/src/arm/sysv.S b/src/arm/sysv.S index 49c561eee..e816e32d5 100644 --- a/src/arm/sysv.S +++ b/src/arm/sysv.S @@ -208,6 +208,7 @@ E(ARM_TYPE_STRUCT) UNWIND(.fnend) ARM_FUNC_END(ffi_call_SYSV) +#if FFI_CLOSURES /* int ffi_closure_inner_* (cif, fun, user_data, frame) @@ -401,6 +402,8 @@ ARM_FUNC_END(trampoline_code_table) .align ARM_TRAMP_MAP_SHIFT #endif /* FFI_EXEC_STATIC_TRAMP */ +#endif /* FFI_CLOSURES */ + #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ From 205cf01b57972fdc8c090fc79192b464dc43fc0d Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 23 Mar 2021 11:31:08 -0400 Subject: [PATCH 164/231] Bug #680. Don't accept floats or small ints as var args. (#628) * Bug #680. Don't accept floats or small ints as var args. * Bug #680. Don't accept floats or small ints as var args. * Bug #680. Don't accept floats or small ints as var args. --- README.md | 109 ++++++------ doc/libffi.texi | 27 +-- include/ffi.h.in | 28 ++-- src/prep_cif.c | 23 ++- testsuite/libffi.call/va_1.c | 120 +------------ testsuite/libffi.call/va_2.c | 196 ++++++++++++++++++++++ testsuite/libffi.closures/cls_uchar_va.c | 44 ----- testsuite/libffi.closures/cls_ushort_va.c | 44 ----- 8 files changed, 305 insertions(+), 286 deletions(-) create mode 100644 testsuite/libffi.call/va_2.c delete mode 100644 testsuite/libffi.closures/cls_uchar_va.c delete mode 100644 testsuite/libffi.closures/cls_ushort_va.c diff --git a/README.md b/README.md index 4225d8534..23b10ce5c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ bridge from the interpreter program to compiled code. The libffi library provides a portable, high level programming interface to various calling conventions. This allows a programmer to call any function specified by a call interface description at run -time. +time. FFI stands for Foreign Function Interface. A foreign function interface is the popular name for the interface that allows code @@ -137,15 +137,15 @@ install autoconf, automake and libtool. You may want to tell configure where to install the libffi library and header files. To do that, use the ``--prefix`` configure switch. Libffi -will install under /usr/local by default. +will install under /usr/local by default. If you want to enable extra run-time debugging checks use the the ``--enable-debug`` configure switch. This is useful when your program dies -mysteriously while using libffi. +mysteriously while using libffi. Another useful configure switch is ``--enable-purify-safety``. Using this will add some extra code which will suppress certain warnings when you -are using Purify with libffi. Only use this switch when using +are using Purify with libffi. Only use this switch when using Purify, as it will slow down the library. If you don't want to build documentation, use the ``--disable-docs`` @@ -164,7 +164,7 @@ For 64-bit Windows builds, use ``CC="path/to/msvcc.sh -m64"`` and It is also possible to build libffi on Windows platforms with the LLVM project's clang-cl compiler, like below: - path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" + path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" When building with MSVC under a MingW environment, you may need to remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath' @@ -199,11 +199,14 @@ History See the git log for details at http://github.com/libffi/libffi. 3.4 TBD + Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. Add support for Intel Control-flow Enforcement Technology (CET). - Add support for ARM Pointer Authentication (PA). - Fix 32-bit PPC regression. - Fix MIPS soft-float problem. + Add support for ARM Pointer Authentication (PA). + Fix 32-bit PPC regression. + Fix MIPS soft-float problem. + Reject float and small integer argument in ffi_prep_cif_var(). + Callers must promote these types themselves. 3.3 Nov-23-19 Add RISC-V support. @@ -216,10 +219,10 @@ See the git log for details at http://github.com/libffi/libffi. Raw java (gcj) API deprecated. Add pre-built PDF documentation to source distribution. Many new test cases and bug fixes. - + 3.2.1 Nov-12-14 Build fix for non-iOS AArch64 targets. - + 3.2 Nov-11-14 Add C99 Complex Type support (currently only supported on s390). @@ -227,7 +230,7 @@ See the git log for details at http://github.com/libffi/libffi. Windows/Linux. Add OpenRISC and Cygwin-64 support. Bug fixes. - + 3.1 May-19-14 Add AArch64 (ARM64) iOS support. Add Nios II support. @@ -240,7 +243,7 @@ See the git log for details at http://github.com/libffi/libffi. failures, and respect the $CC and $CXX environment variables. Archive off the manually maintained ChangeLog in favor of git log. - + 3.0.13 Mar-17-13 Add Meta support. Add missing Moxie bits. @@ -250,7 +253,7 @@ See the git log for details at http://github.com/libffi/libffi. Fix the install dir location for some platforms when building with GCC (OS X, Solaris). Fix Cygwin regression. - + 3.0.12 Feb-11-13 Add Moxie support. Add AArch64 support. @@ -262,7 +265,7 @@ See the git log for details at http://github.com/libffi/libffi. Add support for native vendor compilers on Solaris and AIX. Work around LLVM/GCC interoperability issue on x86_64. - + 3.0.11 Apr-11-12 Lots of build fixes. Add support for variadic functions (ffi_prep_cif_var). @@ -273,7 +276,7 @@ See the git log for details at http://github.com/libffi/libffi. Integration with iOS' xcode build tools. Fix Octeon and MC68881 support. Fix code pessimizations. - + 3.0.10 Aug-23-11 Add support for Apple's iOS. Add support for ARM VFP ABI. @@ -287,128 +290,128 @@ See the git log for details at http://github.com/libffi/libffi. Solaris compiler. Testsuite fixes for Tru64 Unix. Additional platform support. - + 3.0.9 Dec-31-09 Add AVR32 and win64 ports. Add ARM softfp support. Many fixes for AIX, Solaris, HP-UX, *BSD. Several PowerPC and x86-64 bug fixes. Build DLL for windows. - + 3.0.8 Dec-19-08 Add *BSD, BeOS, and PA-Linux support. - + 3.0.7 Nov-11-08 Fix for ppc FreeBSD. (thanks to Andreas Tobler) - + 3.0.6 Jul-17-08 Fix for closures on sh. Mark the sh/sh64 stack as non-executable. (both thanks to Kaz Kojima) - + 3.0.5 Apr-3-08 Fix libffi.pc file. Fix #define ARM for IcedTea users. Fix x86 closure bug. - + 3.0.4 Feb-24-08 Fix x86 OpenBSD configury. - + 3.0.3 Feb-22-08 Enable x86 OpenBSD thanks to Thomas Heller, and x86-64 FreeBSD thanks to Björn König and Andreas Tobler. Clean up test instruction in README. - + 3.0.2 Feb-21-08 Improved x86 FreeBSD support. Thanks to Björn König. - + 3.0.1 Feb-15-08 Fix instruction cache flushing bug on MIPS. Thanks to David Daney. - + 3.0.0 Feb-15-08 Many changes, mostly thanks to the GCC project. Cygnus Solutions is now Red Hat. - + [10 years go by...] - + 1.20 Oct-5-98 Raffaele Sena produces ARM port. - + 1.19 Oct-5-98 Fixed x86 long double and long long return support. m68k bug fixes from Andreas Schwab. Patch for DU assembler compatibility for the Alpha from Richard Henderson. - + 1.18 Apr-17-98 Bug fixes and MIPS configuration changes. - + 1.17 Feb-24-98 Bug fixes and m68k port from Andreas Schwab. PowerPC port from Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes. - + 1.16 Feb-11-98 Richard Henderson produces Alpha port. - + 1.15 Dec-4-97 Fixed an n32 ABI bug. New libtool, auto* support. - + 1.14 May-13-97 libtool is now used to generate shared and static libraries. Fixed a minor portability problem reported by Russ McManus . - + 1.13 Dec-2-96 Added --enable-purify-safety to keep Purify from complaining about certain low level code. Sparc fix for calling functions with < 6 args. Linux x86 a.out fix. - + 1.12 Nov-22-96 - Added missing ffi_type_void, needed for supporting void return - types. Fixed test case for non MIPS machines. Cygnus Support - is now Cygnus Solutions. - + Added missing ffi_type_void, needed for supporting void return + types. Fixed test case for non MIPS machines. Cygnus Support + is now Cygnus Solutions. + 1.11 Oct-30-96 Added notes about GNU make. - + 1.10 Oct-29-96 Added configuration fix for non GNU compilers. - + 1.09 Oct-29-96 - Added --enable-debug configure switch. Clean-ups based on LCLint - feedback. ffi_mips.h is always installed. Many configuration + Added --enable-debug configure switch. Clean-ups based on LCLint + feedback. ffi_mips.h is always installed. Many configuration fixes. Fixed ffitest.c for sparc builds. - + 1.08 Oct-15-96 Fixed n32 problem. Many clean-ups. - + 1.07 Oct-14-96 Gordon Irlam rewrites v8.S again. Bug fixes. - + 1.06 Oct-14-96 - Gordon Irlam improved the sparc port. - + Gordon Irlam improved the sparc port. + 1.05 Oct-14-96 Interface changes based on feedback. - + 1.04 Oct-11-96 Sparc port complete (modulo struct passing bug). - + 1.03 Oct-10-96 Passing struct args, and returning struct values works for all architectures/calling conventions. Expanded tests. - + 1.02 Oct-9-96 Added SGI n32 support. Fixed bugs in both o32 and Linux support. Added "make test". - + 1.01 Oct-8-96 Fixed float passing bug in mips version. Restructured some of the code. Builds cleanly with SGI tools. - + 1.00 Oct-7-96 First release. No public announcement. diff --git a/doc/libffi.texi b/doc/libffi.texi index bd305936c..79f937733 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -18,7 +18,7 @@ This manual is for libffi, a portable foreign function interface library. -Copyright @copyright{} 2008--2019 Anthony Green and Red Hat, Inc. +Copyright @copyright{} 2008--2019, 2021 Anthony Green and Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -176,6 +176,11 @@ variadic arguments. It must be greater than zero. @var{ntotalargs} the total number of arguments, including variadic and fixed arguments. @var{argtypes} must have this many elements. +@code{ffi_prep_cif_var} will return @code{FFI_BAD_ARGTYPE} if any of +the variable argument types are @code{ffi_type_float} (promote to +@code{ffi_type_double} first), or any integer type small than an int +(promote to an int-sized type first). + Note that, different cif's must be prepped for calls to the same function when different numbers of arguments are passed. @@ -249,26 +254,26 @@ int main() void *values[1]; char *s; ffi_arg rc; - - /* Initialize the argument info vectors */ + + /* Initialize the argument info vectors */ args[0] = &ffi_type_pointer; values[0] = &s; - + /* Initialize the cif */ - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_sint, args) == FFI_OK) @{ s = "Hello World!"; ffi_call(&cif, puts, &rc, values); /* rc now holds the result of the call to puts */ - - /* values holds a pointer to the function's arg, so to - call puts() again all we need to do is change the + + /* values holds a pointer to the function's arg, so to + call puts() again all we need to do is change the value of s */ s = "This is cool!"; ffi_call(&cif, puts, &rc, values); @} - + return 0; @} @end example @@ -624,7 +629,7 @@ Here is the corresponding code to describe this struct to tm_type.size = tm_type.alignment = 0; tm_type.type = FFI_TYPE_STRUCT; tm_type.elements = &tm_type_elements; - + for (i = 0; i < 9; i++) tm_type_elements[i] = &ffi_type_sint; @@ -887,7 +892,7 @@ writable and executable addresses. @node Closure Example @section Closure Example -A trivial example that creates a new @code{puts} by binding +A trivial example that creates a new @code{puts} by binding @code{fputs} with @code{stdout}. @example diff --git a/include/ffi.h.in b/include/ffi.h.in index 14ec807d9..d16f307e6 100644 --- a/include/ffi.h.in +++ b/include/ffi.h.in @@ -1,6 +1,7 @@ /* -----------------------------------------------------------------*-C-*- - libffi @VERSION@ - Copyright (c) 2011, 2014, 2019 Anthony Green - - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. + libffi @VERSION@ + - Copyright (c) 2011, 2014, 2019, 2021 Anthony Green + - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -217,7 +218,8 @@ FFI_EXTERN ffi_type ffi_type_complex_longdouble; typedef enum { FFI_OK = 0, FFI_BAD_TYPEDEF, - FFI_BAD_ABI + FFI_BAD_ABI, + FFI_BAD_ARGTYPE } ffi_status; typedef struct { @@ -269,7 +271,7 @@ typedef ffi_raw ffi_java_raw; #endif -FFI_API +FFI_API void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, @@ -374,8 +376,8 @@ typedef struct { #if !FFI_NATIVE_RAW_API - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate + /* If this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate handler to do the transaltion, void** -> ffi_raw*. */ void (*translate_args)(ffi_cif*,void*,void**,void*); @@ -400,8 +402,8 @@ typedef struct { #if !FFI_NATIVE_RAW_API - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate + /* If this is enabled, then a raw closure has the same layout + as a regular closure. We use this to install an intermediate handler to do the translation, void** -> ffi_raw*. */ void (*translate_args)(ffi_cif*,void*,void**,void*); @@ -462,7 +464,7 @@ FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, /* ---- Public interface definition -------------------------------------- */ -FFI_API +FFI_API ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, @@ -495,18 +497,18 @@ ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, #endif /* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 +#define FFI_TYPE_VOID 0 #define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 +#define FFI_TYPE_FLOAT 2 #define FFI_TYPE_DOUBLE 3 #if @HAVE_LONG_DOUBLE@ #define FFI_TYPE_LONGDOUBLE 4 #else #define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE #endif -#define FFI_TYPE_UINT8 5 +#define FFI_TYPE_UINT8 5 #define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 +#define FFI_TYPE_UINT16 7 #define FFI_TYPE_SINT16 8 #define FFI_TYPE_UINT32 9 #define FFI_TYPE_SINT32 10 diff --git a/src/prep_cif.c b/src/prep_cif.c index 1db3804b2..c1832b103 100644 --- a/src/prep_cif.c +++ b/src/prep_cif.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- - prep_cif.c - Copyright (c) 2011, 2012 Anthony Green + prep_cif.c - Copyright (c) 2011, 2012, 2021 Anthony Green Copyright (c) 1996, 1998, 2007 Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining @@ -231,7 +231,26 @@ ffi_status ffi_prep_cif_var(ffi_cif *cif, ffi_type *rtype, ffi_type **atypes) { - return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes); + ffi_status rc; + size_t int_size = ffi_type_sint.size; + int i; + + rc = ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes); + + if (rc != FFI_OK) + return rc; + + for (i = 1; i < ntotalargs; i++) + { + ffi_type *arg_type = atypes[i]; + if (arg_type == &ffi_type_float + || ((arg_type->type != FFI_TYPE_STRUCT + && arg_type->type != FFI_TYPE_COMPLEX) + && arg_type->size < int_size)) + return FFI_BAD_ARGTYPE; + } + + return FFI_OK; } #if FFI_CLOSURES diff --git a/testsuite/libffi.call/va_1.c b/testsuite/libffi.call/va_1.c index 59d085c83..ccc6faf5c 100644 --- a/testsuite/libffi.call/va_1.c +++ b/testsuite/libffi.call/va_1.c @@ -5,7 +5,6 @@ Originator: ARM Ltd. */ /* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* m68k-*-* alpha-*-* } } */ #include "ffitest.h" #include @@ -25,62 +24,10 @@ struct large_tag 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; @@ -89,24 +36,6 @@ main (void) ffi_type l_type; ffi_type *l_type_elements[6]; - struct small_tag s1; - struct small_tag s2; - struct large_tag l1; - - int n; - ffi_arg 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; @@ -144,53 +73,6 @@ main (void) 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" } */ - + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_BAD_ARGTYPE); return 0; } diff --git a/testsuite/libffi.call/va_2.c b/testsuite/libffi.call/va_2.c new file mode 100644 index 000000000..0589d0848 --- /dev/null +++ b/testsuite/libffi.call/va_2.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*-*-* m68k-*-* alpha-*-* } } */ + +#include "ffitest.h" +#include + +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; + ffi_arg res; + + unsigned int uc; + signed int sc; + unsigned int us; + signed int 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/testsuite/libffi.closures/cls_uchar_va.c b/testsuite/libffi.closures/cls_uchar_va.c deleted file mode 100644 index 6491c5b3d..000000000 --- a/testsuite/libffi.closures/cls_uchar_va.c +++ /dev/null @@ -1,44 +0,0 @@ -/* 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__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)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/testsuite/libffi.closures/cls_ushort_va.c b/testsuite/libffi.closures/cls_ushort_va.c deleted file mode 100644 index 37aa1064e..000000000 --- a/testsuite/libffi.closures/cls_ushort_va.c +++ /dev/null @@ -1,44 +0,0 @@ -/* 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__) - { - *(ffi_arg *)resp = *(T *)args[0]; - - printf("%d: %d %d\n", (int)(*(ffi_arg *)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); -} From 9d491b5e21ffd7fcf2370d998a4832b755d1c9e9 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 23 Mar 2021 12:26:37 -0400 Subject: [PATCH 165/231] Mention KVX --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 23b10ce5c..8cd49b10c 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ See the git log for details at http://github.com/libffi/libffi. 3.4 TBD Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. + Add support for Kalray's KVX architecture. Add support for Intel Control-flow Enforcement Technology (CET). Add support for ARM Pointer Authentication (PA). Fix 32-bit PPC regression. From 8f44384df17b536615caef951a615655a967103f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 23 Mar 2021 14:24:54 -0400 Subject: [PATCH 166/231] Fix formatting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8cd49b10c..28cc8c667 100644 --- a/README.md +++ b/README.md @@ -200,8 +200,8 @@ See the git log for details at http://github.com/libffi/libffi. 3.4 TBD Add static trampoline support for Linux on x86_64 and ARM64. - Add support for Alibaba's CSKY architecture. - Add support for Kalray's KVX architecture. + Add support for Alibaba's CSKY architecture. + Add support for Kalray's KVX architecture. Add support for Intel Control-flow Enforcement Technology (CET). Add support for ARM Pointer Authentication (PA). Fix 32-bit PPC regression. From 5865450decd13275b2bde064bd4a0f79bca6dba2 Mon Sep 17 00:00:00 2001 From: Francisco Boni Date: Tue, 23 Mar 2021 19:50:09 -0300 Subject: [PATCH 167/231] Update ax_cc_maxopt m4 macro (#617) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keeps libffi's specific changes (https://github.com/libffi/libffi/commit/cec3a3a201f17a7f018f25e1a0917bd5206e5a5a#diff-2396a1256ac4b1c6849c931ddb8018bdd984bb2383be21bb819a33b95d8d603f) and updates to the latest ax_cc_maxopt.m4 (http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=commit;h=73ee1b396c21062ee8eeb8721ba5323322110fb5): ax_cc_maxopt.m4: retain setting of CFLAGS by configure AX_CC_MAXOPT checks whether CFLAGS was set by the user; if so, the user’s setting is respected. This behavior is retained, of course. However, AX_CC_MAXOPT was then setting CFLAGS="". This overrode the default setting by configure, which usually includes -g. Hence, if CFLAGS was not set by the user, retain the default setting, to preserve the ability to debug. A typical default setting from configure is "-g -O2". This means that AX_CC_MAXOPT might typically set CFLAGS to "-g -O2 -O3". This is fine, because the later -O3 will override the earlier -O2. (The only assumption is that all compilers that AX_CC_MAXOPT knows behave in this sane way.) --- m4/ax_cc_maxopt.m4 | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/m4/ax_cc_maxopt.m4 b/m4/ax_cc_maxopt.m4 index 9e7f1ee4a..027b6d827 100644 --- a/m4/ax_cc_maxopt.m4 +++ b/m4/ax_cc_maxopt.m4 @@ -55,7 +55,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 17 +#serial 18 AC_DEFUN([AX_CC_MAXOPT], [ @@ -68,19 +68,18 @@ AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disa # Try to determine "good" native compiler flags if none specified via CFLAGS if test "$ac_test_CFLAGS" != "set"; then - CFLAGS="" case $ax_cv_c_compiler_vendor in - dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" + dec) CFLAGS="$CFLAGS -newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host" if test "x$acx_maxopt_portable" = xno; then CFLAGS="$CFLAGS -arch host" fi;; - sun) CFLAGS="-native -fast -xO5 -dalign" + sun) CFLAGS="$CFLAGS -native -fast -xO5 -dalign" if test "x$acx_maxopt_portable" = xyes; then CFLAGS="$CFLAGS -xarch=generic" fi;; - hp) CFLAGS="+Oall +Optrs_ansi +DSnative" + hp) CFLAGS="$CFLAGS +Oall +Optrs_ansi +DSnative" if test "x$acx_maxopt_portable" = xyes; then CFLAGS="$CFLAGS +DAportable" fi;; @@ -91,8 +90,8 @@ if test "$ac_test_CFLAGS" != "set"; then xlc_opt="-qtune=auto" fi AX_CHECK_COMPILE_FLAG($xlc_opt, - CFLAGS="-O3 -qansialias -w $xlc_opt", - [CFLAGS="-O3 -qansialias -w" + CFLAGS="$CFLAGS -O3 -qansialias -w $xlc_opt", + [CFLAGS="$CFLAGS -O3 -qansialias -w" echo "******************************************************" echo "* You seem to have the IBM C compiler. It is *" echo "* recommended for best performance that you use: *" @@ -105,7 +104,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "******************************************************"]) ;; - intel) CFLAGS="-O3 -ansi_alias" + intel) CFLAGS="$CFLAGS -O3 -ansi_alias" if test "x$acx_maxopt_portable" = xno; then icc_archflag=unknown icc_flags="" @@ -146,7 +145,7 @@ if test "$ac_test_CFLAGS" != "set"; then gnu) # default optimization flags for gcc on all systems - CFLAGS="-O3 -fomit-frame-pointer" + CFLAGS="$CFLAGS -O3 -fomit-frame-pointer" # -malign-double for x86 systems # libffi local change -- don't align double, as it changes the ABI @@ -164,7 +163,7 @@ if test "$ac_test_CFLAGS" != "set"; then microsoft) # default optimization flags for MSVC opt builds - CFLAGS="-O2" + CFLAGS="$CFLAGS -O2" ;; esac @@ -176,7 +175,7 @@ if test "$ac_test_CFLAGS" != "set"; then echo "* (otherwise, a default of CFLAGS=-O3 will be used) *" echo "********************************************************" echo "" - CFLAGS="-O3" + CFLAGS="$CFLAGS -O3" fi AX_CHECK_COMPILE_FLAG($CFLAGS, [], [ @@ -187,7 +186,6 @@ if test "$ac_test_CFLAGS" != "set"; then echo "* Use ./configure CFLAGS=... to specify your own flags *" echo "********************************************************" echo "" - CFLAGS="" ]) fi From f58e5ee63263657a7e8f2892d27c012a16facc1a Mon Sep 17 00:00:00 2001 From: AndreRH Date: Tue, 23 Mar 2021 23:54:00 +0100 Subject: [PATCH 168/231] aarch64: Fix closures for win64 (#606) --- src/aarch64/ffi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index fccc7f262..fd7f9d1d5 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -797,7 +797,7 @@ ffi_prep_closure_loc (ffi_closure *closure, void *user_data, void *codeloc) { - if (cif->abi != FFI_SYSV) + if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64) return FFI_BAD_ABI; void (*start)(void); @@ -873,7 +873,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif, { void (*start)(void); - if (cif->abi != FFI_SYSV) + if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64) return FFI_BAD_ABI; if (cif->flags & AARCH64_FLAG_ARG_V) @@ -913,11 +913,18 @@ ffi_closure_SYSV_inner (ffi_cif *cif, void *stack, void *rvalue, void *struct_rvalue) { void **avalue = (void**) alloca (cif->nargs * sizeof (void*)); - int i, h, nargs, flags; + int i, h, nargs, flags, isvariadic = 0; struct arg_state state; arg_init (&state); + flags = cif->flags; + if (flags & AARCH64_FLAG_VARARG) + { + isvariadic = 1; + flags &= ~AARCH64_FLAG_VARARG; + } + for (i = 0, nargs = cif->nargs; i < nargs; i++) { ffi_type *ty = cif->arg_types[i]; @@ -952,8 +959,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, if (h) { n = 4 - (h & 3); -#ifdef _WIN32 /* for handling armasm calling convention */ - if (cif->is_variadic) + if (cif->abi == FFI_WIN64 && isvariadic) { if (state.ngrn + n <= N_X_ARG_REG) { @@ -979,7 +985,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif, } else { -#endif /* for handling armasm calling convention */ if (state.nsrn + n <= N_V_ARG_REG) { void *reg = &context->v[state.nsrn]; @@ -992,9 +997,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif, avalue[i] = allocate_to_stack(&state, stack, ty->alignment, s); } -#ifdef _WIN32 /* for handling armasm calling convention */ } -#endif /* for handling armasm calling convention */ } else if (s > 16) { @@ -1035,7 +1038,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif, #endif } - flags = cif->flags; if (flags & AARCH64_RET_IN_MEM) rvalue = struct_rvalue; From 70ea259c603e0f84eda766be29d4259f1e8fe5b7 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 23 Mar 2021 19:03:45 -0400 Subject: [PATCH 169/231] Search $LIBFFI_TMPDIR also (#605) Most temp file directories need to be hardened against execution, but libffi needs execute privileges. Add a libffi-specific temp directory that can be set up by sysadmins as needed with suitable permissions. This both ensures that libffi will have a valid temp directory to use as well as preventing attempts to access other directories. --- doc/libffi.texi | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ src/closures.c | 1 + 2 files changed, 51 insertions(+) diff --git a/doc/libffi.texi b/doc/libffi.texi index 79f937733..28f0e6adb 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -65,6 +65,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @menu * Introduction:: What is libffi? * Using libffi:: How to use libffi. +* Memory Usage:: Where memory for closures comes from. * Missing Features:: Things libffi can't do. * Index:: Index. @end menu @@ -970,6 +971,55 @@ Currently the only affected platform is PowerPC and the only affected type is @code{long double}. @end itemize +@node Memory Usage +@chapter Memory Usage + +Note that memory allocated by @code{ffi_closure_alloc} and freed by +@code{ffi_closure_free} does not come from the same general pool of +memory that @code{malloc} and @code{free} use. To accomodate security +settings, @samp{libffi} may aquire memory, for example, by mapping +temporary files into multiple places in the address space (once to +write out the closure, a second to execute it). The search follows +this list, using the first that works: + +@itemize @bullet + +@item +A anonymous mapping (i.e. not file-backed) + +@item +@code{memfd_create()}, if the kernel supports it. + +@item +A file created in the directory referenced by the environment variable +@code{LIBFFI_TMPDIR}. + +@item +Likewise for the environment variable @code{TMPDIR}. + +@item +A file created in @code{/tmp}. + +@item +A file created in @code{/var/tmp}. + +@item +A file created in @code{/dev/shm}. + +@item +A file created in the user's home directory (@code{$HOME}). + +@item +A file created in any directory listed in @code{/etc/mtab}. + +@item +A file created in any directory listed in @code{/proc/mounts}. + +@end itemize + +If security settings prohibit using any of these for closures, +@code{ffi_closure_alloc} will fail. + @node Missing Features @chapter Missing Features diff --git a/src/closures.c b/src/closures.c index 3a63c32da..3558d7855 100644 --- a/src/closures.c +++ b/src/closures.c @@ -695,6 +695,7 @@ static struct #ifdef HAVE_MEMFD_CREATE { open_temp_exec_file_memfd, "libffi", 0 }, #endif + { open_temp_exec_file_env, "LIBFFI_TMPDIR", 0 }, { open_temp_exec_file_env, "TMPDIR", 0 }, { open_temp_exec_file_dir, "/tmp", 0 }, { open_temp_exec_file_dir, "/var/tmp", 0 }, From aa4dafb159a2e0f74aa39353a1bf23a943f36656 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 23 Mar 2021 19:06:08 -0400 Subject: [PATCH 170/231] Mention LIBFFI_TMPDIR --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 28cc8c667..6a79c5890 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ See the git log for details at http://github.com/libffi/libffi. Add support for ARM Pointer Authentication (PA). Fix 32-bit PPC regression. Fix MIPS soft-float problem. + Enable tmpdir override with the $LIBFFI_TMPDIR environment variable. Reject float and small integer argument in ffi_prep_cif_var(). Callers must promote these types themselves. From f88add14e40de398706c732e578620e8106062c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 24 Mar 2021 12:04:51 +0100 Subject: [PATCH 171/231] x86: Fix MSVC runtime checks interop (#612) MSVC can add runtime code that checks if a stack frame is mismanaged, however our custom assembly deliberately accesses and modifies the parent stack frame. Fortunately we can disable that specific check for the function call so do that. Co-authored-by: Matthew Waters --- src/x86/ffi.c | 10 ++++++++++ src/x86/ffiw64.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index b4d0d3908..26dbc0591 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -256,6 +256,13 @@ static const struct abi_params abi_params[FFI_LAST_ABI] = { extern void FFI_DECLARE_FASTCALL ffi_call_i386(struct call_frame *, char *) FFI_HIDDEN; +/* We perform some black magic here to use some of the parent's stack frame in + * ffi_call_i386() that breaks with the MSVC compiler with the /RTCs or /GZ + * flags. Disable the 'Stack frame run time error checking' for this function + * so we don't hit weird exceptions in debug builds. */ +#if defined(_MSC_VER) +#pragma runtime_checks("s", off) +#endif static void ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, void *closure) @@ -391,6 +398,9 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_call_i386 (frame, stack); } +#if defined(_MSC_VER) +#pragma runtime_checks("s", restore) +#endif void ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index 6c28d59b1..6870d07c9 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -108,6 +108,13 @@ EFI64(ffi_prep_cif_machdep)(ffi_cif *cif) return FFI_OK; } +/* We perform some black magic here to use some of the parent's stack frame in + * ffi_call_win64() that breaks with the MSVC compiler with the /RTCs or /GZ + * flags. Disable the 'Stack frame run time error checking' for this function + * so we don't hit weird exceptions in debug builds. */ +#if defined(_MSC_VER) +#pragma runtime_checks("s", off) +#endif static void ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, void *closure) @@ -172,6 +179,9 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_call_win64 (stack, frame, closure); } +#if defined(_MSC_VER) +#pragma runtime_checks("s", restore) +#endif void EFI64(ffi_call)(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) From e92c81a549924c80d70666ecbe5ed0c2fcd7963a Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 24 Mar 2021 07:07:53 -0400 Subject: [PATCH 172/231] Mention MSVC runtime stack checking improvement --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a79c5890..a412191a6 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ See the git log for details at http://github.com/libffi/libffi. Fix 32-bit PPC regression. Fix MIPS soft-float problem. Enable tmpdir override with the $LIBFFI_TMPDIR environment variable. + Enable compatibility with MSVC runtime stack checking. Reject float and small integer argument in ffi_prep_cif_var(). Callers must promote these types themselves. From 1aeb26714ec30649f5d9de5b4884a4ac46f5f474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 24 Mar 2021 12:16:12 +0100 Subject: [PATCH 173/231] x86: Fix thiscall and fastcall stack cleanup behavior (#611) These are meant to use callee clean-up. --- src/x86/ffi.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 26dbc0591..24431c170 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -538,10 +538,17 @@ ffi_closure_inner (struct closure_frame *frame, char *stack) frame->fun (cif, rvalue, avalue, frame->user_data); - if (cabi == FFI_STDCALL) - return flags + (cif->bytes << X86_RET_POP_SHIFT); - else - return flags; + switch (cabi) + { + case FFI_STDCALL: + return flags | (cif->bytes << X86_RET_POP_SHIFT); + case FFI_THISCALL: + case FFI_FASTCALL: + return flags | ((cif->bytes - (narg_reg * FFI_SIZEOF_ARG)) + << X86_RET_POP_SHIFT); + default: + return flags; + } } ffi_status @@ -558,12 +565,12 @@ ffi_prep_closure_loc (ffi_closure* closure, switch (cif->abi) { case FFI_SYSV: - case FFI_THISCALL: - case FFI_FASTCALL: case FFI_MS_CDECL: dest = ffi_closure_i386; break; case FFI_STDCALL: + case FFI_THISCALL: + case FFI_FASTCALL: case FFI_PASCAL: dest = ffi_closure_STDCALL; break; From 01b56f4b3e89a349228c4ccf55061d847153c8d6 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Wed, 24 Mar 2021 12:20:27 +0100 Subject: [PATCH 174/231] fix windows tests (#595) * Update .appveyor.yml * add (debug+release)*(shared+static) CI * fix libversion --- .appveyor.yml | 27 ++++++++++++++++++++++----- msvcc.sh | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ece8a948c..e1fb63491 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -15,13 +15,19 @@ platform: - arm - arm64 +configuration: + - Debug + - Release + environment: global: CYG_ROOT: C:/cygwin CYG_CACHE: C:/cygwin/var/cache/setup CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/ + VSVER: 15 matrix: - - VSVER: 15 + - SHARED_ARG: "--enable-shared --disable-static" + - SHARED_ARG: "--enable-static --disable-shared" install: - ps: >- @@ -50,6 +56,11 @@ install: $env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh -m64" $env:SRC_ARCHITECTURE="x86" } + If ($env:Configuration -Match "Debug") { + $env:DEBUG_ARG="--enable-debug" + } Else { + $env:DEBUG_ARG="--disable-debug" + } - 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe' - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu >NUL' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' @@ -60,7 +71,13 @@ install: - call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM% build_script: - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh;)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST;)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include; make; find .;)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/; make check; cat `find ./ -name libffi.log`)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST $DEBUG_ARG $SHARED_ARG)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/)" + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make check RUNTESTFLAGS='-v -v -v -v')" + + +on_finish: + - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)" diff --git a/msvcc.sh b/msvcc.sh index 7cfc5097f..301e2fbd6 100755 --- a/msvcc.sh +++ b/msvcc.sh @@ -52,7 +52,7 @@ ml="ml" safeseh="-safeseh" output= libpaths= -libversion=7 +libversion=8 verbose= while [ $# -gt 0 ] From eafab2356e8dcf5f01d2bcfa311cafba3b395a7e Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Wed, 24 Mar 2021 11:38:36 -0700 Subject: [PATCH 175/231] arm64e: Pull in pointer authentication code from Apple's arm64e libffi port (#565) NOTES: This changes the ptrauth support from #548 to match what Apple is shipping in its libffi-27 tag. Signed-off-by: Jeremy Huddleston Sequoia --- src/aarch64/ffi.c | 9 +++-- src/aarch64/internal.h | 22 ++++++++++ src/aarch64/sysv.S | 91 +++++++++++++++++++++++------------------- src/closures.c | 18 +++++---- 4 files changed, 89 insertions(+), 51 deletions(-) diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index fd7f9d1d5..5c85fcd0e 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -617,11 +617,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue, else if (flags & AARCH64_RET_NEED_COPY) rsize = 16; - /* Allocate consectutive stack for everything we'll need. */ - context = alloca (sizeof(struct call_context) + stack_bytes + 32 + rsize); + /* Allocate consectutive stack for everything we'll need. + The frame uses 40 bytes for: lr, fp, rvalue, flags, sp */ + context = alloca (sizeof(struct call_context) + stack_bytes + 40 + rsize); stack = context + 1; frame = (void*)((uintptr_t)stack + (uintptr_t)stack_bytes); - rvalue = (rsize ? (void*)((uintptr_t)frame + 32) : orig_rvalue); + rvalue = (rsize ? (void*)((uintptr_t)frame + 40) : orig_rvalue); arg_init (&state); for (i = 0, nargs = cif->nargs; i < nargs; i++) @@ -810,7 +811,7 @@ ffi_prep_closure_loc (ffi_closure *closure, #if FFI_EXEC_TRAMPOLINE_TABLE #ifdef __MACH__ #ifdef HAVE_PTRAUTH - codeloc = ptrauth_strip (codeloc, ptrauth_key_asia); + codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0); #endif void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE); config[0] = closure; diff --git a/src/aarch64/internal.h b/src/aarch64/internal.h index de55755f9..b5d102b4a 100644 --- a/src/aarch64/internal.h +++ b/src/aarch64/internal.h @@ -75,4 +75,26 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define AARCH64_TRAMP_MAP_SHIFT 14 #define AARCH64_TRAMP_MAP_SIZE (1 << AARCH64_TRAMP_MAP_SHIFT) #define AARCH64_TRAMP_SIZE 32 + +#endif + +/* Helpers for writing assembly compatible with arm ptr auth */ +#ifdef LIBFFI_ASM + +#ifdef HAVE_PTRAUTH +#define SIGN_LR pacibsp +#define SIGN_LR_WITH_REG(x) pacib lr, x +#define AUTH_LR_AND_RET retab +#define AUTH_LR_WITH_REG(x) autib lr, x +#define BRANCH_AND_LINK_TO_REG blraaz +#define BRANCH_TO_REG braaz +#else +#define SIGN_LR +#define SIGN_LR_WITH_REG(x) +#define AUTH_LR_AND_RET ret +#define AUTH_LR_WITH_REG(x) +#define BRANCH_AND_LINK_TO_REG blr +#define BRANCH_TO_REG br +#endif + #endif diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S index bc10da840..eeaf3f851 100644 --- a/src/aarch64/sysv.S +++ b/src/aarch64/sysv.S @@ -56,14 +56,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define PTR_SIZE 4 #else #define PTR_SIZE 8 -#endif - -#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH) -# define BR(r) braaz r -# define BLR(r) blraaz r -#else -# define BR(r) br r -# define BLR(r) blr r #endif .text @@ -86,9 +78,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ cfi_startproc CNAME(ffi_call_SYSV): + /* Sign the lr with x1 since that is where it will be stored */ + SIGN_LR_WITH_REG(x1) + /* Use a stack frame allocated by our caller. */ - cfi_def_cfa(x1, 32); +#if defined(HAVE_PTRAUTH) && defined(__APPLE__) + /* darwin's libunwind assumes that the cfa is the sp and that's the data + * used to sign the lr. In order to allow unwinding through this + * function it is necessary to point the cfa at the signing register. + */ + cfi_def_cfa(x1, 0); +#else + cfi_def_cfa(x1, 40); +#endif stp x29, x30, [x1] + mov x9, sp + str x9, [x1, #32] mov x29, x1 mov sp, x0 cfi_def_cfa_register(x29) @@ -119,13 +124,15 @@ CNAME(ffi_call_SYSV): /* Deallocate the context, leaving the stacked arguments. */ add sp, sp, #CALL_CONTEXT_SIZE - BLR(x9) /* call fn */ + BRANCH_AND_LINK_TO_REG x9 /* call fn */ ldp x3, x4, [x29, #16] /* reload rvalue and flags */ /* Partially deconstruct the stack frame. */ - mov sp, x29 + ldr x9, [x29, #32] + mov sp, x9 cfi_def_cfa_register (sp) + mov x2, x29 /* Preserve for auth */ ldp x29, x30, [x29] /* Save the return value as directed. */ @@ -139,71 +146,76 @@ CNAME(ffi_call_SYSV): and therefore we want to extend to 64 bits; these types have two consecutive entries allocated for them. */ .align 4 -0: ret /* VOID */ +0: b 99f /* VOID */ nop 1: str x0, [x3] /* INT64 */ - ret + b 99f 2: stp x0, x1, [x3] /* INT128 */ - ret + b 99f 3: brk #1000 /* UNUSED */ - ret + b 99f 4: brk #1000 /* UNUSED */ - ret + b 99f 5: brk #1000 /* UNUSED */ - ret + b 99f 6: brk #1000 /* UNUSED */ - ret + b 99f 7: brk #1000 /* UNUSED */ - ret + b 99f 8: st4 { v0.s, v1.s, v2.s, v3.s }[0], [x3] /* S4 */ - ret + b 99f 9: st3 { v0.s, v1.s, v2.s }[0], [x3] /* S3 */ - ret + b 99f 10: stp s0, s1, [x3] /* S2 */ - ret + b 99f 11: str s0, [x3] /* S1 */ - ret + b 99f 12: st4 { v0.d, v1.d, v2.d, v3.d }[0], [x3] /* D4 */ - ret + b 99f 13: st3 { v0.d, v1.d, v2.d }[0], [x3] /* D3 */ - ret + b 99f 14: stp d0, d1, [x3] /* D2 */ - ret + b 99f 15: str d0, [x3] /* D1 */ - ret + b 99f 16: str q3, [x3, #48] /* Q4 */ nop 17: str q2, [x3, #32] /* Q3 */ nop 18: stp q0, q1, [x3] /* Q2 */ - ret + b 99f 19: str q0, [x3] /* Q1 */ - ret + b 99f 20: uxtb w0, w0 /* UINT8 */ str x0, [x3] -21: ret /* reserved */ +21: b 99f /* reserved */ nop 22: uxth w0, w0 /* UINT16 */ str x0, [x3] -23: ret /* reserved */ +23: b 99f /* reserved */ nop 24: mov w0, w0 /* UINT32 */ str x0, [x3] -25: ret /* reserved */ +25: b 99f /* reserved */ nop 26: sxtb x0, w0 /* SINT8 */ str x0, [x3] -27: ret /* reserved */ +27: b 99f /* reserved */ nop 28: sxth x0, w0 /* SINT16 */ str x0, [x3] -29: ret /* reserved */ +29: b 99f /* reserved */ nop 30: sxtw x0, w0 /* SINT32 */ str x0, [x3] -31: ret /* reserved */ +31: b 99f /* reserved */ nop + /* Return now that result has been populated. */ +99: + AUTH_LR_WITH_REG(x2) + ret + cfi_endproc .globl CNAME(ffi_call_SYSV) @@ -234,6 +246,7 @@ CNAME(ffi_call_SYSV): .align 4 CNAME(ffi_closure_SYSV_V): cfi_startproc + SIGN_LR stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) cfi_rel_offset (x29, 0) @@ -257,6 +270,7 @@ CNAME(ffi_closure_SYSV_V): .align 4 cfi_startproc CNAME(ffi_closure_SYSV): + SIGN_LR stp x29, x30, [sp, #-ffi_closure_SYSV_FS]! cfi_adjust_cfa_offset (ffi_closure_SYSV_FS) cfi_rel_offset (x29, 0) @@ -283,9 +297,6 @@ CNAME(ffi_closure_SYSV): bl CNAME(ffi_closure_SYSV_inner) /* Load the return value as directed. */ -#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH) - autiza x1 -#endif adr x1, 0f and w0, w0, #AARCH64_RET_MASK add x1, x1, x0, lsl #3 @@ -361,7 +372,7 @@ CNAME(ffi_closure_SYSV): cfi_adjust_cfa_offset (-ffi_closure_SYSV_FS) cfi_restore (x29) cfi_restore (x30) - ret + AUTH_LR_AND_RET cfi_endproc .globl CNAME(ffi_closure_SYSV) @@ -450,7 +461,7 @@ CNAME(ffi_closure_trampoline_table_page): .rept PAGE_MAX_SIZE / FFI_TRAMPOLINE_SIZE adr x16, -PAGE_MAX_SIZE ldp x17, x16, [x16] - BR(x16) + br x16 nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller than 16 bytes */ .endr diff --git a/src/closures.c b/src/closures.c index 3558d7855..f7bead67b 100644 --- a/src/closures.c +++ b/src/closures.c @@ -173,7 +173,6 @@ struct ffi_trampoline_table { /* contiguous writable and executable pages */ vm_address_t config_page; - vm_address_t trampoline_page; /* free list tracking */ uint16_t free_count; @@ -217,7 +216,13 @@ ffi_trampoline_table_alloc (void) /* Remap the trampoline table on top of the placeholder page */ trampoline_page = config_page + PAGE_MAX_SIZE; + +#ifdef HAVE_PTRAUTH + trampoline_page_template = (vm_address_t)(uintptr_t)ptrauth_auth_data((void *)&ffi_closure_trampoline_table_page, ptrauth_key_function_pointer, 0); +#else trampoline_page_template = (vm_address_t)&ffi_closure_trampoline_table_page; +#endif + #ifdef __arm__ /* ffi_closure_trampoline_table_page can be thumb-biased on some ARM archs */ trampoline_page_template &= ~1UL; @@ -225,7 +230,7 @@ ffi_trampoline_table_alloc (void) kt = vm_remap (mach_task_self (), &trampoline_page, PAGE_MAX_SIZE, 0x0, VM_FLAGS_OVERWRITE, mach_task_self (), trampoline_page_template, FALSE, &cur_prot, &max_prot, VM_INHERIT_SHARE); - if (kt != KERN_SUCCESS) + if (kt != KERN_SUCCESS || !(cur_prot & VM_PROT_EXECUTE)) { vm_deallocate (mach_task_self (), config_page, PAGE_MAX_SIZE * 2); return NULL; @@ -235,7 +240,6 @@ ffi_trampoline_table_alloc (void) table = calloc (1, sizeof (ffi_trampoline_table)); table->free_count = FFI_TRAMPOLINE_COUNT; table->config_page = config_page; - table->trampoline_page = trampoline_page; /* Create and initialize the free list */ table->free_list_pool = @@ -245,7 +249,10 @@ ffi_trampoline_table_alloc (void) { ffi_trampoline_table_entry *entry = &table->free_list_pool[i]; entry->trampoline = - (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); + (void *) (trampoline_page + (i * FFI_TRAMPOLINE_SIZE)); +#ifdef HAVE_PTRAUTH + entry->trampoline = ptrauth_sign_unauthenticated(entry->trampoline, ptrauth_key_function_pointer, 0); +#endif if (i < table->free_count - 1) entry->next = &table->free_list_pool[i + 1]; @@ -314,9 +321,6 @@ ffi_closure_alloc (size_t size, void **code) /* Initialize the return values */ *code = entry->trampoline; -#ifdef HAVE_PTRAUTH - *code = ptrauth_sign_unauthenticated (*code, ptrauth_key_asia, 0); -#endif closure->trampoline_table = table; closure->trampoline_table_entry = entry; From 58dfdf6a84b98296ceb2b8b4237d37aa75bb2cd4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 24 Mar 2021 23:19:54 +0000 Subject: [PATCH 176/231] testsuite: fix compiler vendor detection on dash as /bin/sh (#594) In https://bugs.gentoo.org/753299 Paolo Pedroni reported a single test failure out of all libffi. Here is the minimal reproducer: ``` $ ./autogen $ CONFIG_SHELL=/bin/dash ./configure --host=x86_64-pc-linux-gnu $ make check RUNTESTFLAGS='complex.exp' ... FAIL: libffi.complex/cls_align_complex_float.c (test for excess errors) ``` This happens because under 'dash' shell autoconf generates slightly different style of string quotation in `config.log`: - on bash: `ax_cv_c_compiler_vendor=gnu` - on dash: `ax_cv_c_compiler_vendor='gnu'` To avoid shell quotation parsing the change just embeds `compiler_vendor` into `local.exp` at configure time. Reported-by: Paolo Pedroni Bug: https://bugs.gentoo.org/753299 Signed-off-by: Sergei Trofimovich --- configure.ac | 1 + testsuite/lib/libffi.exp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 0f141f48b..a9b7bf6a3 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,7 @@ fi cat > local.exp < Date: Thu, 25 Mar 2021 09:15:37 -0400 Subject: [PATCH 177/231] Move container images to quay.io. --- .travis/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 5f9a86e99..ebd063ddc 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -55,7 +55,7 @@ function build_foreign_linux() function build_cross_linux() { - ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) @@ -65,7 +65,7 @@ function build_cross_linux() function build_cross() { - ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} + ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} ${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl @@ -106,7 +106,7 @@ case "$HOST" in ;; arm32v7-linux-gnu) ./autogen.sh - build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest + build_foreign_linux arm quay.io/moxielogic/arm32v7-ci-build-container:latest ;; mips64el-linux-gnu | sparc64-linux-gnu) build_cfarm From 95ef857d5c6ed15c6c6ba5f8a5b26c0a38b417ab Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 25 Mar 2021 10:43:05 -0400 Subject: [PATCH 178/231] Verbose brew update. --- .travis/install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis/install.sh b/.travis/install.sh index 242024571..7e8723570 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -2,7 +2,8 @@ set -x if [[ $TRAVIS_OS_NAME != 'linux' ]]; then - brew update > brew-update.log 2>&1 + brew update --verbose + # brew update > brew-update.log 2>&1 # fix an issue with libtool on travis by reinstalling it brew uninstall libtool; brew install libtool dejagnu; @@ -26,7 +27,7 @@ else wget -qO - https://rl.gl/cli/rlgl-linux-s390x.tgz | \ tar --strip-components=2 -xvzf - ./rlgl/rlgl; ;; - *) + *) wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \ tar --strip-components=2 -xvzf - ./rlgl/rlgl; ;; @@ -36,7 +37,7 @@ else sudo apt-get update case $HOST in mips64el-linux-gnu | sparc64-linux-gnu) - ;; + ;; alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu) sudo apt-get install qemu-user-static ;; From dd5bd03075149d7cf8441875c1a344e8beb57dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 7 Apr 2021 05:42:10 +0300 Subject: [PATCH 179/231] Fix building for arm windows with mingw toolchains (#631) * arm: Check _WIN32 instead of _M_ARM or _MSC_VER for detecting windows This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Only use armasm source when building with MSVC When building for windows/arm with clang, the normal gas style .S source works fine (if fixed up to support thumb and other windows specifics). This matches what was done for ARM64 in c06468fa6674d3783a0edb1d0fae9afc8bc28513. * arm: Fix sysv.S to work in thumb mode Align cases in jump tables (adding nop padding to make sure each case starts where expected). Rewrite instructions that add directly to the pc register. For ffi_closure_ret, factor out a call_epilogue subroutine that restores both sp and pc from the stack; the thumb version of ldm can't load into the sp register. To avoid excessive ifdeffing, keep using call_epilogue in arm mode, but keep the shorter "ldm sp, {sp, pc}" epilogue in that case. * arm: Add win32 version of trampoline to sysv.S This matches the version of it in sysv_msvc_arm32.S. The calling C code expects a specific form of the trampoline on windows; make sure these work the same on windows regardless of the form of assembly used. * arm: Avoid optimizing out clearing the thumb bit of ffi_arm_trampoline We clear the thumb bit of ffi_arm_trampoline with a bitmask before memcpying its instructions into closure->tramp. If the bit isn't cleared, the memcpy of the trampoline function copies the wrong instructions. If the ffi_arm_trampoline symbol is declared as an array of int, the compiler can assume that it is aligned to a 4 byte boundary and the bitmask operation is a no-op, and optimize it out. See https://godbolt.org/z/dE3jE1WTz; both Clang and GCC optimize out the bitmask as it is, while MSVC doesn't. By declaring the trampoline as an array of unsigned char, the bitmask works as intended. --- configure.host | 10 +++++-- src/arm/ffi.c | 19 +++++++----- src/arm/ffitarget.h | 6 ++-- src/arm/sysv.S | 72 +++++++++++++++++++++++++++++++++++++++------ 4 files changed, 85 insertions(+), 22 deletions(-) diff --git a/configure.host b/configure.host index 257b78487..268267183 100644 --- a/configure.host +++ b/configure.host @@ -32,7 +32,9 @@ case "${host}" in arm*-*-cygwin* | arm*-*-mingw* | arm*-*-win* ) TARGET=ARM_WIN32; TARGETDIR=arm - MSVC=1 + if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then + MSVC=1 + fi ;; arm*-*-*) @@ -264,7 +266,11 @@ esac # ... but some of the cases above share configury. case "${TARGET}" in ARM_WIN32) - SOURCES="ffi.c sysv_msvc_arm32.S" + if test "$MSVC" = 1; then + SOURCES="ffi.c sysv_msvc_arm32.S" + else + SOURCES="ffi.c sysv.S" + fi ;; ARM_WIN64) if test "$MSVC" = 1; then diff --git a/src/arm/ffi.c b/src/arm/ffi.c index b2f60d16a..593ab4d48 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -37,7 +37,7 @@ #include #include "internal.h" -#if defined(_MSC_VER) && defined(_M_ARM) +#if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include #endif @@ -49,10 +49,13 @@ #endif #else -#ifndef _M_ARM +#ifndef _WIN32 extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN; #else -extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN; +// Declare this as an array of char, instead of array of int, +// otherwise Clang optimizes out the "& 0xFFFFFFFE" for clearing +// the thumb bit. +extern unsigned char ffi_arm_trampoline[12] FFI_HIDDEN; #endif #endif @@ -104,13 +107,13 @@ ffi_put_arg (ffi_type *ty, void *src, void *dst) case FFI_TYPE_SINT32: case FFI_TYPE_UINT32: case FFI_TYPE_POINTER: -#ifndef _MSC_VER +#ifndef _WIN32 case FFI_TYPE_FLOAT: #endif *(UINT32 *)dst = *(UINT32 *)src; break; -#ifdef _MSC_VER +#ifdef _WIN32 // casting a float* to a UINT32* doesn't work on Windows case FFI_TYPE_FLOAT: *(uintptr_t *)dst = 0; @@ -633,7 +636,7 @@ ffi_prep_closure_loc (ffi_closure * closure, #endif /* Initialize the dynamic trampoline. */ -#ifndef _M_ARM +#ifndef _WIN32 memcpy(closure->tramp, ffi_arm_trampoline, 8); #else // cast away function type so MSVC doesn't set the lower bit of the function pointer @@ -643,13 +646,13 @@ ffi_prep_closure_loc (ffi_closure * closure, #if defined (__QNX__) msync(closure->tramp, 8, 0x1000000); /* clear data map */ msync(codeloc, 8, 0x1000000); /* clear insn map */ -#elif defined(_MSC_VER) +#elif defined(_WIN32) FlushInstructionCache(GetCurrentProcess(), closure->tramp, FFI_TRAMPOLINE_SIZE); #else __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */ __clear_cache(codeloc, codeloc + 8); /* clear insn map */ #endif -#ifdef _M_ARM +#ifdef _WIN32 *(void(**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func; #else *(void (**)(void))(closure->tramp + 8) = closure_func; diff --git a/src/arm/ffitarget.h b/src/arm/ffitarget.h index cb57b8488..12d5d2069 100644 --- a/src/arm/ffitarget.h +++ b/src/arm/ffitarget.h @@ -43,7 +43,7 @@ typedef enum ffi_abi { FFI_SYSV, FFI_VFP, FFI_LAST_ABI, -#if defined(__ARM_PCS_VFP) || defined(_M_ARM) +#if defined(__ARM_PCS_VFP) || defined(_WIN32) FFI_DEFAULT_ABI = FFI_VFP, #else FFI_DEFAULT_ABI = FFI_SYSV, @@ -57,7 +57,7 @@ typedef enum ffi_abi { signed char vfp_args[16] \ #define FFI_TARGET_SPECIFIC_VARIADIC -#ifndef _M_ARM +#ifndef _WIN32 #define FFI_TARGET_HAS_COMPLEX_TYPE #endif @@ -77,7 +77,7 @@ typedef enum ffi_abi { #endif #else -#ifdef _MSC_VER +#ifdef _WIN32 #define FFI_TRAMPOLINE_SIZE 16 #define FFI_TRAMPOLINE_CLOSURE_FUNCTION 12 #else diff --git a/src/arm/sysv.S b/src/arm/sysv.S index e816e32d5..fb36213c6 100644 --- a/src/arm/sysv.S +++ b/src/arm/sysv.S @@ -92,9 +92,25 @@ #define ARM_FUNC_END(name) \ SIZE(name) + .text + .syntax unified +#if defined(_WIN32) + /* Windows on ARM is thumb-only */ + .thumb +#else + /* Keep the assembly in ARM mode in other cases, for simplicity + * (to avoid interworking issues). */ +#undef __thumb__ + .arm +#endif + /* Aid in defining a jump table with 8 bytes between entries. */ +#ifdef __thumb__ +/* In thumb mode, instructions can be shorter than expected in arm mode, so + * we need to align the start of each case. */ +# define E(index) .align 3 +#elif defined(__clang__) /* ??? The clang assembler doesn't handle .if with symbolic expressions. */ -#ifdef __clang__ # define E(index) #else # define E(index) \ @@ -103,9 +119,6 @@ .endif #endif - .text - .syntax unified - .arm #ifndef __clang__ /* We require interworking on LDM, which implies ARMv5T, @@ -128,6 +141,7 @@ ARM_FUNC_START(ffi_call_VFP) cfi_startproc cmp r3, #3 @ load only d0 if possible + ite le #ifdef __clang__ vldrle d0, [r0] vldmgt r0, {d0-d7} @@ -167,9 +181,16 @@ ARM_FUNC_START(ffi_call_SYSV) cfi_def_cfa_register(sp) @ Store values stored in registers. +#ifndef __thumb__ .align 3 add pc, pc, r3, lsl #3 nop +#else + adr ip, 0f + add ip, ip, r3, lsl #3 + mov pc, ip + .align 3 +#endif 0: E(ARM_TYPE_VFP_S) #ifdef __clang__ @@ -228,6 +249,9 @@ ARM_FUNC_END(ffi_go_closure_SYSV) ARM_FUNC_START(ffi_closure_SYSV) UNWIND(.fnstart) cfi_startproc +#ifdef _WIN32 + ldmfd sp!, {r0, ip} @ restore fp (r0 is used for stack alignment) +#endif stmdb sp!, {r0-r3} @ save argument regs cfi_adjust_cfa_offset(16) @@ -256,7 +280,12 @@ ARM_FUNC_START(ffi_closure_SYSV) @ Load values returned in registers. add r2, sp, #8+64 @ load result adr r3, CNAME(ffi_closure_ret) +#ifndef __thumb__ add pc, r3, r0, lsl #3 +#else + add r3, r3, r0, lsl #3 + mov pc, r3 +#endif cfi_endproc UNWIND(.fnend) ARM_FUNC_END(ffi_closure_SYSV) @@ -275,6 +304,9 @@ ARM_FUNC_END(ffi_go_closure_VFP) ARM_FUNC_START(ffi_closure_VFP) UNWIND(.fnstart) cfi_startproc +#ifdef _WIN32 + ldmfd sp!, {r0, ip} @ restore fp (r0 is used for stack alignment) +#endif stmdb sp!, {r0-r3} @ save argument regs cfi_adjust_cfa_offset(16) @@ -306,7 +338,12 @@ ARM_FUNC_START(ffi_closure_VFP) @ Load values returned in registers. add r2, sp, #8+64 @ load result adr r3, CNAME(ffi_closure_ret) +#ifndef __thumb__ add pc, r3, r0, lsl #3 +#else + add r3, r3, r0, lsl #3 + mov pc, r3 +#endif cfi_endproc UNWIND(.fnend) ARM_FUNC_END(ffi_closure_VFP) @@ -326,32 +363,40 @@ E(ARM_TYPE_VFP_S) #else ldc p10, cr0, [r2] @ vldr s0, [r2] #endif - ldm sp, {sp,pc} + b call_epilogue E(ARM_TYPE_VFP_D) #ifdef __clang__ vldr d0, [r2] #else ldc p11, cr0, [r2] @ vldr d0, [r2] #endif - ldm sp, {sp,pc} + b call_epilogue E(ARM_TYPE_VFP_N) #ifdef __clang__ vldm r2, {d0-d3} #else ldc p11, cr0, [r2], {8} @ vldm r2, {d0-d3} #endif - ldm sp, {sp,pc} + b call_epilogue E(ARM_TYPE_INT64) ldr r1, [r2, #4] nop E(ARM_TYPE_INT) ldr r0, [r2] - ldm sp, {sp,pc} + b call_epilogue E(ARM_TYPE_VOID) - ldm sp, {sp,pc} + b call_epilogue nop E(ARM_TYPE_STRUCT) + b call_epilogue +call_epilogue: +#ifndef __thumb__ ldm sp, {sp,pc} +#else + ldm sp, {ip,lr} + mov sp, ip + bx lr +#endif cfi_endproc ARM_FUNC_END(ffi_closure_ret) @@ -419,6 +464,15 @@ ARM_FUNC_START(ffi_closure_trampoline_table_page) ARM_FUNC_END(ffi_closure_trampoline_table_page) #endif +#elif defined(_WIN32) + +ARM_FUNC_START(ffi_arm_trampoline) +0: adr ip, 0b + stmdb sp!, {r0, ip} + ldr pc, 1f +1: .long 0 +ARM_FUNC_END(ffi_arm_trampoline) + #else ARM_FUNC_START(ffi_arm_trampoline) From 1f1829bd4ce19b58d0354db3bef21cb8402cdf82 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 1 Jun 2021 22:34:37 -0400 Subject: [PATCH 180/231] Bring in the latest version of perl --- .appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index e1fb63491..f095f7b81 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -62,7 +62,7 @@ install: $env:DEBUG_ARG="--disable-debug" } - 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe' - - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu >NUL' + - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,perl >NUL' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - echo call VsDevCmd to set VS150COMNTOOLS - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" @@ -77,7 +77,7 @@ build_script: - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make)" - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/)" - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make check RUNTESTFLAGS='-v -v -v -v')" - - + + on_finish: - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)" From 03a78e88402fff424426a1968e014be93666b86f Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 1 Jun 2021 22:53:44 -0400 Subject: [PATCH 181/231] Try updating automake --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index f095f7b81..1f820899a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -62,7 +62,7 @@ install: $env:DEBUG_ARG="--disable-debug" } - 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe' - - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,perl >NUL' + - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,automake' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - echo call VsDevCmd to set VS150COMNTOOLS - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" From 04c157f49a1b83798c102f3259bc397b9b7f7266 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 1 Jun 2021 22:57:47 -0400 Subject: [PATCH 182/231] Upgrade to vs2019 --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 1f820899a..31b4b82bf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -8,7 +8,7 @@ shallow_clone: true # 32- and 64-bit clang/mingw # and perhaps more. -image: Visual Studio 2017 +image: Visual Studio 2019 platform: - x64 - x86 From 243004cc4c8be552503a5d10710ebb252b406064 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 1 Jun 2021 23:00:29 -0400 Subject: [PATCH 183/231] Update vs version --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 31b4b82bf..5a4ebce80 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -65,7 +65,7 @@ install: - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,automake' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - echo call VsDevCmd to set VS150COMNTOOLS - - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" + - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" - ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS")) - echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%" - call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM% From ca2235ecfe717ecaed6abbef3a2ca2918a91c60b Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 4 Jun 2021 18:20:24 -0400 Subject: [PATCH 184/231] Revert appveyor changes --- .appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 5a4ebce80..1f820899a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -8,7 +8,7 @@ shallow_clone: true # 32- and 64-bit clang/mingw # and perhaps more. -image: Visual Studio 2019 +image: Visual Studio 2017 platform: - x64 - x86 @@ -65,7 +65,7 @@ install: - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,automake' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - echo call VsDevCmd to set VS150COMNTOOLS - - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" + - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" - ps: $env:VSCOMNTOOLS=(Get-Content ("env:VS" + "$env:VSVER" + "0COMNTOOLS")) - echo "Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS%" - call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM% From 6eb38863bc0b21854959ebf845f8672c44a99684 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 9 Jun 2021 15:45:31 -0400 Subject: [PATCH 185/231] Remove reference to old test case --- testsuite/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index bcfea5770..ee96a0870 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -81,7 +81,7 @@ libffi.closures/cls_ulonglong.c libffi.closures/cls_struct_va1.c \ libffi.closures/cls_9byte2.c libffi.closures/closure_fn5.c \ libffi.closures/cls_5byte.c libffi.closures/cls_3float.c \ libffi.closures/closure.exp libffi.closures/cls_schar.c \ -libffi.closures/closure_fn4.c libffi.closures/cls_uchar_va.c \ +libffi.closures/closure_fn4.c \ libffi.closures/closure_fn0.c libffi.closures/huge_struct.c \ libffi.closures/cls_ushort_va.c \ libffi.closures/cls_64byte.c libffi.closures/cls_longdouble.c \ From e6eb59cde6580607544160f8e7dedc326b4799fd Mon Sep 17 00:00:00 2001 From: Cheng Jin Date: Wed, 9 Jun 2021 16:00:10 -0400 Subject: [PATCH 186/231] Add struct test to verify a nested float struct (#640) The test aims to check a nested float struct [float, [float,float]] to see whether it works good with libffi. Signed-off-by: Cheng Jin --- testsuite/libffi.closures/nested_struct12.c | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 testsuite/libffi.closures/nested_struct12.c diff --git a/testsuite/libffi.closures/nested_struct12.c b/testsuite/libffi.closures/nested_struct12.c new file mode 100644 index 000000000..0d307ae91 --- /dev/null +++ b/testsuite/libffi.closures/nested_struct12.c @@ -0,0 +1,86 @@ +/* Area: ffi_call + Purpose: Check nested float struct. + Limitations: none. + PR: none. + Originator: Cheng Jin */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct stru_FF stru_FF; +typedef struct stru_Nested_F stru_Nested_F; + +struct stru_FF { + float elem1; + float elem2; +}; + +struct stru_Nested_F { + float elem1; + stru_FF elem2; +}; + +static float testNestedFloatStruct(float arg1, stru_Nested_F arg2) +{ + float floatSum = arg1 + arg2.elem1 + arg2.elem2.elem1 + arg2.elem2.elem2; + return floatSum; +} + +int main (void) +{ + float ts12_result = 0; + int structElemNum = 2; + int nestedStructElemNum = 2; + int argNum = 2; + + ffi_cif cif; + ffi_type **struct_float1 = (ffi_type **)malloc(sizeof(ffi_type *) * (structElemNum + 1)); + ffi_type **struct_float2 = (ffi_type **)malloc(sizeof(ffi_type *) * (nestedStructElemNum + 1)); + ffi_type **args = (ffi_type **)malloc(sizeof(ffi_type *) * (argNum + 1)); + void **values = (void **)malloc(sizeof(void *) * (argNum + 1)); + ffi_type struct_float_type1, struct_float_type2; + ffi_type *retType = &ffi_type_float; + float arg1; + float *arg2 = (float *)malloc(sizeof(stru_Nested_F)); + + struct_float2[0] = &ffi_type_float; + struct_float2[1] = &ffi_type_float; + struct_float2[2] = NULL; + + struct_float_type2.size = 0; + struct_float_type2.alignment = 0; + struct_float_type2.type = FFI_TYPE_STRUCT; + struct_float_type2.elements = struct_float2; + + struct_float1[0] = &ffi_type_float; + struct_float1[1] = &struct_float_type2; + struct_float1[2] = NULL; + + struct_float_type1.size = 0; + struct_float_type1.alignment = 0; + struct_float_type1.type = FFI_TYPE_STRUCT; + struct_float_type1.elements = struct_float1; + + args[0] = &ffi_type_float; + args[1] = &struct_float_type1; + args[2] = NULL; + + arg1 = 37.88; + arg2[0] = 31.22; + arg2[1] = 33.44; + arg2[2] = 35.66; + values[0] = &arg1; + values[1] = arg2; + values[2] = NULL; + + CHECK( ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, retType, args) == FFI_OK); + ffi_call(&cif, FFI_FN(testNestedFloatStruct), &ts12_result, values); + CHECK(ts12_result == 138.2f); + + free(struct_float1); + free(struct_float2); + free(args); + free(values); + + exit(0); +} From ff059dd96af6ba4daf7bc9ddf22d1d2dbf6a177b Mon Sep 17 00:00:00 2001 From: vhankala <81743325+vhankala@users.noreply.github.com> Date: Thu, 10 Jun 2021 18:41:02 +0000 Subject: [PATCH 187/231] Fix build on OpenBSD/mips64 (#638) The build fails on OpenBSD/mips64 because clang 11's integrated assembler expects read-only .eh_frame: ../src/mips/n32.S:585:9: error: changed section flags for .eh_frame, expected: 0x2 .section .eh_frame,"aw",@progbits ^ Use EH_FRAME_FLAGS to get matching flags for the section. --- src/mips/n32.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mips/n32.S b/src/mips/n32.S index 1a940b6d2..23b77fdfd 100644 --- a/src/mips/n32.S +++ b/src/mips/n32.S @@ -582,7 +582,7 @@ cls_epilogue: .end ffi_closure_N32 #ifdef __GNUC__ - .section .eh_frame,"aw",@progbits + .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: .4byte .LECIE1-.LSCIE1 # length .LSCIE1: From f56eb85227bbcc7bd81232a338655146385a77ca Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Tue, 15 Jun 2021 08:50:20 -0400 Subject: [PATCH 188/231] Don't stop test on copy failure (#636) * Don't stop test on copy failure Static-library tests were failing only because there were no DLLs to copy. This change makes a copy failure not stop the build; if a failed copy would otherwise be relevent, the later tests would fail anyway. While there are more clever ways to solve this, a brute force fix is sufficient. * [TEST] Try cygwin64; install more packages explicitly * use correct cygwin64 directory name appveyor has cygwin64 pre-installed in /cygwin64, and 32-bit cygwin in /cygwin * More testing - revert VS change, bump travis timeout * Add -g to update the rest of perl * Skip execution tests on non-native platforms Special site.exp that skips the unix_load() command for arm platforms. Unset TERM to avoid cruft in stdout Try harder to find the libffi libraries --- .appveyor.yml | 23 ++++++++++++----------- .appveyor/site.exp | 16 ++++++++++++++++ .appveyor/unix-noexec.exp | 7 +++++++ .travis.yml | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 .appveyor/site.exp create mode 100644 .appveyor/unix-noexec.exp diff --git a/.appveyor.yml b/.appveyor.yml index 1f820899a..48fbb4df2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,8 +21,8 @@ configuration: environment: global: - CYG_ROOT: C:/cygwin - CYG_CACHE: C:/cygwin/var/cache/setup + CYG_ROOT: C:/cygwin64 + CYG_CACHE: C:/cygwin64/var/cache/setup CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/ VSVER: 15 matrix: @@ -61,8 +61,8 @@ install: } Else { $env:DEBUG_ARG="--disable-debug" } - - 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe' - - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu,automake' + - 'appveyor DownloadFile https://cygwin.com/setup-x86_64.exe -FileName setup.exe' + - 'setup.exe -qgnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu -P autoconf -P automake -P libtool' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' - echo call VsDevCmd to set VS150COMNTOOLS - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" @@ -71,13 +71,14 @@ install: - call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM% build_script: - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST $DEBUG_ARG $SHARED_ARG)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/)" - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; make check RUNTESTFLAGS='-v -v -v -v')" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; ./autogen.sh)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST $DEBUG_ARG $SHARED_ARG)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; make)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp $HOST/.libs/libffi.lib $HOST/testsuite/libffi-8.lib || true)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/ || true)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; TERM=none make check RUNTESTFLAGS='-v -v -v -v --target '$HOST DEJAGNU=$PWD/.appveyor/site.exp SITEDIR=$PWD/.appveyor)" on_finish: - - c:\cygwin\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)" + - c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)" diff --git a/.appveyor/site.exp b/.appveyor/site.exp new file mode 100644 index 000000000..93f47731f --- /dev/null +++ b/.appveyor/site.exp @@ -0,0 +1,16 @@ +# Copyright (C) 2021 Anthony Green + +lappend boards_dir $::env(SITEDIR) + +verbose "Global Config File: target_triplet is $target_triplet" 1 +global target_list + +case "$target_triplet" in { + { "aarch*cygwin*" } { + set target_list "unix-noexec" + } + { "arm*cygwin*" } { + set target_list "unix-noexec" + } +} + diff --git a/.appveyor/unix-noexec.exp b/.appveyor/unix-noexec.exp new file mode 100644 index 000000000..9796cfa17 --- /dev/null +++ b/.appveyor/unix-noexec.exp @@ -0,0 +1,7 @@ +load_generic_config "remote" + +proc noexec_load { dest prog args } { + return "unsupported" +} + +set_board_info protocol "noexec" diff --git a/.travis.yml b/.travis.yml index 8db2ddfb2..a18919cd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ before_install: - if test x"$MEVAL" != x; then eval ${MEVAL}; fi install: - - travis_wait 30 ./.travis/install.sh + - travis_wait 60 ./.travis/install.sh script: - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi From 5651bea284ad0822eafe768e3443c2f4d7da2c8f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 15 Jun 2021 15:19:26 -0400 Subject: [PATCH 189/231] 2021-06-15 Jakub Jelinek * src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words to number of words needed for type->size + byte_offset bytes rather than just type->size bytes. Compute pos before the loop and check total size of the structure. * testsuite/libffi.call/nested_struct12.c: New test. --- src/x86/ffi64.c | 8 +- testsuite/libffi.call/nested_struct12.c | 107 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 testsuite/libffi.call/nested_struct12.c diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index 5264cdf2f..438b374e2 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -218,7 +218,8 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], case FFI_TYPE_STRUCT: { const size_t UNITS_PER_WORD = 8; - size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + size_t words = (type->size + byte_offset + UNITS_PER_WORD - 1) + / UNITS_PER_WORD; ffi_type **ptr; unsigned int i; enum x86_64_reg_class subclasses[MAX_CLASSES]; @@ -242,14 +243,15 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], /* Merge the fields of structure. */ for (ptr = type->elements; *ptr != NULL; ptr++) { - size_t num; + size_t num, pos; byte_offset = FFI_ALIGN (byte_offset, (*ptr)->alignment); num = classify_argument (*ptr, subclasses, byte_offset % 8); if (num == 0) return 0; - for (i = 0; i < num; i++) + pos = byte_offset / 8; + for (i = 0; i < num && (i + pos) < words; i++) { size_t pos = byte_offset / 8; classes[i + pos] = diff --git a/testsuite/libffi.call/nested_struct12.c b/testsuite/libffi.call/nested_struct12.c new file mode 100644 index 000000000..6c139b952 --- /dev/null +++ b/testsuite/libffi.call/nested_struct12.c @@ -0,0 +1,107 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing. + Limitations: none. + PR: none. + Originator: and 20210609 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + float a, b; +} A; + +typedef struct B { + float x; + struct A y; +} B; + +B B_fn(float b0, struct B b1) +{ + struct B result; + + result.x = b0 + b1.x; + result.y.a = b0 + b1.y.a; + result.y.b = b0 + b1.y.b; + + printf("%g %g %g %g: %g %g %g\n", b0, b1.x, b1.y.a, b1.y.b, + result.x, result.y.a, result.y.b); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + float b0; + struct B b1; + + b0 = *(float*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + float e_dbl = 12.125f; + struct B f_dbl = { 24.75f, { 31.625f, 32.25f } }; + + struct B 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_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_float; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &ffi_type_float; + cls_struct_fields1[1] = &cls_struct_type; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &ffi_type_float; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ + CHECK( res_dbl.x == (e_dbl + f_dbl.x)); + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(float, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ + CHECK( res_dbl.x == (e_dbl + f_dbl.x)); + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + + exit(0); +} From 84bb56914756845371be62e2753041521fd5d261 Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Tue, 22 Jun 2021 07:33:46 -0400 Subject: [PATCH 190/231] Remove libtool-ldflags file from .gitignore (#600) This is correct. Thank you! --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5d3968946..e393a472d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ include/ffitarget.h install-sh libffi.pc libtool -libtool-ldflags ltmain.sh m4/libtool.m4 m4/lt*.m4 From fa1ef887d4dc5d18696517e32e2ae98310f0040d Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 22 Jun 2021 08:48:24 -0400 Subject: [PATCH 191/231] Avoid undefined behaviour --- testsuite/libffi.bhaible/testcases.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testsuite/libffi.bhaible/testcases.c b/testsuite/libffi.bhaible/testcases.c index d25ebf48c..23a6f4660 100644 --- a/testsuite/libffi.bhaible/testcases.c +++ b/testsuite/libffi.bhaible/testcases.c @@ -64,7 +64,11 @@ typedef struct { typedef struct { char c[3]; } T; typedef struct { char c[33],c1; } X; -char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1; +/* Don't use a number over 127, as some systems use signed chars and + the test case 25 doesn't account for this, resulting in undefined + behavior. See https://github.com/libffi/libffi/issues/598. */ +char c1='a', c2=127, c3=(char)1; + short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9; int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9, i10=11, i11=12, i12=13, i13=14, i14=15, i15=16, i16=17; From becae7397873d6bb85a271b16961f055e71f42a6 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Tue, 22 Jun 2021 13:01:06 -0400 Subject: [PATCH 192/231] Switch from travis-ci.org to travis-ci.com. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a412191a6..7ac463561 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Status ====== -[![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) +[![Build Status](https://travis-ci.com/libffi/libffi.svg?branch=master)](https://travis-ci.com/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) libffi-3.4 was released on TBD. Check the libffi web From 8d83c7c1fa331b93e58967979c59c38600df1ee9 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 25 Jun 2021 19:50:33 -0700 Subject: [PATCH 193/231] Make test methods static (#644) --- testsuite/libffi.closures/cls_20byte.c | 2 +- testsuite/libffi.closures/cls_20byte1.c | 2 +- testsuite/libffi.closures/cls_5_1_byte.c | 2 +- testsuite/libffi.closures/cls_5byte.c | 2 +- testsuite/libffi.closures/cls_6_1_byte.c | 2 +- testsuite/libffi.closures/cls_6byte.c | 2 +- testsuite/libffi.closures/cls_7_1_byte.c | 2 +- testsuite/libffi.closures/cls_7byte.c | 2 +- testsuite/libffi.closures/cls_9byte1.c | 2 +- testsuite/libffi.closures/cls_9byte2.c | 2 +- testsuite/libffi.closures/cls_align_double.c | 2 +- testsuite/libffi.closures/cls_align_float.c | 2 +- testsuite/libffi.closures/cls_align_longdouble.c | 2 +- testsuite/libffi.closures/cls_align_longdouble_split.c | 2 +- testsuite/libffi.closures/cls_align_longdouble_split2.c | 2 +- testsuite/libffi.closures/cls_align_pointer.c | 2 +- testsuite/libffi.closures/cls_align_sint16.c | 2 +- testsuite/libffi.closures/cls_align_sint32.c | 2 +- testsuite/libffi.closures/cls_align_sint64.c | 2 +- testsuite/libffi.closures/cls_align_uint16.c | 2 +- testsuite/libffi.closures/cls_align_uint32.c | 2 +- testsuite/libffi.closures/cls_align_uint64.c | 2 +- testsuite/libffi.closures/cls_multi_schar.c | 2 +- testsuite/libffi.closures/cls_multi_sshort.c | 2 +- testsuite/libffi.closures/cls_multi_sshortchar.c | 2 +- testsuite/libffi.closures/cls_multi_uchar.c | 2 +- testsuite/libffi.closures/cls_multi_ushort.c | 2 +- testsuite/libffi.closures/cls_multi_ushortchar.c | 2 +- testsuite/libffi.closures/nested_struct.c | 2 +- testsuite/libffi.closures/nested_struct1.c | 2 +- testsuite/libffi.closures/nested_struct2.c | 2 +- testsuite/libffi.closures/nested_struct3.c | 2 +- testsuite/libffi.closures/stret_medium.c | 2 +- testsuite/libffi.closures/stret_medium2.c | 2 +- testsuite/libffi.closures/testclosure.c | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/testsuite/libffi.closures/cls_20byte.c b/testsuite/libffi.closures/cls_20byte.c index 3f8bb28ad..34ea021fb 100644 --- a/testsuite/libffi.closures/cls_20byte.c +++ b/testsuite/libffi.closures/cls_20byte.c @@ -14,7 +14,7 @@ typedef struct cls_struct_20byte { int c; } cls_struct_20byte; -cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, +static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, struct cls_struct_20byte a2) { struct cls_struct_20byte result; diff --git a/testsuite/libffi.closures/cls_20byte1.c b/testsuite/libffi.closures/cls_20byte1.c index 65627273c..eab4be603 100644 --- a/testsuite/libffi.closures/cls_20byte1.c +++ b/testsuite/libffi.closures/cls_20byte1.c @@ -16,7 +16,7 @@ typedef struct cls_struct_20byte { double c; } cls_struct_20byte; -cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, +static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, struct cls_struct_20byte a2) { struct cls_struct_20byte result; diff --git a/testsuite/libffi.closures/cls_5_1_byte.c b/testsuite/libffi.closures/cls_5_1_byte.c index ad9d51c24..8db761cd5 100644 --- a/testsuite/libffi.closures/cls_5_1_byte.c +++ b/testsuite/libffi.closures/cls_5_1_byte.c @@ -16,7 +16,7 @@ typedef struct cls_struct_5byte { unsigned char e; } cls_struct_5byte; -cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, +static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, struct cls_struct_5byte a2) { struct cls_struct_5byte result; diff --git a/testsuite/libffi.closures/cls_5byte.c b/testsuite/libffi.closures/cls_5byte.c index 4e0c0003c..fbb69ce4a 100644 --- a/testsuite/libffi.closures/cls_5byte.c +++ b/testsuite/libffi.closures/cls_5byte.c @@ -14,7 +14,7 @@ typedef struct cls_struct_5byte { unsigned char c; } cls_struct_5byte; -cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, +static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, struct cls_struct_5byte a2) { struct cls_struct_5byte result; diff --git a/testsuite/libffi.closures/cls_6_1_byte.c b/testsuite/libffi.closures/cls_6_1_byte.c index b4dcdba47..797098628 100644 --- a/testsuite/libffi.closures/cls_6_1_byte.c +++ b/testsuite/libffi.closures/cls_6_1_byte.c @@ -17,7 +17,7 @@ typedef struct cls_struct_6byte { unsigned char f; } cls_struct_6byte; -cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, +static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, struct cls_struct_6byte a2) { struct cls_struct_6byte result; diff --git a/testsuite/libffi.closures/cls_6byte.c b/testsuite/libffi.closures/cls_6byte.c index 740678017..e89c73cf8 100644 --- a/testsuite/libffi.closures/cls_6byte.c +++ b/testsuite/libffi.closures/cls_6byte.c @@ -16,7 +16,7 @@ typedef struct cls_struct_6byte { unsigned char d; } cls_struct_6byte; -cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, +static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, struct cls_struct_6byte a2) { struct cls_struct_6byte result; diff --git a/testsuite/libffi.closures/cls_7_1_byte.c b/testsuite/libffi.closures/cls_7_1_byte.c index 14a7e96f9..94b1a44bd 100644 --- a/testsuite/libffi.closures/cls_7_1_byte.c +++ b/testsuite/libffi.closures/cls_7_1_byte.c @@ -18,7 +18,7 @@ typedef struct cls_struct_7byte { unsigned char g; } cls_struct_7byte; -cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, +static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, struct cls_struct_7byte a2) { struct cls_struct_7byte result; diff --git a/testsuite/libffi.closures/cls_7byte.c b/testsuite/libffi.closures/cls_7byte.c index 1645cc635..3aa8d6cfe 100644 --- a/testsuite/libffi.closures/cls_7byte.c +++ b/testsuite/libffi.closures/cls_7byte.c @@ -15,7 +15,7 @@ typedef struct cls_struct_7byte { unsigned short d; } cls_struct_7byte; -cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, +static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, struct cls_struct_7byte a2) { struct cls_struct_7byte result; diff --git a/testsuite/libffi.closures/cls_9byte1.c b/testsuite/libffi.closures/cls_9byte1.c index 0b8572223..6eb452036 100644 --- a/testsuite/libffi.closures/cls_9byte1.c +++ b/testsuite/libffi.closures/cls_9byte1.c @@ -15,7 +15,7 @@ typedef struct cls_struct_9byte { double b; } cls_struct_9byte; -cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, +static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, struct cls_struct_9byte b2) { struct cls_struct_9byte result; diff --git a/testsuite/libffi.closures/cls_9byte2.c b/testsuite/libffi.closures/cls_9byte2.c index edf991de7..26e460bc7 100644 --- a/testsuite/libffi.closures/cls_9byte2.c +++ b/testsuite/libffi.closures/cls_9byte2.c @@ -15,7 +15,7 @@ typedef struct cls_struct_9byte { int b; } cls_struct_9byte; -cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, +static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, struct cls_struct_9byte b2) { struct cls_struct_9byte result; diff --git a/testsuite/libffi.closures/cls_align_double.c b/testsuite/libffi.closures/cls_align_double.c index aad5f3ced..910e2287d 100644 --- a/testsuite/libffi.closures/cls_align_double.c +++ b/testsuite/libffi.closures/cls_align_double.c @@ -15,7 +15,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_float.c b/testsuite/libffi.closures/cls_align_float.c index 37e085529..56161ef63 100644 --- a/testsuite/libffi.closures/cls_align_float.c +++ b/testsuite/libffi.closures/cls_align_float.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_longdouble.c b/testsuite/libffi.closures/cls_align_longdouble.c index b3322d861..3dccdef10 100644 --- a/testsuite/libffi.closures/cls_align_longdouble.c +++ b/testsuite/libffi.closures/cls_align_longdouble.c @@ -14,7 +14,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_longdouble_split.c b/testsuite/libffi.closures/cls_align_longdouble_split.c index cc1c43b8c..9b01cbd01 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split.c @@ -19,7 +19,7 @@ typedef struct cls_struct_align { long double g; } cls_struct_align; -cls_struct_align cls_struct_align_fn( +static cls_struct_align cls_struct_align_fn( cls_struct_align a1, cls_struct_align a2) { diff --git a/testsuite/libffi.closures/cls_align_longdouble_split2.c b/testsuite/libffi.closures/cls_align_longdouble_split2.c index 5d3bec071..8a973e7a2 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split2.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split2.c @@ -20,7 +20,7 @@ typedef struct cls_struct_align { long double g; } cls_struct_align; -cls_struct_align cls_struct_align_fn( +static cls_struct_align cls_struct_align_fn( cls_struct_align a1, cls_struct_align a2) { diff --git a/testsuite/libffi.closures/cls_align_pointer.c b/testsuite/libffi.closures/cls_align_pointer.c index 8fbf36a5c..ef59259df 100644 --- a/testsuite/libffi.closures/cls_align_pointer.c +++ b/testsuite/libffi.closures/cls_align_pointer.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_sint16.c b/testsuite/libffi.closures/cls_align_sint16.c index 039b87473..79977093d 100644 --- a/testsuite/libffi.closures/cls_align_sint16.c +++ b/testsuite/libffi.closures/cls_align_sint16.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_sint32.c b/testsuite/libffi.closures/cls_align_sint32.c index c96c6d136..5edde7224 100644 --- a/testsuite/libffi.closures/cls_align_sint32.c +++ b/testsuite/libffi.closures/cls_align_sint32.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_sint64.c b/testsuite/libffi.closures/cls_align_sint64.c index 9aa7bdddf..bcba22f3e 100644 --- a/testsuite/libffi.closures/cls_align_sint64.c +++ b/testsuite/libffi.closures/cls_align_sint64.c @@ -14,7 +14,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_uint16.c b/testsuite/libffi.closures/cls_align_uint16.c index 97620b79d..f33c0ec68 100644 --- a/testsuite/libffi.closures/cls_align_uint16.c +++ b/testsuite/libffi.closures/cls_align_uint16.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_uint32.c b/testsuite/libffi.closures/cls_align_uint32.c index 5766fadf0..c96eee6bb 100644 --- a/testsuite/libffi.closures/cls_align_uint32.c +++ b/testsuite/libffi.closures/cls_align_uint32.c @@ -13,7 +13,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_align_uint64.c b/testsuite/libffi.closures/cls_align_uint64.c index a52cb8939..958e1c2ca 100644 --- a/testsuite/libffi.closures/cls_align_uint64.c +++ b/testsuite/libffi.closures/cls_align_uint64.c @@ -15,7 +15,7 @@ typedef struct cls_struct_align { unsigned char c; } cls_struct_align; -cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, +static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, struct cls_struct_align a2) { struct cls_struct_align result; diff --git a/testsuite/libffi.closures/cls_multi_schar.c b/testsuite/libffi.closures/cls_multi_schar.c index 71df7b651..417f7be82 100644 --- a/testsuite/libffi.closures/cls_multi_schar.c +++ b/testsuite/libffi.closures/cls_multi_schar.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -signed char test_func_fn(signed char a1, signed char a2) +static signed char test_func_fn(signed char a1, signed char a2) { signed char result; diff --git a/testsuite/libffi.closures/cls_multi_sshort.c b/testsuite/libffi.closures/cls_multi_sshort.c index 4c3915326..467146dbd 100644 --- a/testsuite/libffi.closures/cls_multi_sshort.c +++ b/testsuite/libffi.closures/cls_multi_sshort.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -signed short test_func_fn(signed short a1, signed short a2) +static signed short test_func_fn(signed short a1, signed short a2) { signed short result; diff --git a/testsuite/libffi.closures/cls_multi_sshortchar.c b/testsuite/libffi.closures/cls_multi_sshortchar.c index 1c3aeb5a6..de45b593e 100644 --- a/testsuite/libffi.closures/cls_multi_sshortchar.c +++ b/testsuite/libffi.closures/cls_multi_sshortchar.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -signed short test_func_fn(signed char a1, signed short a2, +static signed short test_func_fn(signed char a1, signed short a2, signed char a3, signed short a4) { signed short result; diff --git a/testsuite/libffi.closures/cls_multi_uchar.c b/testsuite/libffi.closures/cls_multi_uchar.c index 009c02c72..eb93e95e3 100644 --- a/testsuite/libffi.closures/cls_multi_uchar.c +++ b/testsuite/libffi.closures/cls_multi_uchar.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -unsigned char test_func_fn(unsigned char a1, unsigned char a2, +static unsigned char test_func_fn(unsigned char a1, unsigned char a2, unsigned char a3, unsigned char a4) { unsigned char result; diff --git a/testsuite/libffi.closures/cls_multi_ushort.c b/testsuite/libffi.closures/cls_multi_ushort.c index dd10ca734..0e5838df1 100644 --- a/testsuite/libffi.closures/cls_multi_ushort.c +++ b/testsuite/libffi.closures/cls_multi_ushort.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -unsigned short test_func_fn(unsigned short a1, unsigned short a2) +static unsigned short test_func_fn(unsigned short a1, unsigned short a2) { unsigned short result; diff --git a/testsuite/libffi.closures/cls_multi_ushortchar.c b/testsuite/libffi.closures/cls_multi_ushortchar.c index 2588e97f9..69aedfe0d 100644 --- a/testsuite/libffi.closures/cls_multi_ushortchar.c +++ b/testsuite/libffi.closures/cls_multi_ushortchar.c @@ -7,7 +7,7 @@ /* { dg-do run } */ #include "ffitest.h" -unsigned short test_func_fn(unsigned char a1, unsigned short a2, +static unsigned short test_func_fn(unsigned char a1, unsigned short a2, unsigned char a3, unsigned short a4) { unsigned short result; diff --git a/testsuite/libffi.closures/nested_struct.c b/testsuite/libffi.closures/nested_struct.c index c15e3a033..10797a345 100644 --- a/testsuite/libffi.closures/nested_struct.c +++ b/testsuite/libffi.closures/nested_struct.c @@ -25,7 +25,7 @@ typedef struct cls_struct_combined { cls_struct_16byte2 e; } cls_struct_combined; -cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, +static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, struct cls_struct_16byte2 b1, struct cls_struct_combined b2) { diff --git a/testsuite/libffi.closures/nested_struct1.c b/testsuite/libffi.closures/nested_struct1.c index 477a6b9bd..df8ab5973 100644 --- a/testsuite/libffi.closures/nested_struct1.c +++ b/testsuite/libffi.closures/nested_struct1.c @@ -25,7 +25,7 @@ typedef struct cls_struct_combined { cls_struct_16byte2 e; } cls_struct_combined; -cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, +static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, struct cls_struct_16byte2 b1, struct cls_struct_combined b2, struct cls_struct_16byte1 b3) diff --git a/testsuite/libffi.closures/nested_struct2.c b/testsuite/libffi.closures/nested_struct2.c index 69268cdb8..d919e5c93 100644 --- a/testsuite/libffi.closures/nested_struct2.c +++ b/testsuite/libffi.closures/nested_struct2.c @@ -19,7 +19,7 @@ typedef struct B { unsigned char y; } B; -B B_fn(struct A b0, struct B b1) +static B B_fn(struct A b0, struct B b1) { struct B result; diff --git a/testsuite/libffi.closures/nested_struct3.c b/testsuite/libffi.closures/nested_struct3.c index ab18cad73..7d4c2cf80 100644 --- a/testsuite/libffi.closures/nested_struct3.c +++ b/testsuite/libffi.closures/nested_struct3.c @@ -19,7 +19,7 @@ typedef struct B { unsigned char y; } B; -B B_fn(struct A b0, struct B b1) +static B B_fn(struct A b0, struct B b1) { struct B result; diff --git a/testsuite/libffi.closures/stret_medium.c b/testsuite/libffi.closures/stret_medium.c index 973ee02ed..56e3d9d8f 100644 --- a/testsuite/libffi.closures/stret_medium.c +++ b/testsuite/libffi.closures/stret_medium.c @@ -21,7 +21,7 @@ typedef struct struct_72byte { double i; } struct_72byte; -struct_72byte cls_struct_72byte_fn( +static struct_72byte cls_struct_72byte_fn( struct_72byte b0, struct_72byte b1, struct_72byte b2, diff --git a/testsuite/libffi.closures/stret_medium2.c b/testsuite/libffi.closures/stret_medium2.c index 84323d16a..0746b6ee4 100644 --- a/testsuite/libffi.closures/stret_medium2.c +++ b/testsuite/libffi.closures/stret_medium2.c @@ -22,7 +22,7 @@ typedef struct struct_72byte { long long i; } struct_72byte; -struct_72byte cls_struct_72byte_fn( +static struct_72byte cls_struct_72byte_fn( struct_72byte b0, struct_72byte b1, struct_72byte b2, diff --git a/testsuite/libffi.closures/testclosure.c b/testsuite/libffi.closures/testclosure.c index ca31056d8..600368e0c 100644 --- a/testsuite/libffi.closures/testclosure.c +++ b/testsuite/libffi.closures/testclosure.c @@ -14,7 +14,7 @@ typedef struct cls_struct_combined { float d; } cls_struct_combined; -void cls_struct_combined_fn(struct cls_struct_combined arg) +static void cls_struct_combined_fn(struct cls_struct_combined arg) { printf("%g %g %g %g\n", arg.a, arg.b, From 87429ce726ead7bb789d194c6d979c5b0c4086e9 Mon Sep 17 00:00:00 2001 From: Matthew Green <85970515+squidhacks@users.noreply.github.com> Date: Sat, 26 Jun 2021 08:49:45 -0400 Subject: [PATCH 194/231] This test includes a closure and must live in the closures test directory. (#645) Co-authored-by: Matthew Green --- .../nested_struct12.c => libffi.closures/nested_struct13.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename testsuite/{libffi.call/nested_struct12.c => libffi.closures/nested_struct13.c} (100%) diff --git a/testsuite/libffi.call/nested_struct12.c b/testsuite/libffi.closures/nested_struct13.c similarity index 100% rename from testsuite/libffi.call/nested_struct12.c rename to testsuite/libffi.closures/nested_struct13.c From c0b210c7fd1e5b4a17e9fc839a4cf1d75483d591 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 26 Jun 2021 10:55:57 -0400 Subject: [PATCH 195/231] Remove test case --- testsuite/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index ee96a0870..8dc8d2eb2 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -83,7 +83,6 @@ libffi.closures/cls_5byte.c libffi.closures/cls_3float.c \ libffi.closures/closure.exp libffi.closures/cls_schar.c \ libffi.closures/closure_fn4.c \ libffi.closures/closure_fn0.c libffi.closures/huge_struct.c \ -libffi.closures/cls_ushort_va.c \ libffi.closures/cls_64byte.c libffi.closures/cls_longdouble.c \ libffi.closures/cls_ulong_va.c libffi.closures/cls_6_1_byte.c \ libffi.closures/cls_align_uint16.c libffi.closures/closure_fn2.c \ From 1e5dc8de825d03f5493884a45e1edeacda2106c5 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 26 Jun 2021 12:08:35 -0400 Subject: [PATCH 196/231] Add missing file from make dist. Add missing license info. --- include/Makefile.am | 2 +- include/ffi_cfi.h | 21 +++++++++++++++++++++ include/ffi_common.h | 21 +++++++++++++++++++++ include/tramp.h | 21 +++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/include/Makefile.am b/include/Makefile.am index c59df9fb3..5f0d4066f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS=foreign DISTCLEANFILES=ffitarget.h -noinst_HEADERS=ffi_common.h ffi_cfi.h +noinst_HEADERS=ffi_common.h ffi_cfi.h tramp.h EXTRA_DIST=ffi.h.in nodist_include_HEADERS = ffi.h ffitarget.h diff --git a/include/ffi_cfi.h b/include/ffi_cfi.h index 244ce572b..f4c292d00 100644 --- a/include/ffi_cfi.h +++ b/include/ffi_cfi.h @@ -2,6 +2,27 @@ ffi_cfi.h - Copyright (c) 2014 Red Hat, Inc. Conditionally assemble cfi directives. Only necessary for building libffi. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the ``Software''), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ #ifndef FFI_CFI_H diff --git a/include/ffi_common.h b/include/ffi_common.h index d3db33ada..20aa756a2 100644 --- a/include/ffi_common.h +++ b/include/ffi_common.h @@ -5,6 +5,27 @@ Common internal definitions and macros. Only necessary for building libffi. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the ``Software''), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ #ifndef FFI_COMMON_H diff --git a/include/tramp.h b/include/tramp.h index cc096a4b9..e14e463e8 100644 --- a/include/tramp.h +++ b/include/tramp.h @@ -2,6 +2,27 @@ ffi_tramp.h - Copyright (C) 2021 Microsoft, Inc. Static trampoline definitions. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the ``Software''), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + ----------------------------------------------------------------------- */ #ifndef FFI_TRAMP_H From 9cf15b3a284d8e79f3673b8743d4157739df5d36 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sat, 26 Jun 2021 12:12:06 -0400 Subject: [PATCH 197/231] Make 3.4 release candidate 1 --- configure.ac | 2 +- doc/version.texi | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index a9b7bf6a3..fea024290 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.3], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.4-rc1], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index d9d509492..70d48f66b 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 22 November 2019 -@set UPDATED-MONTH November 2019 -@set EDITION 3.3 -@set VERSION 3.3 +@set UPDATED 26 June 2021 +@set UPDATED-MONTH June 2021 +@set EDITION 3.4-rc1 +@set VERSION 3.4-rc1 From f792adb61a27aa2a7d24573b956ce29ebdb82e03 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 26 Jun 2021 22:26:52 +0100 Subject: [PATCH 198/231] configure.ac: allow user to specify READELF (#646) Before the change with x86_64-pc-linux-gnu cross-compiler installed the configure was not able to find cross-readelf: ``` $ ./configure --host=x86_64-pc-linux-gnu ... checking whether .eh_frame section should be read-only... .././configure: line 19540: readelf: command not found yes ... ``` The change uses AC_CHECK_TOOL to automatically seatch for ${host}-readelf, readelf. And as a bonus it also allows user to override readelf with something like READELF=llvm-readelf. Signed-off-by: Sergei Trofimovich --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fea024290..21d4f85a9 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,8 @@ AM_PROG_CC_C_O AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIR([m4]) +AC_CHECK_TOOL(READELF, readelf) + # Test for 64-bit build. AC_CHECK_SIZEOF([size_t]) @@ -271,7 +273,7 @@ if test "x$GCC" = "xyes"; then libffi_cv_ro_eh_frame=yes echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then - if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then + if $READELF -WS conftest.o | grep -q -n 'eh_frame .* WA'; then libffi_cv_ro_eh_frame=no fi fi From 11f9713887e1d8e9bdf861c1555de55aba9fc46c Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 27 Jun 2021 07:46:12 -0400 Subject: [PATCH 199/231] Update contact info --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7ac463561..542a49a93 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Status ====== -[![Build Status](https://travis-ci.com/libffi/libffi.svg?branch=master)](https://travis-ci.com/libffi/libffi) +[![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) libffi-3.4 was released on TBD. Check the libffi web @@ -443,9 +443,10 @@ developers: avr32 Bradley Smith blackfin Alexandre Keunecke I. de Mendonca cris Simon Posnjak, Hans-Peter Nilsson - csky Ma Jun, Zhang Wenmeng + csky Ma Jun, Zhang Wenmeng frv Anthony Green ia64 Hans Boehm + kvx Yann Sionneau m32r Kazuhiro Inaoka m68k Andreas Schwab m88k Miod Vallat @@ -487,6 +488,11 @@ Alex Oliva solved the executable page problem for SElinux. The list above is almost certainly incomplete and inaccurate. I'm happy to make corrections or additions upon request. -If you have a problem, or have found a bug, please send a note to the -author at green@moxielogic.com, or the project mailing list at -libffi-discuss@sourceware.org. +If you have a problem, or have found a bug, please file an issue on +our issue tracker at https://github.com/libffi/libffi/issues. + +The author can be reached at green@moxielogic.com. + +To subscribe/unsubscribe to our mailing lists, visit: +https://sourceware.org/mailman/listinfo/libffi-announce +https://sourceware.org/mailman/listinfo/libffi-discuss From 4e07374c2773711902ec12905d5c64d95d22d050 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 27 Jun 2021 11:25:06 -0400 Subject: [PATCH 200/231] Remove caveat about varargs support --- doc/libffi.texi | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/libffi.texi b/doc/libffi.texi index 28f0e6adb..7fd3625d9 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -1041,9 +1041,6 @@ The ``raw'' API is undocumented. The Go API is undocumented. @end itemize -Note that variadic support is very new and tested on a relatively -small number of platforms. - @node Index @unnumbered Index From 132699b95d3ee4d889ea2a80540acf3300987dad Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 27 Jun 2021 16:50:20 +0100 Subject: [PATCH 201/231] configure.ac: add --disable-exec-static-tramp flag (#647) Some projects like GHC (Glasgow Haskell Compiler) and gobject-introspection use `ffi_closure_alloc()` as a way to allocate executable memory. exec static tramp interferes with it (unclear how exactly yet). GHC symptom: ffi closure freeing cimplains about unexpected trampoline (GHC manually fills one): ``` $ ghci GHCi, version 8.10.5: https://www.haskell.org/ghc/ :? for help ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efe8 ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efc8 ``` gobject-introspection symptom: ``` $ meld Segmentation fault (core dumped) $ gdb --args /usr/bin/python3.9 /usr/bin/meld (gdb) run ... Thread 1 "python3.9" received signal SIGSEGV, Segmentation fault. 0x00007fffe9ac1ae8 in g_callable_info_free_closure ( callable_info=0x555555d45990, closure=0x7fffe9e70c20) at ../gobject-introspection-1.68.0/girepository/girffi.c:428 428 g_free (wrapper->ffi_closure.cif->arg_types); (gdb) bt callable_info=0x555555d45990, closure=0x7fffe9e70c20) at ../gobject-introspection-1.68.0/girepository/girffi.c:428 data=0x555555d252d0) at ../pygobject-3.40.1/gi/pygi-closure.c:635 ... ``` To ease downstreams narrowing down the actual problem let's provide a knob to disable exec static trampolines. The change for not affect current default. Signed-off-by: Sergei Trofimovich --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 21d4f85a9..b3e78f32a 100644 --- a/configure.ac +++ b/configure.ac @@ -366,6 +366,10 @@ AC_ARG_ENABLE(raw-api, AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.]) fi) +AC_ARG_ENABLE(exec-static-tramp, +[ --disable-exec-static-tramp disable use of static exec trampolines (enabled by default)]) + +if test "$enable_exec_static_tramp" != no; then case "$target" in *-cygwin*) ;; @@ -374,6 +378,7 @@ case "$target" in [Define this if you want statically defined trampolines]) ;; esac +fi AC_ARG_ENABLE(purify-safety, [ --enable-purify-safety purify-safe mode], From 91eaadfb2e4b79d12a45d24002b06563e5905e5d Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sun, 27 Jun 2021 09:49:31 -0700 Subject: [PATCH 202/231] Fix signature of function pointer in cls_dbls_struct (#648) --- testsuite/libffi.closures/cls_dbls_struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.closures/cls_dbls_struct.c b/testsuite/libffi.closures/cls_dbls_struct.c index e451dea51..25b8b6350 100644 --- a/testsuite/libffi.closures/cls_dbls_struct.c +++ b/testsuite/libffi.closures/cls_dbls_struct.c @@ -56,7 +56,7 @@ int main(int argc __UNUSED__, char** argv __UNUSED__) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK); - ((void*(*)(Dbls))(code))(arg); + ((void (*)(Dbls))(code))(arg); /* { dg-output "1.0 2.0" } */ closure_test_fn(arg); From 9fa94c607852081adce33547bde292fe4313cff7 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sun, 27 Jun 2021 11:02:33 -0700 Subject: [PATCH 203/231] Print more information when an assertion fails in test suite (#649) --- testsuite/libffi.call/ffitest.h | 8 +++++++- testsuite/libffi.closures/ffitest.h | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index cfce1ad58..95d96a83f 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -15,7 +15,13 @@ #define MAX_ARGS 256 -#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0) +#define CHECK(x) \ + do { \ + if(!(x)){ \ + printf("Check failed:\n%s\n", #x); \ + abort(); \ + } \ + } while(0) /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ diff --git a/testsuite/libffi.closures/ffitest.h b/testsuite/libffi.closures/ffitest.h index cfce1ad58..95d96a83f 100644 --- a/testsuite/libffi.closures/ffitest.h +++ b/testsuite/libffi.closures/ffitest.h @@ -15,7 +15,13 @@ #define MAX_ARGS 256 -#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0) +#define CHECK(x) \ + do { \ + if(!(x)){ \ + printf("Check failed:\n%s\n", #x); \ + abort(); \ + } \ + } while(0) /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ From cd4428911d5c4d25ce2c24e6728124792124bba2 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Mon, 28 Jun 2021 04:56:30 -0700 Subject: [PATCH 204/231] Add missing FFI_HIDDEN to ffi_tramp_is_present declaration (#651) Signed-off-by: Jeremy Huddleston Sequoia --- include/ffi_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ffi_common.h b/include/ffi_common.h index 20aa756a2..2bd31b03d 100644 --- a/include/ffi_common.h +++ b/include/ffi_common.h @@ -126,7 +126,7 @@ void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN; /* The arch code calls this to determine if a given closure has a static trampoline. */ -int ffi_tramp_is_present (void *closure); +int ffi_tramp_is_present (void *closure) FFI_HIDDEN; /* Extended cif, used in callback from assembly routine */ typedef struct From 4557f232926353f5cdec0f2f459e4d59ce8f19e4 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 09:53:01 -0400 Subject: [PATCH 205/231] 3.4.0 release candidate 2 --- README.md | 4 ++-- configure.ac | 2 +- doc/version.texi | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 542a49a93..183cb6418 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Status [![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) [![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) -libffi-3.4 was released on TBD. Check the libffi web -page for updates: . +libffi-3.4.0 was released on TBD. Check the libffi web page for +updates: . What is libffi? diff --git a/configure.ac b/configure.ac index b3e78f32a..144129b98 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.4-rc1], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.4.0-rc2], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index 70d48f66b..7e681ca88 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 26 June 2021 +@set UPDATED 27 June 2021 @set UPDATED-MONTH June 2021 -@set EDITION 3.4-rc1 -@set VERSION 3.4-rc1 +@set EDITION 3.4.0-rc2 +@set VERSION 3.4.0-rc2 From f08c5ace5750f1e1f234f52f4d3d772bb8d276a0 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jun 2021 07:24:19 -0700 Subject: [PATCH 206/231] Fix the assertions in cls-24byte (#652) * Fix the assertions in cls-24byte * Update print statement too --- testsuite/libffi.closures/cls_24byte.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testsuite/libffi.closures/cls_24byte.c b/testsuite/libffi.closures/cls_24byte.c index 1d82f6e4a..78796da92 100644 --- a/testsuite/libffi.closures/cls_24byte.c +++ b/testsuite/libffi.closures/cls_24byte.c @@ -31,7 +31,7 @@ cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0, b0.a, b0.b, b0.c, b0.d, b1.a, b1.b, b1.c, b1.d, b2.a, b2.b, b2.c, b2.d, - b3.a, b3.b, b3.c, b2.d, + b3.a, b3.b, b3.c, b3.d, result.a, result.b, result.c, result.d); return result; @@ -94,7 +94,7 @@ int main (void) args_dbl[4] = NULL; ffi_call(&cif, FFI_FN(cls_struct_24byte_fn), &res_dbl, args_dbl); - /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ + /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ @@ -105,7 +105,7 @@ int main (void) cls_struct_24byte, cls_struct_24byte)) (code))(e_dbl, f_dbl, g_dbl, h_dbl); - /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */ + /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ From ee3ef737857e13cc01a15dbef298478d90188805 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 28 Jun 2021 11:51:35 -0700 Subject: [PATCH 207/231] Add tests for single entry structs (#653) --- .../libffi.closures/single_entry_structs1.c | 86 +++++++++++++++ .../libffi.closures/single_entry_structs2.c | 102 ++++++++++++++++++ .../libffi.closures/single_entry_structs3.c | 101 +++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 testsuite/libffi.closures/single_entry_structs1.c create mode 100644 testsuite/libffi.closures/single_entry_structs2.c create mode 100644 testsuite/libffi.closures/single_entry_structs3.c diff --git a/testsuite/libffi.closures/single_entry_structs1.c b/testsuite/libffi.closures/single_entry_structs1.c new file mode 100644 index 000000000..89d0d32eb --- /dev/null +++ b/testsuite/libffi.closures/single_entry_structs1.c @@ -0,0 +1,86 @@ +/* Area: ffi_call, closure_call + Purpose: Single argument structs have a different ABI in emscripten. + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + int a; +} A; + +static struct A A_fn(int b0, struct A b1) +{ + b1.a += b0; + return b1; +} + +static void +A_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + int b0; + struct A b1; + + b0 = *(int*)(args[0]); + b1 = *(struct A*)(args[1]); + + *(A*)resp = A_fn(b0, b1); +} + +int main (void) +{ + printf("123\n"); + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[2]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + int e_dbl = 12125; + struct A f_dbl = { 31625 }; + + struct A 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_sint; + cls_struct_fields[1] = NULL; + + dbl_arg_types[0] = &ffi_type_sint; + dbl_arg_types[1] = &cls_struct_type; + dbl_arg_types[2] = NULL; + + res_dbl = A_fn(e_dbl, f_dbl); + printf("0 res: %d\n", res_dbl.a); + /* { dg-output "0 res: 43750" } */ + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + + ffi_call(&cif, FFI_FN(A_fn), &res_dbl, args_dbl); + printf("1 res: %d \n", res_dbl.a); + /* { dg-output "\n1 res: 43750" } */ + CHECK( res_dbl.a == (e_dbl + f_dbl.a)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, A_gn, NULL, code) == FFI_OK); + + res_dbl = ((A(*)(int, A))(code))(e_dbl, f_dbl); + printf("2 res: %d \n", res_dbl.a); + /* { dg-output "\n2 res: 43750" } */ + CHECK( res_dbl.a == (e_dbl + f_dbl.a)); + + exit(0); +} diff --git a/testsuite/libffi.closures/single_entry_structs2.c b/testsuite/libffi.closures/single_entry_structs2.c new file mode 100644 index 000000000..ab6556bf4 --- /dev/null +++ b/testsuite/libffi.closures/single_entry_structs2.c @@ -0,0 +1,102 @@ +/* Area: ffi_call, closure_call + Purpose: Single argument structs have a different ABI in emscripten. + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + int a, b; +} A; + +typedef struct B { + struct A y; +} B; + +static struct B B_fn(int b0, struct B b1) +{ + b1.y.a += b0; + b1.y.b -= b0; + return b1; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + int b0; + struct B b1; + + b0 = *(int*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[2]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + int e_dbl = 12125; + struct B f_dbl = { { 31625, 16723 } }; + + struct B 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_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = &ffi_type_sint; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = NULL; + + + dbl_arg_types[0] = &ffi_type_sint; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + res_dbl = B_fn(e_dbl, f_dbl); + printf("0 res: %d %d\n", res_dbl.y.a, res_dbl.y.b); + /* { dg-output "0 res: 43750 4598" } */ + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + printf("1 res: %d %d\n", res_dbl.y.a, res_dbl.y.b); + /* { dg-output "\n1 res: 43750 4598" } */ + CHECK( res_dbl.y.a == (f_dbl.y.a + e_dbl)); + CHECK( res_dbl.y.b == (f_dbl.y.b - e_dbl)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(int, B))(code))(e_dbl, f_dbl); + printf("2 res: %d %d\n", res_dbl.y.a, res_dbl.y.b); + /* { dg-output "\n2 res: 43750 4598" } */ + CHECK( res_dbl.y.a == (f_dbl.y.a + e_dbl)); + CHECK( res_dbl.y.b == (f_dbl.y.b - e_dbl)); + + exit(0); +} diff --git a/testsuite/libffi.closures/single_entry_structs3.c b/testsuite/libffi.closures/single_entry_structs3.c new file mode 100644 index 000000000..eec8d72bd --- /dev/null +++ b/testsuite/libffi.closures/single_entry_structs3.c @@ -0,0 +1,101 @@ +/* Area: ffi_call, closure_call + Purpose: Single argument structs have a different ABI in emscripten. + Limitations: none. + PR: none. + Originator: */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + int a; +} A; + +typedef struct B { + struct A y; +} B; + +static struct B B_fn(int b0, struct B b1) +{ + b1.y.a += b0; + return b1; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + int b0; + struct B b1; + + b0 = *(int*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + printf("123\n"); + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[2]; + ffi_type* cls_struct_fields1[2]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + int e_dbl = 12125; + struct B f_dbl = { { 31625 } }; + + struct B 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_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_sint; + cls_struct_fields[1] = NULL; + + cls_struct_fields1[0] = &cls_struct_type; + cls_struct_fields1[1] = NULL; + + + dbl_arg_types[0] = &ffi_type_sint; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + res_dbl = B_fn(e_dbl, f_dbl); + printf("0 res: %f\n", res_dbl.y.a); + /* { dg-output "0 res: 43750" } */ + + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + printf("1 res: %d\n", res_dbl.y.a); + /* { dg-output "\n1 res: 43750" } */ + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(int, B))(code))(e_dbl, f_dbl); + printf("2 res: %d\n", res_dbl.y.a); + /* { dg-output "\n2 res: 43750" } */ + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + + exit(0); +} From 0a2cc2ec2893821f62b36b269da1dbc0442a5617 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 14:59:07 -0400 Subject: [PATCH 208/231] Add missing test cases to distribution --- testsuite/Makefile.am | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 8dc8d2eb2..1e4b35a34 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -13,7 +13,7 @@ libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc-tc.c \ libffi.call/float_va.c libffi.call/struct8.c libffi.call/pr1172638.c \ libffi.call/return_sc.c libffi.call/va_struct1.c \ libffi.call/align_stdcall.c libffi.call/struct9.c libffi.call/va_1.c \ -libffi.call/va_struct2.c libffi.call/return_fl2.c \ +libffi.call/va_2.c libffi.call/va_struct2.c libffi.call/return_fl2.c \ libffi.call/align_mixed.c libffi.call/ffitest.h libffi.call/struct4.c \ libffi.call/return_ldl.c libffi.call/float3.c libffi.call/return_sl.c \ libffi.call/return_dbl1.c libffi.call/err_bad_typedef.c \ @@ -101,6 +101,8 @@ libffi.closures/closure_fn3.c libffi.closures/cls_align_sint64.c \ libffi.closures/nested_struct1.c libffi.closures/unwindtest.cc \ libffi.closures/nested_struct5.c libffi.closures/cls_multi_ushort.c \ libffi.closures/nested_struct11.c \ +libffi.closures/nested_struct12.c \ +libffi.closures/nested_struct13.c \ libffi.closures/cls_multi_sshortchar.c \ libffi.closures/cls_align_longdouble.c \ libffi.closures/cls_dbls_struct.c \ @@ -118,4 +120,7 @@ libffi.closures/cls_double_va.c libffi.closures/cls_3byte2.c \ libffi.closures/cls_double.c libffi.closures/cls_7byte.c \ libffi.closures/closure_fn6.c libffi.closures/closure_fn1.c \ libffi.closures/cls_20byte.c libffi.closures/cls_18byte.c \ -libffi.closures/err_bad_abi.c +libffi.closures/err_bad_abi.c \ +libffi.closures/single_entry_structs1.c \ +libffi.closures/single_entry_structs2.c \ +libffi.closures/single_entry_structs3.c From 1ed0aa73806872f0c31dccf2c689c762239d3353 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 18:45:11 -0400 Subject: [PATCH 209/231] Fix warnings --- testsuite/libffi.closures/single_entry_structs1.c | 6 +++--- testsuite/libffi.closures/single_entry_structs3.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/libffi.closures/single_entry_structs1.c b/testsuite/libffi.closures/single_entry_structs1.c index 89d0d32eb..00c4e1744 100644 --- a/testsuite/libffi.closures/single_entry_structs1.c +++ b/testsuite/libffi.closures/single_entry_structs1.c @@ -38,7 +38,7 @@ int main (void) ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); void* args_dbl[3]; ffi_type* cls_struct_fields[2]; - ffi_type cls_struct_type, cls_struct_type1; + ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; int e_dbl = 12125; @@ -71,14 +71,14 @@ int main (void) ffi_call(&cif, FFI_FN(A_fn), &res_dbl, args_dbl); - printf("1 res: %d \n", res_dbl.a); + printf("1 res: %d\n", res_dbl.a); /* { dg-output "\n1 res: 43750" } */ CHECK( res_dbl.a == (e_dbl + f_dbl.a)); CHECK(ffi_prep_closure_loc(pcl, &cif, A_gn, NULL, code) == FFI_OK); res_dbl = ((A(*)(int, A))(code))(e_dbl, f_dbl); - printf("2 res: %d \n", res_dbl.a); + printf("2 res: %d\n", res_dbl.a); /* { dg-output "\n2 res: 43750" } */ CHECK( res_dbl.a == (e_dbl + f_dbl.a)); diff --git a/testsuite/libffi.closures/single_entry_structs3.c b/testsuite/libffi.closures/single_entry_structs3.c index eec8d72bd..4f619cbf7 100644 --- a/testsuite/libffi.closures/single_entry_structs3.c +++ b/testsuite/libffi.closures/single_entry_structs3.c @@ -73,7 +73,7 @@ int main (void) dbl_arg_types[2] = NULL; res_dbl = B_fn(e_dbl, f_dbl); - printf("0 res: %f\n", res_dbl.y.a); + printf("0 res: %d\n", res_dbl.y.a); /* { dg-output "0 res: 43750" } */ From c1d09bf08c2859abb40c476c57ae521d208f92a8 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 18:50:31 -0400 Subject: [PATCH 210/231] Update version to 3.4.0 --- README.md | 9 +++------ configure.ac | 2 +- doc/version.texi | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 183cb6418..fb02a2202 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,8 @@ Status ====== -[![Build Status](https://travis-ci.org/libffi/libffi.svg?branch=master)](https://travis-ci.org/libffi/libffi) -[![Build status](https://ci.appveyor.com/api/projects/status/8lko9vagbx4w2kxq?svg=true)](https://ci.appveyor.com/project/atgreen/libffi) - -libffi-3.4.0 was released on TBD. Check the libffi web page for -updates: . +libffi-3.4.0 was released on June 28, 2022. Check the libffi web page +for updates: . What is libffi? @@ -198,7 +195,7 @@ History See the git log for details at http://github.com/libffi/libffi. - 3.4 TBD + 3.4.0 Jun-28-22 Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. Add support for Kalray's KVX architecture. diff --git a/configure.ac b/configure.ac index 144129b98..842b08845 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.4.0-rc2], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.4.0], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index 7e681ca88..0b3886b0b 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ @set UPDATED 27 June 2021 @set UPDATED-MONTH June 2021 -@set EDITION 3.4.0-rc2 -@set VERSION 3.4.0-rc2 +@set EDITION 3.4.0 +@set VERSION 3.4.0 From 2bdc8e52efb78d939f23efb4f9c515355610bff5 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 19:50:29 -0400 Subject: [PATCH 211/231] Version 3.4.1 --- LICENSE | 2 +- README.md | 4 ++-- configure.ac | 2 +- doc/version.texi | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index 4f0b76251..e4034b09a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -libffi - Copyright (c) 1996-2020 Anthony Green, Red Hat, Inc and others. +libffi - Copyright (c) 1996-2021 Anthony Green, Red Hat, Inc and others. See source files for details. Permission is hereby granted, free of charge, to any person obtaining diff --git a/README.md b/README.md index fb02a2202..0d2641c3e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Status ====== -libffi-3.4.0 was released on June 28, 2022. Check the libffi web page +libffi-3.4.1 was released on June 28, 2021. Check the libffi web page for updates: . @@ -195,7 +195,7 @@ History See the git log for details at http://github.com/libffi/libffi. - 3.4.0 Jun-28-22 + 3.4.1 Jun-28-21 Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. Add support for Kalray's KVX architecture. diff --git a/configure.ac b/configure.ac index 842b08845..481faa726 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.4.0], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.4.1], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index 0b3886b0b..2dee51b53 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ @set UPDATED 27 June 2021 @set UPDATED-MONTH June 2021 -@set EDITION 3.4.0 -@set VERSION 3.4.0 +@set EDITION 3.4.1 +@set VERSION 3.4.1 From f9ea41683444ebe11cfa45b05223899764df28fb Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Mon, 28 Jun 2021 21:10:49 -0400 Subject: [PATCH 212/231] Update version to 3.4.2 --- README.md | 2 +- configure.ac | 2 +- doc/version.texi | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d2641c3e..b95bd74d8 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ History See the git log for details at http://github.com/libffi/libffi. - 3.4.1 Jun-28-21 + 3.4.2 Jun-28-21 Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. Add support for Kalray's KVX architecture. diff --git a/configure.ac b/configure.ac index 481faa726..70f6d2c2e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure AC_PREREQ(2.68) -AC_INIT([libffi], [3.4.1], [http://github.com/libffi/libffi/issues]) +AC_INIT([libffi], [3.4.2], [http://github.com/libffi/libffi/issues]) AC_CONFIG_HEADERS([fficonfig.h]) AC_CANONICAL_SYSTEM diff --git a/doc/version.texi b/doc/version.texi index 2dee51b53..f2b741e87 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ @set UPDATED 27 June 2021 @set UPDATED-MONTH June 2021 -@set EDITION 3.4.1 -@set VERSION 3.4.1 +@set EDITION 3.4.2 +@set VERSION 3.4.2 From d1eef904766dbd647de6c240a57dbc98d46e33dd Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 08:29:08 -0400 Subject: [PATCH 213/231] Migrate from travis-ci to github actions. --- {.travis => .ci}/ar-lib | 0 {.travis => .ci}/bfin-sim.exp | 0 .ci/build-cross-in-container.sh | 18 + {.travis => .ci}/build-in-container.sh | 10 +- {.travis => .ci}/build.sh | 9 +- {.travis => .ci}/compile | 0 {.travis => .ci}/install.sh | 6 +- {.travis => .ci}/m32r-sim.exp | 0 {.travis => .ci}/moxie-sim.exp | 0 .ci/msvs-detect | 1103 ++++++++++++++++++++++++ {.travis => .ci}/or1k-sim.exp | 0 {.travis => .ci}/powerpc-eabisim.exp | 0 {.travis => .ci}/site.exp | 8 +- {.travis => .ci}/wine-sim.exp | 0 .github/workflows/build.yml | 154 ++++ .gitignore | 2 +- .travis.yml | 83 -- .travis/build-cross-in-container.sh | 14 - 18 files changed, 1293 insertions(+), 114 deletions(-) rename {.travis => .ci}/ar-lib (100%) rename {.travis => .ci}/bfin-sim.exp (100%) create mode 100755 .ci/build-cross-in-container.sh rename {.travis => .ci}/build-in-container.sh (52%) rename {.travis => .ci}/build.sh (77%) rename {.travis => .ci}/compile (100%) rename {.travis => .ci}/install.sh (89%) rename {.travis => .ci}/m32r-sim.exp (100%) rename {.travis => .ci}/moxie-sim.exp (100%) create mode 100755 .ci/msvs-detect rename {.travis => .ci}/or1k-sim.exp (100%) rename {.travis => .ci}/powerpc-eabisim.exp (100%) rename {.travis => .ci}/site.exp (73%) rename {.travis => .ci}/wine-sim.exp (100%) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml delete mode 100755 .travis/build-cross-in-container.sh diff --git a/.travis/ar-lib b/.ci/ar-lib similarity index 100% rename from .travis/ar-lib rename to .ci/ar-lib diff --git a/.travis/bfin-sim.exp b/.ci/bfin-sim.exp similarity index 100% rename from .travis/bfin-sim.exp rename to .ci/bfin-sim.exp diff --git a/.ci/build-cross-in-container.sh b/.ci/build-cross-in-container.sh new file mode 100755 index 000000000..d2143e3fd --- /dev/null +++ b/.ci/build-cross-in-container.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -x + +cd /opt + +echo $PATH +export PATH=/usr/local/bin:$PATH +echo $PATH + +export DEJAGNU=$(pwd)/.ci/site.exp +echo $DEJAGNU +ls -l $DEJAGNU +pwd +find . +./configure --host=${HOST} || cat */config.log +make +make dist +BOARDSDIR=$(pwd)/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true diff --git a/.travis/build-in-container.sh b/.ci/build-in-container.sh similarity index 52% rename from .travis/build-in-container.sh rename to .ci/build-in-container.sh index 1a7fa76b8..a4124b036 100755 --- a/.travis/build-in-container.sh +++ b/.ci/build-in-container.sh @@ -1,12 +1,10 @@ #!/bin/bash - -cd /opt +set -x export QEMU_LD_PREFIX=/usr/${HOST} - +export DEJAGNU=/opt/.ci/site.exp +cd /opt ./configure ${HOST+--host=$HOST --disable-shared} make make dist -make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true - - +BOARDSDIR=/opt/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true diff --git a/.travis/build.sh b/.ci/build.sh similarity index 77% rename from .travis/build.sh rename to .ci/build.sh index ebd063ddc..a6389770e 100755 --- a/.travis/build.sh +++ b/.ci/build.sh @@ -35,7 +35,8 @@ function build_linux() ./configure ${HOST+--host=$HOST} ${CONFIGURE_OPTIONS} || cat */config.log make make dist - make check RUNTESTFLAGS="-a $RUNTESTFLAGS" + DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci runtest --version + DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci make check RUNTESTFLAGS="-a $RUNTESTFLAGS" ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) @@ -45,7 +46,7 @@ function build_linux() function build_foreign_linux() { - ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -v $(pwd):/opt ${SET_QEMU_CPU} -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" $2 bash -c /opt/.ci/build-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) @@ -55,7 +56,7 @@ function build_foreign_linux() function build_cross_linux() { - ${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh + ${DOCKER} run --rm -t -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/cross-ci-build-container:latest bash -c /opt/.ci/build-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) @@ -66,7 +67,7 @@ function build_cross_linux() function build_cross() { ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} - ${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh + ${DOCKER} run --rm -t -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e RUNNER_WORKSPACE=/opt -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.ci/build-cross-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) diff --git a/.travis/compile b/.ci/compile similarity index 100% rename from .travis/compile rename to .ci/compile diff --git a/.travis/install.sh b/.ci/install.sh similarity index 89% rename from .travis/install.sh rename to .ci/install.sh index 7e8723570..d3fa0e9c8 100755 --- a/.travis/install.sh +++ b/.ci/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -x -if [[ $TRAVIS_OS_NAME != 'linux' ]]; then +if [[ $RUNNER_OS != 'Linux' ]]; then brew update --verbose # brew update > brew-update.log 2>&1 # fix an issue with libtool on travis by reinstalling it @@ -48,11 +48,11 @@ else sudo apt-get install gcc-multilib g++-multilib; ;; moxie-elf) - echo 'deb https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list + echo 'deb [trusted=yes] https://repos.moxielogic.org:7114/MoxieLogic moxiedev main' | sudo tee -a /etc/apt/sources.list sudo apt-get clean # clear the cache sudo apt-get update ## -qq sudo apt-get update - sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim + sudo apt-get install -y --allow-unauthenticated moxielogic-moxie-elf-gcc moxielogic-moxie-elf-gcc-c++ moxielogic-moxie-elf-gcc-libstdc++ moxielogic-moxie-elf-gdb-sim texinfo sharutils texlive dejagnu ;; x86_64-w64-mingw32) sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 wine; diff --git a/.travis/m32r-sim.exp b/.ci/m32r-sim.exp similarity index 100% rename from .travis/m32r-sim.exp rename to .ci/m32r-sim.exp diff --git a/.travis/moxie-sim.exp b/.ci/moxie-sim.exp similarity index 100% rename from .travis/moxie-sim.exp rename to .ci/moxie-sim.exp diff --git a/.ci/msvs-detect b/.ci/msvs-detect new file mode 100755 index 000000000..601575c67 --- /dev/null +++ b/.ci/msvs-detect @@ -0,0 +1,1103 @@ +#!/usr/bin/env bash +# ################################################################################################ # +# MetaStack Solutions Ltd. # +# ################################################################################################ # +# Microsoft C Compiler Environment Detection Script # +# ################################################################################################ # +# Copyright (c) 2016, 2017, 2018, 2019, 2020 MetaStack Solutions Ltd. # +# ################################################################################################ # +# Author: David Allsopp # +# 16-Feb-2016 # +# ################################################################################################ # +# Redistribution and use in source and binary forms, with or without modification, are permitted # +# provided that the following two conditions are met: # +# 1. Redistributions of source code must retain the above copyright notice, this list of # +# conditions and the following disclaimer. # +# 2. Neither the name of MetaStack Solutions Ltd. nor the names of its contributors may be # +# used to endorse or promote products derived from this software without specific prior # +# written permission. # +# # +# This software is provided by the Copyright Holder 'as is' and any express or implied warranties # +# including, but not limited to, the implied warranties of merchantability and fitness for a # +# particular purpose are disclaimed. In no event shall the Copyright Holder be liable for any # +# direct, indirect, incidental, special, exemplary, or consequential damages (including, but not # +# limited to, procurement of substitute goods or services; loss of use, data, or profits; or # +# business interruption) however caused and on any theory of liability, whether in contract, # +# strict liability, or tort (including negligence or otherwise) arising in any way out of the use # +# of this software, even if advised of the possibility of such damage. # +# ################################################################################################ # + +VERSION=0.4.1 + +# debug [level=2] message +debug () +{ + if [[ -z ${2+x} ]] ; then + DEBUG_LEVEL=2 + else + DEBUG_LEVEL=$1 + shift + fi + + if [[ $DEBUG -ge $DEBUG_LEVEL ]] ; then + echo "$1">&2 + fi +} + +# warning message +warning () +{ + if [[ $DEBUG -gt 0 ]] ; then + echo "Warning: $1">&2 + fi +} + +# reg_string key value +# Retrieves a REG_SZ value from the registry (redirected on WOW64) +reg_string () +{ + reg query "$1" /v "$2" 2>/dev/null | tr -d '\r' | sed -ne "s/ *$2 *REG_SZ *//p" +} + +# reg64_string key value +# As reg_string, but without WOW64 redirection (i.e. guaranteed access to 64-bit registry) +reg64_string () +{ + $REG64 query "$1" /v "$2" 2>/dev/null | tr -d '\r' | sed -ne "s/ *$2 *REG_SZ *//p" +} + +# find_in list file +# Increments $RET if file does not exist in any of the directories in the *-separated list +find_in () +{ + debug 4 "Looking for $2 in $1" + if [[ -z $1 ]] ; then + STATUS=1 + else + IFS=* + STATUS=1 + for f in $1; do + if [[ -e "$f/$2" ]] ; then + STATUS=0 + break + fi + done + unset IFS + fi + if [[ $STATUS -eq 1 ]] ; then + debug 4 "$2 not found" + fi + ((RET+=STATUS)) +} + +# check_environment PATH INC LIB name arch +# By checking for the presence of various files, verifies that PATH, INC and LIB provide a complete +# compiler and indicates this in its return status. RET is assumed to be zero on entry. $ASSEMBLER +# will contain the name of assembler for this compiler series (ml.exe or ml64.exe). +# The following files are checked: +# cl.exe PATH Microsoft C compiler +# kernel32.lib LIB Implies Windows SDK present +# link.exe PATH Microsoft Linker +# ml[64].exe PATH Microsoft Assembler (ml.exe or ml64.exe) +# msvcrt.lib LIB Implies C Runtime Libraries present +# mt.exe PATH Microsoft Manifest Tool +# oldnames.lib LIB Implies C Runtime Libraries present +# rc.exe PATH Microsoft Resource Compiler (implies tools present) +# stdlib.h INC Implies Microsoft C Runtime Libraries present +# windows.h INC Implies Windows SDK present +# oldnames.lib is included, because certain SDKs and older versions don't correctly install the +# entire runtime if only some options (e.g. Dynamic Runtime and not Static) are selected. +check_environment () +{ + debug 4 "Checking $4 ($5)" + for tool in cl rc link ; do + find_in "$1" $tool.exe + done + + if [[ $RET -gt 0 ]] ; then + warning "Microsoft C Compiler tools not all found - $4 ($5) excluded" + return 1 + fi + + RET=0 + find_in "$2" windows.h + find_in "$3" kernel32.lib + if [[ $RET -gt 0 ]] ; then + warning "Windows SDK not all found - $4 ($5) excluded" + return 1 + fi + + RET=0 + find_in "$2" stdlib.h + find_in "$3" msvcrt.lib + find_in "$3" oldnames.lib + if [[ $RET -gt 0 ]] ; then + warning "Microsoft C runtime library not all found - $4 ($5) excluded" + return 1 + fi + + ASSEMBLER=ml${5#x} + ASSEMBLER=${ASSEMBLER%86}.exe + if [[ $ML_REQUIRED -eq 1 ]] ; then + RET=0 + find_in "$1" $ASSEMBLER + if [[ $RET -gt 0 ]] ; then + warning "Microsoft Assembler ($ASSEMBLER) not found - $4 ($5)" + return 1 + fi + fi + + if [[ $MT_REQUIRED -eq 1 ]] ; then + RET=0 + find_in "$1" mt.exe + if [[ $RET -gt 0 ]] ; then + warning "Microsoft Manifest Tool not found - $4 ($5)" + return 1 + fi + fi + + return 0 +} + +# output VAR value arch +# Outputs a command for setting VAR to value based on $OUTPUT. If $ENV_ARCH is arch, then an empty +# value (i.e. no change) is output. +output () +{ + if [[ $3 = $ENV_ARCH ]] ; then + VALUE= + else + VALUE=$2 + fi + case "$OUTPUT" in + 0) + echo "$1='${VALUE//\'/\'\"\'\"\'}'";; + 1) + VALUE=${VALUE//#/\\\#} + echo "$1=${VALUE//\$/\$\$}";; + esac +} + +# DEBUG Debugging level +# MODE Operation mode +# 0 - Normal +# 1 - --all +# 2 - --help +# 3 - --version +# OUTPUT --output option +# 0 - =shell +# 1 - =make +# MT_REQUIRED --with-mt +# ML_REQUIRED --with-assembler +# TARGET_ARCH Normalised --arch (x86, x64 or blank for both) +# LEFT_ARCH \ If $TARGET_ARCH is blank, these will be x86 and x64 respectively, otherwise they +# RIGHT_ARCH / equal $TARGET_ARCH +# SCAN_ENV Controls from parsing whether the environment should be queried for a compiler +DEBUG=0 +MODE=0 +OUTPUT=0 +MT_REQUIRED=0 +ML_REQUIRED=0 +TARGET_ARCH= +SCAN_ENV=0 + +# Various PATH messing around means it's sensible to know where tools are now +WHICH=$(which which) + +if [[ $(uname --operating-system 2>/dev/null) = "Msys" ]] ; then + # Prevent MSYS from translating command line switches to paths + SWITCH_PREFIX='//' +else + SWITCH_PREFIX='/' +fi + +# Parse command-line. At the moment, the short option which usefully combines with anything is -d, +# so for the time being, combining short options is not permitted, as the loop becomes even less +# clear with getopts. GNU getopt isn't installed by default on Cygwin... +if [[ $@ != "" ]] ; then + while true ; do + case "$1" in + # Mode settings ($MODE) + -a|--all) + MODE=1 + shift 1;; + -h|--help) + MODE=2 + shift;; + -v|--version) + MODE=3 + shift;; + + # Simple flags ($MT_REQUIRED and $ML_REQUIRED) + --with-mt) + MT_REQUIRED=1 + shift;; + --with-assembler) + ML_REQUIRED=1 + shift;; + + # -o, --output ($OUTPUT) + -o|--output) + case "$2" in + shell) + ;; + make) + OUTPUT=1;; + *) + echo "$0: unrecognised option for $1: '$2'">&2 + exit 2;; + esac + shift 2;; + -oshell|--output=shell) + shift;; + -omake|--output=make) + OUTPUT=1 + shift;; + -o*) + echo "$0: unrecognised option for -o: '${1#-o}'">&2 + exit 2;; + --output=*) + echo "$0: unrecognised option for --output: '${1#--output=}'">&2 + exit 2;; + + # -x, --arch ($TARGET_ARCH) + -x|--arch) + case "$2" in + 86|x86) + TARGET_ARCH=x86;; + 64|x64) + TARGET_ARCH=x64;; + *) + echo "$0: unrecognised option for $1: '$2'">&2 + exit 2 + esac + shift 2;; + -x86|-xx86|--arch=x86|--arch=86) + TARGET_ARCH=x86 + shift;; + -x64|-xx64|--arch=x64|--arch=64) + TARGET_ARCH=x64 + shift;; + -x*) + echo "$0: unrecognised option for -x: '${1#-x}'">&2 + exit 2;; + --arch=*) + echo "$0: unrecognised option for --arch: '${1#--arch}'">&2 + exit 2;; + + # -d, --debug ($DEBUG) + -d*) + DEBUG=${1#-d} + if [[ -z $DEBUG ]] ; then + DEBUG=1 + fi + shift;; + --debug=*) + DEBUG=${1#*=} + shift;; + --debug) + DEBUG=1 + shift;; + + # End of option marker + --) + shift + break;; + + # Invalid options + --*) + echo "$0: unrecognised option: '${1%%=*}'">&2 + exit 2;; + -*) + echo "$0: unrecognised option: '${1:1:1}'">&2 + exit 2;; + + # MSVS_PREFERENCE (without end-of-option marker) + *) + break;; + esac + done + + if [[ -n ${1+x} ]] ; then + if [[ $MODE -eq 1 ]] ; then + echo "$0: cannot specify MSVS_PREFERENCE and --all">&2 + exit 2 + else + MSVS_PREFERENCE="$@" + fi + fi +fi + +# Options sanitising +if [[ $MODE -eq 1 ]] ; then + if [[ -n $TARGET_ARCH ]] ; then + echo "$0: --all and --arch are mutually exclusive">&2 + exit 2 + fi + MSVS_PREFERENCE= + SCAN_ENV=1 +elif [[ -z ${MSVS_PREFERENCE+x} ]] ; then + MSVS_PREFERENCE='@;VS16.*;VS15.*;VS14.0;VS12.0;VS11.0;10.0;9.0;8.0;7.1;7.0' +fi + +MSVS_PREFERENCE=${MSVS_PREFERENCE//;/ } + +if [[ -z $TARGET_ARCH ]] ; then + LEFT_ARCH=x86 + RIGHT_ARCH=x64 +else + LEFT_ARCH=$TARGET_ARCH + RIGHT_ARCH=$TARGET_ARCH +fi + +# Command line parsing complete (MSVS_PREFERENCE pending) + +NAME="Microsoft C Compiler Environment Detection Script" +case $MODE in + 2) + echo "$NAME" + echo "Queries the environment and registry to locate Visual Studio / Windows SDK" + echo "installations and uses their initialisation scripts (SetEnv.cmd, vcvarsall.bat," + echo "etc.) to determine INCLUDE, LIB and PATH alterations." + echo + echo "Usage:" + echo " $0 [OPTIONS] [--] [MSVS_PREFERENCE]" + echo + echo "Options:" + echo " -a, --all Display all available compiler packages" + echo " -x, --arch=ARCH Only consider packages for ARCH (x86 or x64). Default is" + echo " to return packages containing both architectures" + echo " -d, --debug[=LEVEL] Set debug messages level" + echo " -h, --help Display this help screen" + echo " -o, --output=OUTPUT Set final output. Default is shell. Valid values:" + echo " shell - shell assignments, for use with eval" + echo " make - make assignments, for inclusion in a Makefile" + echo " -v, --version Display the version" + echo " --with-mt Only consider packages including the Manifest Tool" + echo " --with-assembler Only consider packages including an assembler" + echo + echo "If MSVS_PREFERENCE is not given, then the environment variable MSVS_PREFERENCE" + echo "is read. MSVS_PREFERENCE is a semicolon separated list of preferred versions." + echo "Three kinds of version notation are supported:" + echo " 1. @ - which refers to the C compiler found in PATH (if it can be identified)" + echo " (this allows the C compiler corresponding to the opposite architecture to" + echo " be selected, if possible)." + echo " 2. mm.n - which refers to a Visual Studio version (e.g. 14.0, 7.1) but which" + echo " also allows an SDK to provide the compiler (e.g. Windows SDK 7.1 provides" + echo " 10.0). Visual Studio packages are always preferred ahead of SDKs." + echo " 3. SPEC - an actual package specification. Visual Studio packages are VSmm.n" + echo " (e.g. VS14.0, VS7.1) and SDK packages are SDKm.n (e.g. SDK7.1)." + echo " Any Visual Studio 2017 update can be selected with VS15.*" + echo "The default behaviour is to match the environment compiler followed by the most" + echo "recent version of the compiler." + exit 0;; + 3) + echo "$NAME" + echo "Version $VERSION" + exit 0;; +esac + +# Known compiler packages. Visual Studio .NET 2002 onwards. Detection is in place for Visual Studio +# 2005 Express, but because it doesn't include a Windows SDK, it can only ever be detected if the +# script has been launched from within a Platform SDK command prompt (this provides the Windows +# Headers and Libraries which allows this script to detect the rest). +# Each element is either a Visual Studio or SDK package and the value is the syntax for a bash +# associative array to be eval'd. Each of these contains the following properties: +# NAME - the friendly name of the package +# ENV - (VS only) the version-specific portion of the VSCOMNTOOLS environment variable +# VERSION - (VS only) version number of the package +# ARCH - Lists the architectures available in this version +# ARCH_SWITCHES - The script is assumed to accept x86 and x64 to indicate architecture. This key +# contains another eval'd associative array allowing alternate values to be given +# SETENV_RELEASE - (SDK only) script switch necessary to select release than debugging versions +# EXPRESS - (VS only) the prefix to the registry key to detect the Express edition +# EXPRESS_ARCH - (VS only) overrides ARCH if Express edition is detected +# EXPRESS_ARCH_SWITCHES - (VS only) overrides ARCH_SWITCHES if Express edition is detected +# VC_VER - (SDK only) specifies the version of the C Compilers included in the SDK (SDK +# equivalent of the VERSION key) +# REG_KEY - (SDK only) registry key to open to identify this package installation +# REG_VALUE - (SDK only) registry value to query to identify this package installation +# VSWHERE - (VS 2017+) is 1 if the compiler can only be detected using vswhere +# For a while, Windows SDKs followed a standard pattern which is stored in the SDK element and +# copied to the appropriate version. SDKs after 7.1 do not include compilers, and so are not +# captured (as of Visual Studio 2015, the Windows SDK is official part of Visual Studio). +declare -A COMPILERS +SDK52_KEY='HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3' +COMPILERS=( + ["VS7.0"]='( + ["NAME"]="Visual Studio .NET 2002" + ["ENV"]="" + ["VERSION"]="7.0" + ["ARCH"]="x86")' + ["VS7.1"]='( + ["NAME"]="Visual Studio .NET 2003" + ["ENV"]="71" + ["VERSION"]="7.1" + ["ARCH"]="x86")' + ["VS8.0"]='( + ["NAME"]="Visual Studio 2005" + ["ENV"]="80" + ["VERSION"]="8.0" + ["EXPRESS"]="VC" + ["ARCH"]="x86 x64" + ["EXPRESS_ARCH"]="x86")' + ["VS9.0"]='( + ["NAME"]="Visual Studio 2008" + ["ENV"]="90" + ["VERSION"]="9.0" + ["EXPRESS"]="VC" + ["ARCH"]="x86 x64" + ["EXPRESS_ARCH"]="x86")' + ["VS10.0"]='( + ["NAME"]="Visual Studio 2010" + ["ENV"]="100" + ["VERSION"]="10.0" + ["EXPRESS"]="VC" + ["ARCH"]="x86 x64" + ["EXPRESS_ARCH"]="x86")' + ["VS11.0"]='( + ["NAME"]="Visual Studio 2012" + ["ENV"]="110" + ["VERSION"]="11.0" + ["EXPRESS"]="WD" + ["ARCH"]="x86 x64" + ["EXPRESS_ARCH_SWITCHES"]="([\"x64\"]=\"x86_amd64\")")' + ["VS12.0"]='( + ["NAME"]="Visual Studio 2013" + ["ENV"]="120" + ["VERSION"]="12.0" + ["EXPRESS"]="WD" + ["ARCH"]="x86 x64" + ["EXPRESS_ARCH_SWITCHES"]="([\"x64\"]=\"x86_amd64\")")' + ["VS14.0"]='( + ["NAME"]="Visual Studio 2015" + ["ENV"]="140" + ["VERSION"]="14.0" + ["ARCH"]="x86 x64")' + ["VS15.*"]='( + ["NAME"]="Visual Studio 2017" + ["VSWHERE"]="1")' + ["VS16.*"]='( + ["NAME"]="Visual Studio 2019" + ["VSWHERE"]="1")' + ["SDK5.2"]='( + ["NAME"]="Windows Server 2003 SP1 SDK" + ["VC_VER"]="8.0" + ["REG_KEY"]="$SDK52_KEY" + ["REG_VALUE"]="Install Dir" + ["SETENV_RELEASE"]="/RETAIL" + ["ARCH"]="x64" + ["ARCH_SWITCHES"]="([\"x64\"]=\"/X64\")")' + ["SDK"]='( + ["NAME"]="Generalised Windows SDK" + ["SETENV_RELEASE"]="/Release" + ["ARCH"]="x86 x64" + ["ARCH_SWITCHES"]="([\"x86\"]=\"/x86\" [\"x64\"]=\"/x64\")")' + ["SDK6.1"]='( + ["NAME"]="Windows Server 2008 with .NET 3.5 SDK" + ["VC_VER"]="9.0")' + ["SDK7.0"]='( + ["NAME"]="Windows 7 with .NET 3.5 SP1 SDK" + ["VC_VER"]="9.0")' + ["SDK7.1"]='( + ["NAME"]="Windows 7 with .NET 4 SDK" + ["VC_VER"]="10.0")' +) + +# FOUND is ultimately an associative array containing installed compiler packages. It's +# hijacked here as part of MSVS_PREFERENCE validation. +# Ultimately, it contains a copy of the value from COMPILERS with the following extra keys: +# IS_EXPRESS - (VS only) indicates whether the Express edition was located +# SETENV - (SDK only) the full location of the SetEnv.cmd script +# ASSEMBLER - the name of the assembler (ml or ml64) +# MSVS_PATH \ +# MSVS_INC > prefix values for PATH, INCLUDE and LIB determined by running the scripts. +# MSVS_LIB / +declare -A FOUND + +# Check that MSVS_PREFERENCE is valid and contains no repetitions. +for v in $MSVS_PREFERENCE ; do + if [[ -n ${FOUND[$v]+x} ]] ; then + echo "$0: corrupt MSVS_PREFERENCE: repeated '$v'">&2 + exit 2 + fi + if [[ $v != "@" ]] ; then + if [[ -z ${COMPILERS[$v]+x} && -z ${COMPILERS["VS$v"]+x} && -z ${COMPILERS[${v%.*}.*]+x} ]] ; then + echo "$0: corrupt MSVS_PREFERENCE: unknown compiler '$v'">&2 + exit 2 + fi + else + SCAN_ENV=1 + fi + FOUND["$v"]="" +done + +# Reset FOUND for later use. +FOUND=() + +# Scan the environment for a C compiler, and check that it's valid. Throughout the rest of the +# script, it is assumed that if ENV_ARCH is set then there is a valid environment compiler. +if [[ $SCAN_ENV -eq 1 ]] ; then + if "$WHICH" cl >/dev/null 2>&1 ; then + # Determine its architecture from the Microsoft Logo line. + ENV_ARCH=$(cl 2>&1 | head -1 | tr -d '\r') + case "${ENV_ARCH#* for }" in + x64|AMD64) + ENV_ARCH=x64;; + 80x86|x86) + ENV_ARCH=x86;; + *) + echo "Unable to identify C compiler architecture from '${ENV_ARCH#* for }'">&2 + echo "Environment C compiler discarded">&2 + unset ENV_ARCH;; + esac + + # Environment variable names are a bit of a nightmare on Windows - they are actually case + # sensitive (at the kernel level) but not at the user level! To compound the misery is that SDKs + # use Include and Lib where vcvars32 tends to use INCLUDE and LIB. Windows versions also contain + # a mix of Path and PATH, but fortunately Cygwin normalises that to PATH for us! For this + # reason, use env to determine the actual case of the LIB and INCLUDE variables. + if [[ -n ${ENV_ARCH+x} ]] ; then + RET=0 + ENV_INC=$(env | sed -ne 's/^\(INCLUDE\)=.*/\1/pi') + ENV_LIB=$(env | sed -ne 's/^\(LIB\)=.*/\1/pi') + if [[ -z $ENV_INC || -z $ENV_LIB ]] ; then + warning "Microsoft C Compiler Include and/or Lib not set - Environment C compiler ($ENV_ARCH) excluded" + unset ENV_ARCH + else + if check_environment "${PATH//:/*}" \ + "${!ENV_INC//;/*}" \ + "${!ENV_LIB//;/*}" \ + "Environment C compiler" \ + "$ENV_ARCH" ; then + ENV_CL=$("$WHICH" cl) + ENV_cl=${ENV_CL,,} + ENV_cl=${ENV_cl/bin\/*_/bin\/} + debug "Environment appears to include a compiler at $ENV_CL" + if [[ -n $TARGET_ARCH && $TARGET_ARCH != $ENV_ARCH ]] ; then + debug "But architecture doesn't match required value" + unset ENV_ARCH + fi + else + unset ENV_ARCH + fi + fi + fi + fi +fi + +# Even if launched from a 64-bit Command Prompt, Cygwin is usually 32-bit and so the scripts +# executed will inherit that fact. This is a problem when querying the registry, but fortunately +# WOW64 provides a mechanism to break out of the 32-bit environment by mapping $WINDIR/sysnative to +# the real 64-bit programs. +# Thus: +# MS_ROOT is the 32-bit Microsoft Registry key (all Visual Studio keys are located there) +# REG64 is the processor native version of the reg utility (allowing 64-bit keys to be read for +# the SDKs) +if [[ -n ${PROCESSOR_ARCHITEW6432+x} ]] ; then + debug "WOW64 detected" + MS_ROOT='HKLM\SOFTWARE\Microsoft' + REG64=$WINDIR/sysnative/reg +else + MS_ROOT='HKLM\SOFTWARE\Wow6432Node\Microsoft' + REG64=reg +fi + +# COMPILER contains each eval'd element from COMPILERS +declare -A COMPILER + +# Scan the registry for compiler package (vswhere is later) +for i in "${!COMPILERS[@]}" ; do + eval COMPILER=${COMPILERS[$i]} + + if [[ -n ${COMPILER["ENV"]+x} ]] ; then + # Visual Studio package - test for its environment variable + ENV=VS${COMPILER["ENV"]}COMNTOOLS + if [[ -n ${!ENV+x} ]] ; then + debug "$ENV is a candidate" + TEST_PATH=${!ENV%\"} + TEST_PATH=$(cygpath -u -f - <<< ${TEST_PATH#\"}) + if [[ -e $TEST_PATH/vsvars32.bat ]] ; then + debug "Directory pointed to by $ENV contains vsvars32.bat" + EXPRESS=0 + # Check for the primary Visual Studio registry value indicating installation + INSTALL_DIR=$(reg_string "$MS_ROOT\\VisualStudio\\${COMPILER["VERSION"]}" InstallDir) + if [[ -z $INSTALL_DIR ]] ; then + if [[ -n ${COMPILER["EXPRESS"]+x} ]] ; then + TEST_KEY="$MS_ROOT\\${COMPILER["EXPRESS"]}Express\\${COMPILER["VERSION"]}" + INSTALL_DIR=$(reg_string "$TEST_KEY" InstallDir) + # Exception for Visual Studio 2005 Express, which doesn't set the registry correctly, so + # set INSTALL_DIR to a fake value to pass the next test. + if [[ ${COMPILER["VERSION"]} = "8.0" ]] ; then + INSTALL_DIR=$(cygpath -w "$TEST_PATH") + EXPRESS=1 + else + if [[ -z $INSTALL_DIR ]] ; then + warning "vsvars32.bat found, but registry value not located (Exp or Pro)" + else + EXPRESS=1 + fi + fi + else + warning "vsvars32.bat found, but registry value not located" + fi + fi + + if [[ -n $INSTALL_DIR ]] ; then + if [[ ${TEST_PATH%/} = $(cygpath -u "$INSTALL_DIR\\..\\Tools") ]] ; then + RESULT=${COMPILERS[$i]%)} + DISPLAY=${COMPILER["NAME"]} + if [[ $EXPRESS -eq 1 ]] ; then + DISPLAY="$DISPLAY Express" + fi + FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"IS_EXPRESS\"]=\"$EXPRESS\")") + debug "${COMPILER["NAME"]} accepted for further detection" + else + warning "$ENV doesn't agree with registry" + fi + else + warning "vsvars32.bat found, but registry settings not found" + fi + else + warning "$ENV set, but vsvars32.bat not found" + fi + fi + elif [[ -n ${COMPILER["REG_KEY"]+x} ]] ; then + # SDK with explicit registry detection value + INSTALL_DIR=$(reg64_string "${COMPILER["REG_KEY"]}" "${COMPILER["REG_VALUE"]}") + if [[ -n $INSTALL_DIR ]] ; then + TEST_PATH=$(cygpath -u "$INSTALL_DIR") + if [[ -e $TEST_PATH/SetEnv.cmd ]] ; then + RESULT=${COMPILERS[$i]%)} + FOUND+=(["$i"]="$RESULT [\"DISPLAY\"]=\"${COMPILER["NAME"]}\" [\"SETENV\"]=\"$INSTALL_DIR\\SetEnv.cmd\")") + debug "${COMPILER["NAME"]} accepted for further detection" + else + warning "Registry set for Windows Server 2003 SDK, but SetEnv.cmd not found" + fi + fi + fi +done + +# Now enumerate installed SDKs for v6.0+ +SDK_ROOT='HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows' +for i in $(reg query "$SDK_ROOT" 2>/dev/null | tr -d '\r' | sed -ne '/Windows\\v/s/.*\\//p') ; do + debug "Analysing SDK key $SDK_ROOT\\$i" + INSTALL_DIR=$(reg_string "$SDK_ROOT\\$i" InstallationFolder) + if [[ -n $INSTALL_DIR ]] ; then + TEST_PATH=$(cygpath -u "$INSTALL_DIR") + if [[ -e $TEST_PATH/Bin/SetEnv.cmd ]] ; then + if [[ -z ${COMPILERS["SDK${i#v}"]+x} ]] ; then + warning "SDK $i is not known to this script - assuming compatibility" + DISPLAY="Windows SDK $i" + else + eval COMPILER=${COMPILERS["SDK${i#v}"]} + DISPLAY=${COMPILER['NAME']} + fi + RESULT=${COMPILERS['SDK']%)} + FOUND+=(["SDK${i/v/}"]="$RESULT [\"DISPLAY\"]=\"$DISPLAY\" [\"SETENV\"]=\"$INSTALL_DIR\\Bin\\SetEnv.cmd\")") + else + if [[ -n ${COMPILERS["SDK${i#v}"]+x} ]] ; then + warning "Registry set for Windows SDK $i, but SetEnv.cmd not found" + fi + fi + else + warning "Registry key for Windows SDK $i doesn't contain expected InstallationFolder value" + fi +done + +# Now enumerate Visual Studio 2017+ instances +VSWHERE=$(dirname $(realpath $0))/vswhere.exe +if [[ ! -x $VSWHERE ]] ; then + VSWHERE="$(printenv 'ProgramFiles(x86)')\\Microsoft Visual Studio\\Installer\\vswhere.exe" + VSWHERE=$(echo $VSWHERE| cygpath -f -) +fi +if [[ -x $VSWHERE ]] ; then + debug "$VSWHERE found" + while IFS= read -r line; do + case ${line%: *} in + instanceId) + INSTANCE=${line#*: };; + installationPath) + INSTANCE_PATH=${line#*: };; + installationVersion) + INSTANCE_VER=${line#*: } + INSTANCE_VER=${INSTANCE_VER%.*} + INSTANCE_VER=${INSTANCE_VER%.*};; + displayName) + INSTANCE_NAME=${line#*: } + debug "Looking at $INSTANCE in $INSTANCE_PATH ($INSTANCE_VER $INSTANCE_NAME)" + if [[ -e "$(echo $INSTANCE_PATH| cygpath -f -)/VC/Auxiliary/Build/vcvarsall.bat" ]] ; then + debug "vcvarsall.bat found" + FOUND+=(["VS$INSTANCE_VER"]="([\"DISPLAY\"]=\"$INSTANCE_NAME\" [\"ARCH\"]=\"x86 x64\" [\"SETENV\"]=\"$INSTANCE_PATH\\VC\\Auxiliary\\Build\\vcvarsall.bat\" [\"SETENV_RELEASE\"]=\"\")") + else + warning "vcvarsall.bat not found for $INSTANCE" + fi;; + esac + done < <("$VSWHERE" -all -nologo | tr -d '\r') +fi + +if [[ $DEBUG -gt 1 ]] ; then + for i in "${!FOUND[@]}" ; do + echo "Inspect $i">&2 + done +fi + +# Basic scanning is complete, now interrogate the packages which seem to be installed and ensure +# that they pass the check_environment tests. + +# CANDIDATES is a hash table of the keys of FOUND. The result of the next piece of processing is to +# derive two arrays PREFERENCE and TEST. TEST will contain a list of the keys of FOUND in the order +# in which they should be evaluated. PREFERENCE contains a parsed version of MSVS_PREFERENCE but +# filtered on the basis of the compiler packages already identified. The current "hoped for" +# preference is stored in $pref (the index into PREFERENCE) and $PREF (which is +# ${PREFERENCE[$pref]}). These two arrays together allow testing to complete quickly if the desired +# version is found (note that often this won't be possible as the @ environment option requires all +# packages to be tested in order to be sure that the environment compiler is not ambiguous). +declare -A CANDIDATES +for i in "${!FOUND[@]}" ; do + CANDIDATES[$i]=""; +done + +# For --all, act as though MSVS_PREFERENCE were "@" because this causes all packages to be tested. +if [[ $MODE -eq 1 ]] ; then + PREFER_ENV=1 + PREFERENCE=("@") +else + PREFER_ENV=0 + PREFERENCE=() +fi + +TEST=() +for i in $MSVS_PREFERENCE ; do + if [[ $i = "@" ]] ; then + if [[ -n ${ENV_ARCH+x} ]] ; then + PREFERENCE+=("@") + PREFER_ENV=1 + else + debug "Preference @ ignored since no environment compiler selected" + fi + else + if [[ -n ${COMPILERS[$i]+x} || -n ${COMPILERS[${i%.*}.*]+x} ]] ; then + if [[ -n ${CANDIDATES[$i]+x} ]] ; then + unset CANDIDATES[$i] + TEST+=($i) + PREFERENCE+=($i) + elif [[ ${i#*.} = "*" ]] ; then + INSTANCES= + for j in "${!CANDIDATES[@]}" ; do + if [[ "${j%.*}.*" = $i ]] ; then + unset CANDIDATES[$j] + INSTANCES="$INSTANCES $j" + fi + done + INSTANCES="$(sort -r <<< "${INSTANCES// /$'\n'}")" + eval TEST+=($INSTANCES) + eval PREFERENCE+=($INSTANCES) + fi + else + if [[ -n ${CANDIDATES["VS$i"]+x} ]] ; then + unset CANDIDATES["VS$i"] + TEST+=("VS$i") + PREFERENCE+=("VS$i") + fi + SDKS= + for j in "${!COMPILERS[@]}" ; do + eval COMPILER=${COMPILERS[$j]} + if [[ -n ${COMPILER["VC_VER"]+x} ]] ; then + if [[ $i = ${COMPILER["VC_VER"]} && -n ${CANDIDATES[$j]+x} ]] ; then + unset CANDIDATES[$j] + SDKS="$j $SDKS" + fi + fi + done + SDKS=${SDKS% } + SDKS="$(sort -r <<< "${SDKS// /$'\n'}")" + SDKS=${SDKS//$'\n'/ } + eval TEST+=($SDKS) + eval PREFERENCE+=($SDKS) + fi + fi +done + +# If MSVS_PREFERENCE includes @, add any remaining items from CANDIDATES to TEST, otherwise remove +# them from FOUND so that they don't accidentally get reported on later. +for i in "${!CANDIDATES[@]}" ; do + if [[ $PREFER_ENV -eq 1 ]] ; then + TEST+=($i) + else + unset FOUND[$i] + fi +done + +# Initialise pref and PREF to ${PREFERENCE[0]} +pref=0 +PREF=${PREFERENCE[0]} + +if [[ $DEBUG -gt 1 ]] ; then + for i in "${!TEST[@]}" ; do + echo "Test ${TEST[$i]}">&2 + done +fi + + +# Now run each compiler's environment script and then test whether it is suitable. During this loop, +# attempt to identify the environment C compiler (if one was found). The environment C compiler is +# strongly identified if the full location of cl matches the one in PATH and both LIB and INCLUDE +# contain the strings returned by the script in an otherwise empty environment (if one or both of +# the LIB and INCLUDE variables do not contain the string returned, then the compiler is weakly +# identified). If the environment compiler is strongly identified by more than one package, then it +# is not identified at all; if it is strongly identified by no packages but weakly identified by +# exactly 1, then we grudgingly accept that that's probably the one. +ENV_COMPILER= +WEAK_ENV= + +# ARCHINFO contains the appropriate ARCH_SWITCHES associative array for each compiler. +declare -A ARCHINFO + +for i in "${TEST[@]}" ; do + CURRENT=${FOUND[$i]} + eval COMPILER=$CURRENT + # At the end of this process, the keys of FOUND will be augmented with the architecture found in + # each case (so if "VS14.0" was in FOUND from the scan and both the x86 and x64 compilers are + # valid, then at the end of this loop FOUND will contain "VS14.0-x86" and "VS14.0-x64"). + unset FOUND[$i] + + if [[ ${COMPILER["IS_EXPRESS"]}0 -gt 0 && -n ${COMPILER["EXPRESS_ARCH_SWITCHES"]+x} ]] ; then + eval ARCHINFO=${COMPILER["EXPRESS_ARCH_SWITCHES"]} + elif [[ -n ${COMPILER["ARCH_SWITCHES"]+x} ]] ; then + eval ARCHINFO=${COMPILER["ARCH_SWITCHES"]} + else + ARCHINFO=() + fi + + # Determine the script to be executed and any non-architecture specific switches needed. + # $ENV is will contain the value of the environment variable for the compiler (empty for an SDK) + # which is required for Visual Studio 7.x shim later. + if [[ -n ${COMPILER["ENV"]+x} ]] ; then + ENV=VS${COMPILER["ENV"]}COMNTOOLS + ENV=${!ENV%\"} + ENV=${ENV#\"} + if [[ ${COMPILER["ENV"]}0 -ge 800 ]] ; then + SCRIPT="$(cygpath -d -f - <<< $ENV)\\..\\..\\VC\\vcvarsall.bat" + SCRIPT_SWITCHES= + else + SCRIPT="$(cygpath -d -f - <<< $ENV)\\vsvars32.bat" + SCRIPT_SWITCHES= + fi + else + ENV= + SCRIPT=${COMPILER["SETENV"]} + SCRIPT_SWITCHES=${COMPILER["SETENV_RELEASE"]} + fi + # For reasons of escaping, the script is executed using its basename so the directory needs + # prepending to PATH. + DIR=$(dirname "$SCRIPT" | cygpath -u -f -) + + if [[ ${COMPILER["IS_EXPRESS"]} -gt 0 && -n ${COMPILER["EXPRESS_ARCH"]+x} ]] ; then + ARCHS=${COMPILER["EXPRESS_ARCH"]} + else + ARCHS=${COMPILER["ARCH"]} + fi + + for arch in $ARCHS ; do + # Determine the command line switch for this architecture + if [[ -n ${ARCHINFO[$arch]+x} ]] ; then + ARCH_SWITCHES=${ARCHINFO[$arch]} + else + ARCH_SWITCHES=$arch + fi + + # Run the script in order to determine changes made to PATH, INCLUDE and LIB. These scripts + # always prepend changes to the environment variables. + MSVS_PATH= + MSVS_LIB= + MSVS_INC= + + COMMAND='%EXEC_SCRIPT% && echo XMARKER && echo !PATH! && echo !LIB! && echo !INCLUDE!' + + # Note that EXEC_SCRIPT must have ARCH_SWITCHES first for older Platform SDKs (newer ones parse + # arguments properly) + if [[ $DEBUG -gt 3 ]] ; then + printf "Scanning %s... " "$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES">&2 + fi + num=0 + while IFS= read -r line; do + case $num in + 0) + MSVS_PATH=${line%% };; + 1) + MSVS_LIB=${line%% };; + 2) + MSVS_INC=${line%% };; + esac + ((num++)) + done < <(INCLUDE='' LIB='' PATH="?msvs-detect?:$DIR:$PATH" ORIGINALPATH='' \ + EXEC_SCRIPT="$(basename "$SCRIPT") $ARCH_SWITCHES $SCRIPT_SWITCHES" \ + $(cygpath "$COMSPEC") ${SWITCH_PREFIX}v:on ${SWITCH_PREFIX}c $COMMAND 2>/dev/null | grep -F XMARKER -A 3 | tr -d '\015' | tail -3) + if [[ $DEBUG -gt 3 ]] ; then + echo done>&2 + fi + + if [[ -n $MSVS_PATH ]] ; then + # Translate MSVS_PATH back to Cygwin notation (/cygdrive, etc. and colon-separated) + MSVS_PATH=$(cygpath "$MSVS_PATH" -p) + # Remove any trailing / from elements of MSVS_PATH + MSVS_PATH=$(echo "$MSVS_PATH" | sed -e 's|\([^:]\)/\+\(:\|$\)|\1\2|g;s/?msvs-detect?.*//') + # Guarantee that MSVS_PATH ends with a single : + MSVS_PATH="${MSVS_PATH%%:}:" + fi + # Ensure that both variables end with a semi-colon (it doesn't matter if for some erroneous + # reason they have come back blank, because check_environment will shortly fail) + MSVS_LIB="${MSVS_LIB%%;};" + MSVS_INC="${MSVS_INC%%;};" + + # Visual Studio .NET 2002 and 2003 do not include mt in PATH, for not entirely clear reasons. + # This shim detects that scenario and adds the winnt folder to MSVS_PATH. + RET=0 + if [[ ${i/.*/} = "VS7" ]] ; then + find_in "${MSVS_PATH//:/*}" mt.exe + if [[ $RET -eq 1 ]] ; then + MSVS_PATH="$MSVS_PATH$(cygpath -u -f - <<< $ENV\\Bin\\winnt):" + RET=0 + fi + fi + + # Ensure that these derived values give a valid compiler. + if check_environment "${MSVS_PATH//:/*}" "${MSVS_INC//;/*}" "${MSVS_LIB//;/*}" "$i" $arch ; then + # Put the package back into FOUND, but augmented with the architecture name and with the + # derived values. + FOUND["$i-$arch"]="${CURRENT%)} [\"MSVS_PATH\"]=\"$MSVS_PATH\" \ + [\"MSVS_INC\"]=\"$MSVS_INC\" \ + [\"MSVS_LIB\"]=\"$MSVS_LIB\" \ + [\"ASSEMBLER\"]=\"$ASSEMBLER\")" #"# fixes vim syn match error + + # Check to see if this is a match for the environment C compiler. + if [[ -n ${ENV_ARCH+x} ]] ; then + TEST_cl=$(PATH="$MSVS_PATH:$PATH" "$WHICH" cl) + TEST_cl=${TEST_cl,,} + TEST_cl=${TEST_cl/bin\/*_/bin\/} + if [[ $TEST_cl = $ENV_cl ]] ; then + if [[ ${!ENV_INC/"$MSVS_INC"/} != "${!ENV_INC}" && \ + ${!ENV_LIB/"$MSVS_LIB"/} != "${!ENV_LIB}" ]] ; then + debug "$i-$arch is a strong candidate for the Environment C compiler" + if [[ -n ${ENV_COMPILER+x} ]] ; then + if [[ -z ${ENV_COMPILER} ]] ; then + ENV_COMPILER=$i-$arch + unset WEAK_ENV + else + # More than one strong candidate - no fall back available + unset ENV_COMPILER + unset WEAK_ENV + fi + fi + else + debug "$i-$arch is a weak candidate for the Environment C compiler" + if [[ -n ${WEAK_ENV+x} ]] ; then + if [[ -z ${WEAK_ENV} ]] ; then + WEAK_ENV=$i-$arch + else + # More than one weak candidate - no fall back available + unset WEAK_ENV + fi + fi + fi + fi + fi + fi + done + + # Does this package match the current preference? Note that PREFERENCE and TEST are constructed in + # a cunning (and hopefully not too "You are not expected to understand this" way) such that $PREF + # will always equal $i, unless $PREF = "@". + if [[ $PREF = $i ]] ; then + # In which case, check that the architecture(s)s were found + if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then + debug "Solved TARGET_ARCH=$TARGET_ARCH with $i" + SOLUTION=$i + break + fi + fi + + if [[ $PREF != "@" ]] ; then + ((pref++)) + PREF=${PREFERENCE[$pref]} + fi +done + +# If we got this far, then either we failed to find a compiler at all, or we were looking for the +# environment compiler (or --all was specified). + +# Adopt a weak match for the environment compiler, if that's the best we can do. +if [[ -n ${ENV_COMPILER+x} && -z ${ENV_COMPILER} && -n ${WEAK_ENV} ]] ; then + warning "Assuming Environment C compiler is $WEAK_ENV" + ENV_COMPILER=$WEAK_ENV +fi + +declare -A FLIP +FLIP=(["x86"]="x64" ["x64"]="x86") + +if [[ $MODE -eq 0 ]] ; then + if [[ $PREF = "@" && -n ${ENV_COMPILER} ]] ; then + SOLUTION=${ENV_COMPILER%-$ENV_ARCH} + # If --arch wasn't specified, then ensure that the other architecture was also found. If --arch + # was specified, then validate that the compiler was valid. This should always happen, unless + # something went wrong running the script to get MSVS_PATH, MSVS_LIB and MSVS_INC. + if [[ -n ${FOUND["$SOLUTION-${FLIP[$ENV_ARCH]}"]+x} || + -n ${FOUND["$SOLUTION-$TARGET_ARCH"]+x} ]] ; then + debug "Solved with $SOLUTION" + else + unset SOLUTION + unset ENV_ARCH + fi + fi + + if [[ -z ${SOLUTION+x} ]] ; then + ((pref++)) + debug "Search remaining: ${PREFERENCE[*]}" + TEST_ARCH=$TARGET_ARCH + for i in "${PREFERENCE[@]:$pref}" ; do + if [[ -n ${FOUND["$i-$LEFT_ARCH"]+x} && -n ${FOUND["$i-$RIGHT_ARCH"]+x} ]] ; then + debug "Solved TARGET_ARCH='$TARGET_ARCH' with $i" + SOLUTION=$i + break + fi + done + fi +fi + +debug "Solution: $SOLUTION" + +if [[ -n ${ENV_COMPILER} && $MODE -eq 1 ]] ; then + echo "Identified Environment C compiler as $ENV_COMPILER" +fi + +if [[ $MODE -eq 1 ]] ; then + echo "Installed and usable packages:" + for i in "${!FOUND[@]}" ; do + echo " $i" + done | sort + exit 0 +fi + +if [[ -n $SOLUTION ]] ; then + eval COMPILER=${FOUND[$SOLUTION-$LEFT_ARCH]} + output MSVS_NAME "${COMPILER["DISPLAY"]}" $LEFT_ARCH + output MSVS_PATH "${COMPILER["MSVS_PATH"]}" $LEFT_ARCH + output MSVS_INC "${COMPILER["MSVS_INC"]}" $LEFT_ARCH + output MSVS_LIB "${COMPILER["MSVS_LIB"]}" $LEFT_ARCH + if [[ $ML_REQUIRED -eq 1 ]] ; then + output MSVS_ML "${COMPILER["ASSEMBLER"]%.exe}" always + fi + if [[ -z $TARGET_ARCH ]] ; then + eval COMPILER=${FOUND[$SOLUTION-$RIGHT_ARCH]} + output MSVS64_PATH "${COMPILER["MSVS_PATH"]}" $RIGHT_ARCH + output MSVS64_INC "${COMPILER["MSVS_INC"]}" $RIGHT_ARCH + output MSVS64_LIB "${COMPILER["MSVS_LIB"]}" $RIGHT_ARCH + if [[ $ML_REQUIRED -eq 1 ]] ; then + output MSVS64_ML "${COMPILER["ASSEMBLER"]%.exe}" always + fi + fi + exit 0 +else + exit 1 +fi diff --git a/.travis/or1k-sim.exp b/.ci/or1k-sim.exp similarity index 100% rename from .travis/or1k-sim.exp rename to .ci/or1k-sim.exp diff --git a/.travis/powerpc-eabisim.exp b/.ci/powerpc-eabisim.exp similarity index 100% rename from .travis/powerpc-eabisim.exp rename to .ci/powerpc-eabisim.exp diff --git a/.travis/site.exp b/.ci/site.exp similarity index 73% rename from .travis/site.exp rename to .ci/site.exp index 644ec6318..96c013e08 100644 --- a/.travis/site.exp +++ b/.ci/site.exp @@ -1,11 +1,11 @@ -# Copyright (C) 2008, 2010, 2018, 2019 Anthony Green +# Copyright (C) 2008, 2010, 2018, 2019, 2021 Anthony Green # Make sure we look in the right place for the board description files. if ![info exists boards_dir] { set boards_dir {} } -lappend boards_dir $::env(TRAVIS_BUILD_DIR)/.travis +lappend boards_dir $::env(BOARDSDIR) verbose "Global Config File: target_triplet is $target_triplet" 2 global target_list @@ -23,5 +23,7 @@ case "$target_triplet" in { { "or1k-elf" } { set target_list "or1k-sim" } + { "powerpc-eabisim" } { + set target_list "powerpc-eabisim" + } } - diff --git a/.travis/wine-sim.exp b/.ci/wine-sim.exp similarity index 100% rename from .travis/wine-sim.exp rename to .ci/wine-sim.exp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..ec19fe0cb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,154 @@ +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ github-actions ] + pull_request: + branches: [ github-actions ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + + build-sim: + name: Build & test + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - MEVAL: "export CC=clang && CXX=clang" + - HOST: "i386-pc-linux-gnu" + MEVAL: 'export CC="gcc -m32" && CXX="g++ -m32"' + - CONFIGURE_OPTIONS: "--disable-shared" + - CONFIGURE_OPTIONS: "--enable-shared" + - HOST: "m68k-linux-gnu" + MEVAL: 'export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' + CONFIGURE_OPTIONS: '--disable-shared' + QEMU_LD_PREFIX: '/usr/m68k-linux-gnu' + QEMU_CPU: 'cfv4e' + - HOST: "sh4-linux-gnu" + CONFIGURE_OPTIONS: "--disable-shared" + QEMU_LD_PREFIX: "/usr/sh4-linux-gnu" + QEMU_CPU: 'sh7785' + - HOST: "alpha-linux-gnu" + CONFIGURE_OPTIONS: "--disable-shared" + QEMU_LD_PREFIX: "/usr/alpha-linux-gnu" + - HOST: "arm32v7-linux-gnu" + LIBFFI_TEST_OPTIMIZATION: "-O0" + - HOST: "arm32v7-linux-gnu" + LIBFFI_TEST_OPTIMIZATION: "-O2" + - HOST: "arm32v7-linux-gnu" + LIBFFI_TEST_OPTIMIZATION: "-O2 -fomit-frame-pointer" + - HOST: "powerpc-eabisim" + RUNTESTFLAGS: "--target_board powerpc-eabisim" + - HOST: "or1k-elf" + RUNTESTFLAGS: "--target_board or1k-sim" + - HOST: "m32r-elf" + RUNTESTFLAGS: "--target_board m32-sim" + - HOST: "bfin-elf" + RUNTESTFLAGS: "--target_board bfin-sim" + - MEVAL: "export PATH=/opt/moxielogic/bin:$PATH && CC=moxie-elf-gcc && CXX=moxie-elf-g++" + HOST: "moxie-elf" + LDFLAGS: "-Tsim.ld" + RUNTESTFLAGS: "--target_board moxie-sim" + + steps: + - uses: actions/checkout@v2 + + - env: + MEVAL: ${{ matrix.MEVAL }} + HOST: ${{ matrix.HOST }} + LDFLAGS: ${{ matrix.LDFLAGS }} + RUNTESTFLAGS: ${{ matrix.RUNTESTFLAGS }} + CONFIGURE_OPTIONS: ${{ matrix.CONFIGURE_OPTIONS }} + QEMU_LD_PREFIX: ${{ matrix.QEMU_LD_PREFIX }} + QEMU_CPU: ${{ matrix.QEMU_CPU }} + run: | + if test x"$MEVAL" != x; then eval ${MEVAL}; fi + ./.ci/install.sh + ./.ci/build.sh + + build: + name: Build & test with Cygwin + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + platform: [windows-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Cygwin + uses: egor-tensin/setup-cygwin@v3 + with: + platform: x64 + packages: wget gcc-core make dejagnu automake autoconf libtool texinfo dos2unix unzip + + - run: | + cd $(cygpath $RUNNER_WORKSPACE)/libffi + wget https://rl.gl/cli/rlgl-windows-amd64.zip + unzip rlgl-windows-amd64.zip + find . -name \*.m4|xargs dos2unix + find . -name \*.ac|xargs dos2unix + find . -name \*.am|xargs dos2unix + find . -name \*.host|xargs dos2unix + autoreconf -f -v -i + ./configure + find . -name libtool\*|xargs dos2unix + make -j 4 + TERM=none export DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci make check || true + ./rlgl/rlgl.exe l --key=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI https://rl.gl + ID=$(./rlgl/rlgl.exe start) + ./rlgl/rlgl.exe e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git $(find . -name libffi.log) + shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' + + build-msvc: + name: Build & test with Visual C++ + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + platform: [windows-latest] + + steps: + - uses: actions/checkout@v2 + - uses: egor-tensin/setup-cygwin@v3 + with: + platform: x64 + packages: wget make dejagnu automake autoconf libtool texinfo unzip dos2unix + - uses: ilammy/msvc-dev-cmd@v1.8.1 + - uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build and test + run: | + dos2unix $(cygpath $RUNNER_WORKSPACE)/libffi/.ci/msvs-detect + # $(cygpath $RUNNER_WORKSPACE)/libffi/.ci/msvs-detect --arch=x64 --with-assembler + export PATH=$PATH:"/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64" + cd $(cygpath $RUNNER_WORKSPACE)/libffi + wget https://rl.gl/cli/rlgl-windows-amd64.zip + unzip rlgl-windows-amd64.zip + find . -name \*.sh|xargs dos2unix + find . -name \*.m4|xargs dos2unix + find . -name \*.ac|xargs dos2unix + find . -name \*.am|xargs dos2unix + find . -name \*.host|xargs dos2unix + dos2unix .ci/ar-lib + autoreconf -f -v -i + ./configure CC="$(pwd)/msvcc.sh -m64" CXX="$(pwd)/msvcc.sh -m64" LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='$(pwd)/.ci/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST $DEBUG_ARG $SHARED_ARG || cat */config.log + find . -name libtool\*|xargs dos2unix + make + cp $(find . -name 'libffi-?.dll') x86_64-pc-cygwin/testsuite/ + TERM=none DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci make check || true + ./rlgl/rlgl.exe l --key=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI https://rl.gl + ID=$(./rlgl/rlgl.exe start) + ./rlgl/rlgl.exe e --id=$ID --policy=https://github.com/libffi/rlgl-policy.git $(find . -name libffi.log) + shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' diff --git a/.gitignore b/.gitignore index e393a472d..f33ca3da1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ Makefile Makefile.in aclocal.m4 compile -!.travis/compile +!.ci/compile configure depcomp doc/libffi.info diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a18919cd9..000000000 --- a/.travis.yml +++ /dev/null @@ -1,83 +0,0 @@ ---- -sudo: required - -language: cpp - -# For qemu-powered targets, get the list of supported processors from -# travis by setting QEMU_CPU=help, then set -mcpu= for the compilers -# accordingly. - -matrix: - include: - - os: linux - env: HOST=powerpc-eabisim RUNTESTFLAGS="--target_board powerpc-eabisim" DEJAGNU="/opt/.travis/site.exp" - - os: linux - env: HOST=or1k-elf RUNTESTFLAGS="--target_board or1k-sim" DEJAGNU="/opt/.travis/site.exp" - - os: linux - env: HOST=m32r-elf RUNTESTFLAGS="--target_board m32r-sim" DEJAGNU="/opt/.travis/site.exp" - - os: linux - env: HOST=bfin-elf RUNTESTFLAGS="--target_board bfin-sim" DEJAGNU="/opt/.travis/site.exp" -# This configuration is still using the native x86 toolchain? -# - os: osx -# env: HOST=aarch64-apple-darwin13 - - os: osx - env: HOST=x86_64-apple-darwin10 - - os: linux - env: HOST=x86_64-w64-mingw32 MEVAL='export CC="x86_64-w64-mingw32-gcc" && CXX="x86_64-w64-mingw32-g++" RUNTESTFLAGS="--target_board wine-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" CONFIGURE_OPTIONS=--disable-shared LIBFFI_TEST_OPTIMIZATION="-O2" - - os: linux - env: HOST=sh4-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/sh4-linux-gnu - - os: linux - env: HOST=alpha-linux-gnu CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/alpha-linux-gnu - - os: linux - env: HOST=m68k-linux-gnu MEVAL='export CC="m68k-linux-gnu-gcc-8 -mcpu=547x" && CXX="m68k-linux-gnu-g++-8 -mcpu=547x"' CONFIGURE_OPTIONS=--disable-shared QEMU_LD_PREFIX=/usr/m68k-linux-gnu QEMU_CPU=cfv4e - - os: linux - arch: s390x - env: HOST=s390x-linux-gnu - - os: linux - arch: ppc64le - env: HOST=ppc64le-linux-gnu - - os: linux - arch: arm64 - env: HOST=aarch64-linux-gnu - - os: linux - arch: arm64 - env: HOST=aarch64-linux-gnu - compiler: clang - - os: linux - env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O0" - - os: linux - env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2" - - os: linux - env: HOST=arm32v7-linux-gnu LIBFFI_TEST_OPTIMIZATION="-O2 -fomit-frame-pointer" -# The sparc64 linux system in the GCC compile farm is non-responsive. -# - os: linux -# env: HOST=sparc64-linux-gnu -# The mips64 linux system in the GCC compile farm is not allowing logins -# - os: linux -# env: HOST=mips64el-linux-gnu - - os: linux - compiler: gcc - env: HOST=i386-pc-linux-gnu MEVAL='export CC="$CC -m32" && CXX="$CXX -m32"' - - os: linux - compiler: gcc - - os: linux - compiler: gcc - env: CONFIGURE_OPTIONS=--disable-shared - - os: linux - compiler: clang - - os: linux - compiler: clang - env: CONFIGURE_OPTIONS=--disable-shared - - os: linux - env: HOST=moxie-elf MEVAL='export PATH=/opt/moxielogic/bin:$PATH && CC=moxie-elf-gcc && CXX=moxie-elf-g++' LDFLAGS=-Tsim.ld RUNTESTFLAGS="--target_board moxie-sim" DEJAGNU="$TRAVIS_BUILD_DIR/.travis/site.exp" - -before_install: - - if test x"$MEVAL" != x; then eval ${MEVAL}; fi - -install: - - travis_wait 60 ./.travis/install.sh - -script: - - if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi - - travis_wait 115 sleep infinity & - - ./.travis/build.sh diff --git a/.travis/build-cross-in-container.sh b/.travis/build-cross-in-container.sh deleted file mode 100755 index 7e2252ce1..000000000 --- a/.travis/build-cross-in-container.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -cd /opt - -echo $PATH -export PATH=/usr/local/bin:$PATH -echo $PATH - -./configure --host=${HOST} || cat */config.log -make -make dist -make check RUNTESTFLAGS="-a $RUNTESTFLAGS" || true - - From b4cf80ab54b6d9d31ef2135036e471388cf026df Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 08:55:02 -0400 Subject: [PATCH 214/231] Trigger actions on master branch --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec19fe0cb..8d504734f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,9 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the master branch push: - branches: [ github-actions ] + branches: [ master ] pull_request: - branches: [ github-actions ] + branches: [ master ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From a541fc600f4418441f91073a0834ea47b0989de9 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 08:56:30 -0400 Subject: [PATCH 215/231] Update README for next release. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b95bd74d8..327f4e317 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Status ====== -libffi-3.4.1 was released on June 28, 2021. Check the libffi web page +libffi-3.4.2 was released on June 28, 2021. Check the libffi web page for updates: . @@ -195,6 +195,9 @@ History See the git log for details at http://github.com/libffi/libffi. + 3.4.3 TBD + TBD + 3.4.2 Jun-28-21 Add static trampoline support for Linux on x86_64 and ARM64. Add support for Alibaba's CSKY architecture. From eb2447249540ca568b0b464f6107501dcc0f65ab Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 16 Jul 2021 14:33:04 +0000 Subject: [PATCH 216/231] Use CHECK to assert more things in test suite (#654) * Use CHECK to assert more things in test suite * Use snprintf instead of sprintf * Fix va_struct1 and va_struct3 --- testsuite/Makefile.am | 2 +- testsuite/libffi.call/ffitest.h | 19 ++++++ testsuite/libffi.call/float_va.c | 3 + .../libffi.call/{pyobjc-tc.c => pyobjc_tc.c} | 0 testsuite/libffi.call/return_ll1.c | 5 ++ testsuite/libffi.call/return_sl.c | 4 ++ testsuite/libffi.call/return_ul.c | 4 ++ testsuite/libffi.call/va_2.c | 24 ++++++++ testsuite/libffi.call/va_struct1.c | 13 ++++ testsuite/libffi.call/va_struct2.c | 11 ++++ testsuite/libffi.call/va_struct3.c | 15 +++++ testsuite/libffi.closures/closure_fn0.c | 5 +- testsuite/libffi.closures/closure_fn1.c | 2 + testsuite/libffi.closures/closure_fn2.c | 2 + testsuite/libffi.closures/closure_fn3.c | 22 ++++++- testsuite/libffi.closures/closure_fn4.c | 2 + testsuite/libffi.closures/closure_fn5.c | 2 + testsuite/libffi.closures/closure_fn6.c | 2 + testsuite/libffi.closures/closure_loc_fn0.c | 7 ++- testsuite/libffi.closures/closure_simple.c | 6 ++ testsuite/libffi.closures/cls_12byte.c | 18 ++++++ testsuite/libffi.closures/cls_16byte.c | 22 +++++++ testsuite/libffi.closures/cls_18byte.c | 24 ++++++++ testsuite/libffi.closures/cls_19byte.c | 29 +++++++++ testsuite/libffi.closures/cls_1_1byte.c | 4 ++ testsuite/libffi.closures/cls_20byte.c | 18 ++++++ testsuite/libffi.closures/cls_20byte1.c | 20 ++++++ testsuite/libffi.closures/cls_24byte.c | 32 ++++++++++ testsuite/libffi.closures/cls_2byte.c | 13 ++++ testsuite/libffi.closures/cls_3_1byte.c | 19 ++++++ testsuite/libffi.closures/cls_3byte1.c | 13 ++++ testsuite/libffi.closures/cls_3byte2.c | 13 ++++ testsuite/libffi.closures/cls_3float.c | 18 ++++++ testsuite/libffi.closures/cls_4_1byte.c | 22 +++++++ testsuite/libffi.closures/cls_4byte.c | 13 ++++ testsuite/libffi.closures/cls_5_1_byte.c | 28 +++++++++ testsuite/libffi.closures/cls_5byte.c | 18 ++++++ testsuite/libffi.closures/cls_64byte.c | 24 ++++++++ testsuite/libffi.closures/cls_6_1_byte.c | 27 ++++++++ testsuite/libffi.closures/cls_6byte.c | 24 +++++++- testsuite/libffi.closures/cls_7_1_byte.c | 38 ++++++++++++ testsuite/libffi.closures/cls_7byte.c | 24 ++++++++ testsuite/libffi.closures/cls_8byte.c | 14 +++++ testsuite/libffi.closures/cls_9byte1.c | 13 ++++ testsuite/libffi.closures/cls_9byte2.c | 14 ++++- testsuite/libffi.closures/cls_align_double.c | 18 ++++++ testsuite/libffi.closures/cls_align_float.c | 18 ++++++ .../libffi.closures/cls_align_longdouble.c | 19 ++++++ .../cls_align_longdouble_split.c | 61 ++++++++++++------- .../cls_align_longdouble_split2.c | 39 +++++++++++- testsuite/libffi.closures/cls_align_pointer.c | 18 ++++++ testsuite/libffi.closures/cls_align_sint16.c | 17 ++++++ testsuite/libffi.closures/cls_align_sint32.c | 19 +++++- testsuite/libffi.closures/cls_align_sint64.c | 17 ++++++ testsuite/libffi.closures/cls_align_uint16.c | 17 ++++++ testsuite/libffi.closures/cls_align_uint32.c | 18 ++++++ testsuite/libffi.closures/cls_align_uint64.c | 18 ++++++ testsuite/libffi.closures/cls_dbls_struct.c | 2 + testsuite/libffi.closures/cls_double_va.c | 8 +++ testsuite/libffi.closures/cls_float.c | 4 ++ testsuite/libffi.closures/cls_longdouble.c | 10 +++ testsuite/libffi.closures/cls_longdouble_va.c | 8 +++ testsuite/libffi.closures/cls_multi_schar.c | 4 ++ testsuite/libffi.closures/cls_multi_sshort.c | 5 ++ .../libffi.closures/cls_multi_sshortchar.c | 8 +++ testsuite/libffi.closures/cls_multi_uchar.c | 8 +++ testsuite/libffi.closures/cls_multi_ushort.c | 6 +- .../libffi.closures/cls_multi_ushortchar.c | 8 +++ testsuite/libffi.closures/cls_pointer.c | 5 ++ testsuite/libffi.closures/cls_pointer_stack.c | 10 +++ testsuite/libffi.closures/cls_schar.c | 3 + testsuite/libffi.closures/cls_sint.c | 2 + testsuite/libffi.closures/cls_sshort.c | 3 + testsuite/libffi.closures/cls_struct_va1.c | 11 ++++ testsuite/libffi.closures/cls_uchar.c | 3 + testsuite/libffi.closures/cls_uint.c | 4 ++ testsuite/libffi.closures/cls_uint_va.c | 4 ++ testsuite/libffi.closures/cls_ulong_va.c | 4 ++ testsuite/libffi.closures/cls_ulonglong.c | 2 + testsuite/libffi.closures/cls_ushort.c | 3 + testsuite/libffi.closures/ffitest.h | 19 ++++++ testsuite/libffi.closures/huge_struct.c | 2 +- testsuite/libffi.closures/nested_struct.c | 39 +++++++++--- testsuite/libffi.closures/nested_struct10.c | 12 ++++ testsuite/libffi.closures/nested_struct11.c | 26 ++++++-- testsuite/libffi.closures/nested_struct12.c | 2 +- testsuite/libffi.closures/nested_struct13.c | 20 ++++-- testsuite/libffi.closures/nested_struct2.c | 9 +++ testsuite/libffi.closures/nested_struct3.c | 9 +++ testsuite/libffi.closures/nested_struct4.c | 9 +++ testsuite/libffi.closures/nested_struct5.c | 9 +++ testsuite/libffi.closures/nested_struct6.c | 11 ++++ testsuite/libffi.closures/nested_struct7.c | 9 +++ testsuite/libffi.closures/nested_struct8.c | 11 ++++ testsuite/libffi.closures/nested_struct9.c | 11 ++++ testsuite/libffi.closures/testclosure.c | 5 ++ 96 files changed, 1202 insertions(+), 57 deletions(-) rename testsuite/libffi.call/{pyobjc-tc.c => pyobjc_tc.c} (100%) diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 1e4b35a34..50cc84b93 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -9,7 +9,7 @@ CLEANFILES = *.exe core* *.log *.sum EXTRA_DIST = lib/target-libpath.exp lib/libffi.exp lib/wrapper.exp \ libffi.call/strlen4.c libffi.call/struct10.c libffi.call/many_mixed.c \ libffi.call/float.c libffi.call/struct5.c libffi.call/return_fl3.c \ -libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc-tc.c \ +libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc_tc.c \ libffi.call/float_va.c libffi.call/struct8.c libffi.call/pr1172638.c \ libffi.call/return_sc.c libffi.call/va_struct1.c \ libffi.call/align_stdcall.c libffi.call/struct9.c libffi.call/va_1.c \ diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 95d96a83f..53b009cdf 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -5,6 +5,9 @@ #include #include "fficonfig.h" +#include +#include + #if defined HAVE_STDINT_H #include #endif @@ -23,6 +26,22 @@ } \ } while(0) +#define CHECK_FLOAT_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > FLT_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + +#define CHECK_DOUBLE_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > DBL_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) diff --git a/testsuite/libffi.call/float_va.c b/testsuite/libffi.call/float_va.c index 5acff91f6..d01d9d0a9 100644 --- a/testsuite/libffi.call/float_va.c +++ b/testsuite/libffi.call/float_va.c @@ -74,6 +74,7 @@ int main (void) /* { dg-output "\n0: 2.0 : total: 2.0" } */ printf("ffi: %.1f\n", resfp); /* { dg-output "\nffi: 2.0" } */ + CHECK_DOUBLE_EQ(resfp, 2); /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */ /* Call it statically and then via ffi */ @@ -81,6 +82,7 @@ int main (void) /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ printf("compiled: %.1f\n", resfp); /* { dg-output "\ncompiled: 11.0" } */ + CHECK_DOUBLE_EQ(resfp, 11); arg_types[0] = &ffi_type_uint; arg_types[1] = &ffi_type_double; @@ -102,6 +104,7 @@ int main (void) /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ printf("ffi: %.1f\n", resfp); /* { dg-output "\nffi: 11.0" } */ + CHECK_DOUBLE_EQ(resfp, 11); exit(0); } diff --git a/testsuite/libffi.call/pyobjc-tc.c b/testsuite/libffi.call/pyobjc_tc.c similarity index 100% rename from testsuite/libffi.call/pyobjc-tc.c rename to testsuite/libffi.call/pyobjc_tc.c diff --git a/testsuite/libffi.call/return_ll1.c b/testsuite/libffi.call/return_ll1.c index 593e8a307..a2426ec93 100644 --- a/testsuite/libffi.call/return_ll1.c +++ b/testsuite/libffi.call/return_ll1.c @@ -9,6 +9,9 @@ #include "ffitest.h" static long long return_ll(int ll0, long long ll1, int ll2) { + CHECK(ll0 == 11111111); + CHECK(ll1 == 11111111111000LL); + CHECK(ll2 == 11111111); return ll0 + ll1 + ll2; } @@ -39,5 +42,7 @@ int main (void) ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2); /* { dg-output "res: 11111133333222, 11111133333222" } */ + CHECK(rlonglong == 11111133333222); + CHECK(ll0 + ll1 + ll2 == 11111133333222); exit(0); } diff --git a/testsuite/libffi.call/return_sl.c b/testsuite/libffi.call/return_sl.c index f0fd345f7..4fe5e9a4b 100644 --- a/testsuite/libffi.call/return_sl.c +++ b/testsuite/libffi.call/return_sl.c @@ -8,6 +8,8 @@ #include "ffitest.h" static long return_sl(long l1, long l2) { + CHECK(l1 == 1073741823L); + CHECK(l2 == 1073741824L); return l1 - l2; } @@ -33,6 +35,8 @@ int main (void) ffi_call(&cif, FFI_FN(return_sl), &res, values); printf("res: %ld, %ld\n", (long)res, l1 - l2); /* { dg-output "res: -1, -1" } */ + CHECK(res == -1); + CHECK(l1 - l2 == -1); exit(0); } diff --git a/testsuite/libffi.call/return_ul.c b/testsuite/libffi.call/return_ul.c index 12b266f03..fedcc25ab 100644 --- a/testsuite/libffi.call/return_ul.c +++ b/testsuite/libffi.call/return_ul.c @@ -8,6 +8,8 @@ #include "ffitest.h" static unsigned long return_ul(unsigned long ul1, unsigned long ul2) { + CHECK(ul1 == 1073741823L); + CHECK(ul2 == 1073741824L); return ul1 + ul2; } @@ -33,6 +35,8 @@ int main (void) ffi_call(&cif, FFI_FN(return_ul), &res, values); printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2); /* { dg-output "res: 2147483647, 2147483647" } */ + CHECK(res == 2147483647L); + CHECK(ul1 + ul2 == 2147483647L); exit(0); } diff --git a/testsuite/libffi.call/va_2.c b/testsuite/libffi.call/va_2.c index 0589d0848..cb88db9af 100644 --- a/testsuite/libffi.call/va_2.c +++ b/testsuite/libffi.call/va_2.c @@ -25,6 +25,7 @@ struct large_tag unsigned e; }; + static int test_fn (int n, ...) { @@ -72,7 +73,29 @@ test_fn (int n, ...) ui, si, ul, sl, f, d); + va_end (ap); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); + CHECK(uc == 9); + CHECK(sc == 10); + CHECK(us == 11); + CHECK(ss == 12); + CHECK(ui == 13); + CHECK(si == 14); + CHECK(ul == 15); + CHECK(sl == 16); + CHECK((int)f == 2); + CHECK((int)d == 3); + return n + 1; } @@ -191,6 +214,7 @@ main (void) /* { 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" } */ + CHECK(res == 42); return 0; } diff --git a/testsuite/libffi.call/va_struct1.c b/testsuite/libffi.call/va_struct1.c index e6452061c..fff5c9acc 100644 --- a/testsuite/libffi.call/va_struct1.c +++ b/testsuite/libffi.call/va_struct1.c @@ -40,6 +40,18 @@ test_fn (int n, ...) 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); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + + CHECK(s2.a == 7); + CHECK(s2.b == 8); return n + 1; } @@ -116,6 +128,7 @@ main (void) /* { dg-output "5 6 10 11 12 13 14 7 8" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 42" } */ + CHECK(res == 42); return 0; } diff --git a/testsuite/libffi.call/va_struct2.c b/testsuite/libffi.call/va_struct2.c index 56f5b9c75..a8daff3bf 100644 --- a/testsuite/libffi.call/va_struct2.c +++ b/testsuite/libffi.call/va_struct2.c @@ -39,6 +39,15 @@ test_fn (int n, ...) 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); + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); va_end (ap); s1.a += s2.a; s1.b += s2.b; @@ -118,6 +127,8 @@ main (void) /* { 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" } */ + CHECK(res.a == 12); + CHECK(res.b == 14); return 0; } diff --git a/testsuite/libffi.call/va_struct3.c b/testsuite/libffi.call/va_struct3.c index 9a27e7fd4..d3bd28096 100644 --- a/testsuite/libffi.call/va_struct3.c +++ b/testsuite/libffi.call/va_struct3.c @@ -39,6 +39,16 @@ test_fn (int n, ...) 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); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); va_end (ap); l.a += s1.a; l.b += s1.b; @@ -120,6 +130,11 @@ main (void) /* { 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" } */ + CHECK(res.a == 15); + CHECK(res.b == 17); + CHECK(res.c == 19); + CHECK(res.d == 21); + CHECK(res.e == 14); return 0; } diff --git a/testsuite/libffi.closures/closure_fn0.c b/testsuite/libffi.closures/closure_fn0.c index a579ff6c9..dfadb0556 100644 --- a/testsuite/libffi.closures/closure_fn0.c +++ b/testsuite/libffi.closures/closure_fn0.c @@ -38,7 +38,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(int *)args[14]),*(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - + CHECK((int)*(ffi_arg *)resp == 680); } typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, @@ -85,5 +85,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ - exit(0); + CHECK(res == 680); + exit(0); } diff --git a/testsuite/libffi.closures/closure_fn1.c b/testsuite/libffi.closures/closure_fn1.c index 91231738c..a90bb291b 100644 --- a/testsuite/libffi.closures/closure_fn1.c +++ b/testsuite/libffi.closures/closure_fn1.c @@ -33,6 +33,7 @@ static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 255); } typedef int (*closure_test_type1)(float, float, float, float, signed short, @@ -77,5 +78,6 @@ int main (void) /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn2.c b/testsuite/libffi.closures/closure_fn2.c index 08ff9d922..7d7af4b59 100644 --- a/testsuite/libffi.closures/closure_fn2.c +++ b/testsuite/libffi.closures/closure_fn2.c @@ -32,6 +32,7 @@ static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(float *)args[13]), (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 255); } typedef int (*closure_test_type2)(double, double, double, double, signed short, @@ -77,5 +78,6 @@ int main (void) /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn3.c b/testsuite/libffi.closures/closure_fn3.c index 9b54d805c..1ad8f9d86 100644 --- a/testsuite/libffi.closures/closure_fn3.c +++ b/testsuite/libffi.closures/closure_fn3.c @@ -31,8 +31,27 @@ static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)(*(float *)args[10]), (int)(*(float *)args[11]), (int)*(int *)args[12], (int)(*(float *)args[13]), (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, - (int)*(ffi_arg *)resp); + (int)*(ffi_arg *)resp); + CHECK((int)*(float *)args[0] == 1); + CHECK((int)(*(float *)args[1]) == 2); + CHECK((int)(*(float *)args[2]) == 3); + CHECK((int)(*(float *)args[3]) == 4); + CHECK((int)(*(float *)args[4]) == 5); + CHECK((int)(*(float *)args[5]) == 6); + CHECK((int)*(float *)args[6] == 7); + CHECK((int)(*(float *)args[7]) == 8); + CHECK((int)(*(double *)args[8]) == 9); + CHECK((int)*(int *)args[9] == 10); + CHECK((int)(*(float *)args[10]) == 11); + CHECK((int)(*(float *)args[11]) == 12); + CHECK((int)*(int *)args[12] == 13); + CHECK((int)(*(float *)args[13]) == 19); + CHECK((int)(*(float *)args[14]) == 21); + CHECK(*(int *)args[15] == 1); + CHECK((int)(intptr_t)userdata == 3); + + CHECK((int)*(ffi_arg *)resp == 135); } typedef int (*closure_test_type3)(float, float, float, float, float, float, @@ -78,5 +97,6 @@ int main (void) /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */ printf("res: %d\n",res); /* { dg-output "\nres: 135" } */ + CHECK(res == 135); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn4.c b/testsuite/libffi.closures/closure_fn4.c index d4a1530b0..e5f1f53d1 100644 --- a/testsuite/libffi.closures/closure_fn4.c +++ b/testsuite/libffi.closures/closure_fn4.c @@ -45,6 +45,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(unsigned long long *)args[14], *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -84,6 +85,7 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn5.c b/testsuite/libffi.closures/closure_fn5.c index 99074426c..97277f5c3 100644 --- a/testsuite/libffi.closures/closure_fn5.c +++ b/testsuite/libffi.closures/closure_fn5.c @@ -44,6 +44,7 @@ closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(unsigned long long *)args[14], *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -87,6 +88,7 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn6.c b/testsuite/libffi.closures/closure_fn6.c index 73c54fd6b..fb079e2ef 100644 --- a/testsuite/libffi.closures/closure_fn6.c +++ b/testsuite/libffi.closures/closure_fn6.c @@ -37,6 +37,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(double *)args[14]), (int)(*(double *)args[15]), (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -86,5 +87,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_loc_fn0.c b/testsuite/libffi.closures/closure_loc_fn0.c index ad488acaa..4f2f4f8c1 100644 --- a/testsuite/libffi.closures/closure_loc_fn0.c +++ b/testsuite/libffi.closures/closure_loc_fn0.c @@ -9,7 +9,7 @@ -/* { dg-do run } */ +/* { dg-do run { xfail wasm32*-*-* } } */ #include "ffitest.h" static void @@ -82,7 +82,7 @@ int main (void) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0, (void *) 3 /* userdata */, codeloc) == FFI_OK); - + #ifndef FFI_EXEC_STATIC_TRAMP /* With static trampolines, the codeloc does not point to closure */ CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0); @@ -94,5 +94,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ - exit(0); + CHECK(res == 680); + exit(0); } diff --git a/testsuite/libffi.closures/closure_simple.c b/testsuite/libffi.closures/closure_simple.c index 5a4e728d4..a18b4a4ff 100644 --- a/testsuite/libffi.closures/closure_simple.c +++ b/testsuite/libffi.closures/closure_simple.c @@ -20,6 +20,11 @@ closure_test(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata) (int)(*(int *)args[2]), (int)(*(int *)args[3]), (int)*(ffi_arg *)resp); + CHECK((int)*(int *)args[0] == 0); + CHECK((int)*(int *)args[1] == 1); + CHECK((int)*(int *)args[2] == 2); + CHECK((int)*(int *)args[3] == 3); + CHECK((int)*(ffi_arg *)resp == 9); } typedef int (ABI_ATTR *closure_test_type0)(int, int, int, int); @@ -50,6 +55,7 @@ int main (void) printf("res: %d\n",res); /* { dg-output "\nres: 9" } */ + CHECK(res == 9); exit(0); } diff --git a/testsuite/libffi.closures/cls_12byte.c b/testsuite/libffi.closures/cls_12byte.c index ea0825d17..a1fdcd76f 100644 --- a/testsuite/libffi.closures/cls_12byte.c +++ b/testsuite/libffi.closures/cls_12byte.c @@ -25,6 +25,17 @@ cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1, printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, result.a, result.b, result.c); + CHECK(b1.a == 7); + CHECK(b1.b == 4); + CHECK(b1.c == 9); + + CHECK(b2.a == 1); + CHECK(b2.b == 5); + CHECK(b2.c == 3); + + CHECK(result.a == 8); + CHECK(result.b == 9); + CHECK(result.c == 12); return result; } @@ -78,6 +89,9 @@ int main (void) /* { dg-output "7 4 9 1 5 3: 8 9 12" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 9 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 9); + CHECK(res_dbl.c == 12); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK); @@ -87,8 +101,12 @@ int main (void) res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl); /* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 9 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 9); + CHECK(res_dbl.c == 12); exit(0); } diff --git a/testsuite/libffi.closures/cls_16byte.c b/testsuite/libffi.closures/cls_16byte.c index 89a08a2d9..57fe8737b 100644 --- a/testsuite/libffi.closures/cls_16byte.c +++ b/testsuite/libffi.closures/cls_16byte.c @@ -26,6 +26,19 @@ cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1, printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, result.a, result.b, result.c); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + CHECK(b1.c == 9); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + CHECK(b2.c == 3); + + CHECK(result.a == 8); + CHECK(result.b == 17); + CHECK(result.c == 12); + + return result; } @@ -80,6 +93,10 @@ int main (void) printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 17 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); + CHECK(res_dbl.c == 12); + res_dbl.a = 0; res_dbl.b = 0.0; res_dbl.c = 0; @@ -91,5 +108,10 @@ int main (void) printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 17 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); + CHECK(res_dbl.c == 12); + + exit(0); } diff --git a/testsuite/libffi.closures/cls_18byte.c b/testsuite/libffi.closures/cls_18byte.c index 9f75da80a..3783121b9 100644 --- a/testsuite/libffi.closures/cls_18byte.c +++ b/testsuite/libffi.closures/cls_18byte.c @@ -29,6 +29,22 @@ cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1, printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + + CHECK(a1.a == 1); + CHECK(a1.b == 127); + CHECK(a1.c == 126); + CHECK(a1.d == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 125); + CHECK(a2.c == 124); + CHECK(a2.d == 5); + + CHECK(result.a == 5); + CHECK(result.b == 252); + CHECK(result.c == 250); + CHECK(result.d == 8); + return result; } @@ -84,6 +100,10 @@ int main (void) /* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 5 252 250 8" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK); @@ -91,6 +111,10 @@ int main (void) /* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 5 252 250 8" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); exit(0); } diff --git a/testsuite/libffi.closures/cls_19byte.c b/testsuite/libffi.closures/cls_19byte.c index 278794b5b..98ce65a48 100644 --- a/testsuite/libffi.closures/cls_19byte.c +++ b/testsuite/libffi.closures/cls_19byte.c @@ -32,6 +32,25 @@ cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1, a1.a, a1.b, a1.c, a1.d, a1.e, a2.a, a2.b, a2.c, a2.d, a2.e, result.a, result.b, result.c, result.d, result.e); + + CHECK(a1.a == 1); + CHECK(a1.b == 127); + CHECK(a1.c == 126); + CHECK(a1.d == 3); + CHECK(a1.e == 120); + + CHECK(a2.a == 4); + CHECK(a2.b == 125); + CHECK(a2.c == 124); + CHECK(a2.d == 5); + CHECK(a2.e == 119); + + CHECK(result.a == 5); + CHECK(result.b == 252); + CHECK(result.c == 250); + CHECK(result.d == 8); + CHECK(result.e == 239); + return result; } @@ -89,6 +108,11 @@ int main (void) printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 5 252 250 8 239" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); + CHECK(res_dbl.e == 239); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK); @@ -97,6 +121,11 @@ int main (void) printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 5 252 250 8 239" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); + CHECK(res_dbl.e == 239); exit(0); } diff --git a/testsuite/libffi.closures/cls_1_1byte.c b/testsuite/libffi.closures/cls_1_1byte.c index 82492c020..49e33b9ba 100644 --- a/testsuite/libffi.closures/cls_1_1byte.c +++ b/testsuite/libffi.closures/cls_1_1byte.c @@ -23,6 +23,9 @@ cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1, result.a = a1.a + a2.a; printf("%d %d: %d\n", a1.a, a2.a, result.a); + CHECK(a1.a == 12); + CHECK(a2.a == 178); + CHECK(result.a == 190); return result; } @@ -84,6 +87,7 @@ int main (void) /* { dg-output "\n12 178: 190" } */ printf("res: %d\n", res_dbl.a); /* { dg-output "\nres: 190" } */ + CHECK(res_dbl.a == 190); exit(0); } diff --git a/testsuite/libffi.closures/cls_20byte.c b/testsuite/libffi.closures/cls_20byte.c index 34ea021fb..fdae6f723 100644 --- a/testsuite/libffi.closures/cls_20byte.c +++ b/testsuite/libffi.closures/cls_20byte.c @@ -25,6 +25,18 @@ static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, printf("%g %g %d %g %g %d: %g %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 5); + CHECK(a2.c == 7); + + CHECK(result.a == 5); + CHECK(result.b == 7); + CHECK(result.c == 10); return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_20byte1.c b/testsuite/libffi.closures/cls_20byte1.c index eab4be603..e6979b562 100644 --- a/testsuite/libffi.closures/cls_20byte1.c +++ b/testsuite/libffi.closures/cls_20byte1.c @@ -27,6 +27,19 @@ static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, printf("%d %g %g %d %g %g: %d %g %g\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 5); + CHECK(a2.c == 7); + + CHECK(result.a == 5); + CHECK(result.b == 7); + CHECK(result.c == 10); + return result; } @@ -81,6 +94,9 @@ int main (void) /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); @@ -89,5 +105,9 @@ int main (void) printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); + exit(0); } diff --git a/testsuite/libffi.closures/cls_24byte.c b/testsuite/libffi.closures/cls_24byte.c index 78796da92..b204966e7 100644 --- a/testsuite/libffi.closures/cls_24byte.c +++ b/testsuite/libffi.closures/cls_24byte.c @@ -33,6 +33,30 @@ cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0, b2.a, b2.b, b2.c, b2.d, b3.a, b3.b, b3.c, b3.d, result.a, result.b, result.c, result.d); + CHECK_DOUBLE_EQ(b0.a, 9); + CHECK_DOUBLE_EQ(b0.b, 2); + CHECK(b0.c == 6); + CHECK_FLOAT_EQ(b0.d, 5); + + CHECK_DOUBLE_EQ(b1.a, 1); + CHECK_DOUBLE_EQ(b1.b, 2); + CHECK(b1.c == 3); + CHECK_FLOAT_EQ(b1.d, 7); + + CHECK_DOUBLE_EQ(b2.a, 4); + CHECK_DOUBLE_EQ(b2.b, 5); + CHECK(b2.c == 7); + CHECK_FLOAT_EQ(b2.d, 9); + + CHECK_DOUBLE_EQ(b3.a, 8); + CHECK_DOUBLE_EQ(b3.b, 6); + CHECK(b3.c == 1); + CHECK_FLOAT_EQ(b3.d, 4); + + CHECK_DOUBLE_EQ(result.a, 22); + CHECK_DOUBLE_EQ(result.b, 15); + CHECK(result.c == 17); + CHECK_FLOAT_EQ(result.d, 25); return result; } @@ -97,6 +121,10 @@ int main (void) /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ + CHECK_DOUBLE_EQ(res_dbl.a, 22); + CHECK_DOUBLE_EQ(res_dbl.b, 15); + CHECK(res_dbl.c == 17); + CHECK_FLOAT_EQ(res_dbl.d, 25); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK); @@ -108,6 +136,10 @@ int main (void) /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ + CHECK_DOUBLE_EQ(res_dbl.a, 22); + CHECK_DOUBLE_EQ(res_dbl.b, 15); + CHECK(res_dbl.c == 17); + CHECK_FLOAT_EQ(res_dbl.d, 25); exit(0); } diff --git a/testsuite/libffi.closures/cls_2byte.c b/testsuite/libffi.closures/cls_2byte.c index 81bb0a64a..c5209b783 100644 --- a/testsuite/libffi.closures/cls_2byte.c +++ b/testsuite/libffi.closures/cls_2byte.c @@ -24,6 +24,15 @@ cls_struct_2byte cls_struct_2byte_fn(struct cls_struct_2byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 12); + CHECK(a1.b == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 13); + + CHECK(result.a == 13); + CHECK(result.b == 140); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "12 127 1 13: 13 140" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n12 127 1 13: 13 140" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_3_1byte.c b/testsuite/libffi.closures/cls_3_1byte.c index b7827466f..aaa7ccc5c 100644 --- a/testsuite/libffi.closures/cls_3_1byte.c +++ b/testsuite/libffi.closures/cls_3_1byte.c @@ -28,6 +28,18 @@ cls_struct_3_1byte cls_struct_3_1byte_fn(struct cls_struct_3_1byte a1, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 13); + CHECK(a1.c == 14); + + CHECK(a2.a == 178); + CHECK(a2.b == 179); + CHECK(a2.c == 180); + + CHECK(result.a == 190); + CHECK(result.b == 192); + CHECK(result.c == 194); + return result; } @@ -83,6 +95,9 @@ int main (void) /* { dg-output "12 13 14 178 179 180: 190 192 194" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 190 192 194" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK); @@ -91,5 +106,9 @@ int main (void) printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 190 192 194" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + exit(0); } diff --git a/testsuite/libffi.closures/cls_3byte1.c b/testsuite/libffi.closures/cls_3byte1.c index a02c463af..b42491754 100644 --- a/testsuite/libffi.closures/cls_3byte1.c +++ b/testsuite/libffi.closures/cls_3byte1.c @@ -24,6 +24,15 @@ cls_struct_3byte cls_struct_3byte_fn(struct cls_struct_3byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 12); + CHECK(a1.b == 119); + + CHECK(a2.a == 1); + CHECK(a2.b == 15); + + CHECK(result.a == 13); + CHECK(result.b == 134); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "12 119 1 15: 13 134" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 134" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 134); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n12 119 1 15: 13 134" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 134" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 134); exit(0); } diff --git a/testsuite/libffi.closures/cls_3byte2.c b/testsuite/libffi.closures/cls_3byte2.c index c7251cead..f13590e4b 100644 --- a/testsuite/libffi.closures/cls_3byte2.c +++ b/testsuite/libffi.closures/cls_3byte2.c @@ -24,6 +24,15 @@ cls_struct_3byte_1 cls_struct_3byte_fn1(struct cls_struct_3byte_1 a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 15); + CHECK(a1.b == 125); + + CHECK(a2.a == 9); + CHECK(a2.b == 19); + + CHECK(result.a == 24); + CHECK(result.b == 144); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "15 125 9 19: 24 144" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 24 144" } */ + CHECK(res_dbl.a == 24); + CHECK(res_dbl.b == 144); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n15 125 9 19: 24 144" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 24 144" } */ + CHECK(res_dbl.a == 24); + CHECK(res_dbl.b == 144); exit(0); } diff --git a/testsuite/libffi.closures/cls_3float.c b/testsuite/libffi.closures/cls_3float.c index 48888f840..63171bc7f 100644 --- a/testsuite/libffi.closures/cls_3float.c +++ b/testsuite/libffi.closures/cls_3float.c @@ -27,6 +27,18 @@ cls_struct_3float cls_struct_3float_fn(struct cls_struct_3float a1, printf("%g %g %g %g %g %g: %g %g %g\n", a1.f, a1.g, a1.h, a2.f, a2.g, a2.h, result.f, result.g, result.h); + CHECK_FLOAT_EQ(a1.f, 1); + CHECK_FLOAT_EQ(a1.g, 2); + CHECK_FLOAT_EQ(a1.h, 3); + + CHECK_FLOAT_EQ(a2.f, 1); + CHECK_FLOAT_EQ(a2.g, 2); + CHECK_FLOAT_EQ(a2.h, 3); + + CHECK_FLOAT_EQ(result.f, 2); + CHECK_FLOAT_EQ(result.g, 4); + CHECK_FLOAT_EQ(result.h, 6); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "1 2 3 1 2 3: 2 4 6" } */ printf("res: %g %g %g\n", res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 2 4 6" } */ + CHECK_FLOAT_EQ(res_dbl.f, 2); + CHECK_FLOAT_EQ(res_dbl.g, 4); + CHECK_FLOAT_EQ(res_dbl.h, 6); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3float_gn, NULL, code) == FFI_OK); @@ -90,6 +105,9 @@ int main (void) /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ printf("res: %g %g %g\n", res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 2 4 6" } */ + CHECK_FLOAT_EQ(res_dbl.f, 2); + CHECK_FLOAT_EQ(res_dbl.g, 4); + CHECK_FLOAT_EQ(res_dbl.h, 6); exit(0); } diff --git a/testsuite/libffi.closures/cls_4_1byte.c b/testsuite/libffi.closures/cls_4_1byte.c index 2d6d8b622..b5d3f7032 100644 --- a/testsuite/libffi.closures/cls_4_1byte.c +++ b/testsuite/libffi.closures/cls_4_1byte.c @@ -30,6 +30,20 @@ cls_struct_4_1byte cls_struct_4_1byte_fn(struct cls_struct_4_1byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 12); + CHECK(a1.b == 13); + CHECK(a1.c == 14); + CHECK(a1.d == 15); + + CHECK(a2.a == 178); + CHECK(a2.b == 179); + CHECK(a2.c == 180); + CHECK(a2.d == 181); + + CHECK(result.a == 190); + CHECK(result.b == 192); + CHECK(result.c == 194); + CHECK(result.d == 196); return result; } @@ -86,6 +100,10 @@ int main (void) /* { dg-output "12 13 14 15 178 179 180 181: 190 192 194 196" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 190 192 194 196" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + CHECK(res_dbl.d == 196); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK); @@ -93,6 +111,10 @@ int main (void) /* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 190 192 194 196" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + CHECK(res_dbl.d == 196); exit(0); } diff --git a/testsuite/libffi.closures/cls_4byte.c b/testsuite/libffi.closures/cls_4byte.c index 4ac378776..4f8d173bf 100644 --- a/testsuite/libffi.closures/cls_4byte.c +++ b/testsuite/libffi.closures/cls_4byte.c @@ -24,6 +24,15 @@ cls_struct_4byte cls_struct_4byte_fn(struct cls_struct_4byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + + CHECK(result.a == 139); + CHECK(result.b == 248); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "127 120 12 128: 139 248" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 139 248" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n127 120 12 128: 139 248" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 139 248" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); exit(0); } diff --git a/testsuite/libffi.closures/cls_5_1_byte.c b/testsuite/libffi.closures/cls_5_1_byte.c index 8db761cd5..07552cde7 100644 --- a/testsuite/libffi.closures/cls_5_1_byte.c +++ b/testsuite/libffi.closures/cls_5_1_byte.c @@ -32,6 +32,24 @@ static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, result.a, result.b, result.c, result.d, result.e); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + return result; } @@ -90,6 +108,11 @@ int main (void) printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 139 248 10 6 8" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); res_dbl.a = 0; res_dbl.b = 0; @@ -104,6 +127,11 @@ int main (void) printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 139 248 10 6 8" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); exit(0); } diff --git a/testsuite/libffi.closures/cls_5byte.c b/testsuite/libffi.closures/cls_5byte.c index fbb69ce4a..9f8936b59 100644 --- a/testsuite/libffi.closures/cls_5byte.c +++ b/testsuite/libffi.closures/cls_5byte.c @@ -27,6 +27,18 @@ static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + return result; } @@ -82,6 +94,9 @@ int main (void) /* { dg-output "127 120 1 12 128 9: 139 248 10" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 139 248 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); res_dbl.a = 0; res_dbl.b = 0; @@ -93,6 +108,9 @@ int main (void) /* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 139 248 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_64byte.c b/testsuite/libffi.closures/cls_64byte.c index a55edc2c7..5adedc944 100644 --- a/testsuite/libffi.closures/cls_64byte.c +++ b/testsuite/libffi.closures/cls_64byte.c @@ -38,6 +38,14 @@ cls_struct_64byte cls_struct_64byte_fn(struct cls_struct_64byte b0, printf("%g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, result.d, result.e, result.f, result.g, result.h); + CHECK(result.a == 22); + CHECK(result.b == 15); + CHECK(result.c == 17); + CHECK(result.d == 25); + CHECK(result.e == 6); + CHECK(result.f == 13); + CHECK(result.g == 19); + CHECK(result.h == 18); return result; } @@ -107,6 +115,14 @@ int main (void) printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + CHECK(res_dbl.a == 22); + CHECK(res_dbl.b == 15); + CHECK(res_dbl.c == 17); + CHECK(res_dbl.d == 25); + CHECK(res_dbl.e == 6); + CHECK(res_dbl.f == 13); + CHECK(res_dbl.g == 19); + CHECK(res_dbl.h == 18); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK); @@ -119,6 +135,14 @@ int main (void) printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + CHECK(res_dbl.a == 22); + CHECK(res_dbl.b == 15); + CHECK(res_dbl.c == 17); + CHECK(res_dbl.d == 25); + CHECK(res_dbl.e == 6); + CHECK(res_dbl.f == 13); + CHECK(res_dbl.g == 19); + CHECK(res_dbl.h == 18); exit(0); } diff --git a/testsuite/libffi.closures/cls_6_1_byte.c b/testsuite/libffi.closures/cls_6_1_byte.c index 797098628..05e2945b6 100644 --- a/testsuite/libffi.closures/cls_6_1_byte.c +++ b/testsuite/libffi.closures/cls_6_1_byte.c @@ -34,6 +34,27 @@ static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, result.a, result.b, result.c, result.d, result.e, result.f); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + CHECK(a1.f == 5); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + CHECK(a2.f == 5); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + CHECK(result.f == 10); + return result; } @@ -109,5 +130,11 @@ int main (void) res_dbl.d, res_dbl.e, res_dbl.f); /* { dg-output "\nres: 139 248 10 6 8 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_6byte.c b/testsuite/libffi.closures/cls_6byte.c index e89c73cf8..a8e3ea071 100644 --- a/testsuite/libffi.closures/cls_6byte.c +++ b/testsuite/libffi.closures/cls_6byte.c @@ -30,6 +30,21 @@ static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 128); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 127); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 255); + return result; } @@ -86,6 +101,10 @@ int main (void) /* { dg-output "127 120 1 128 12 128 9 127: 139 248 10 255" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 255" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 255); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); @@ -93,7 +112,10 @@ int main (void) /* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 255" } */ - + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_7_1_byte.c b/testsuite/libffi.closures/cls_7_1_byte.c index 94b1a44bd..3f1796483 100644 --- a/testsuite/libffi.closures/cls_7_1_byte.c +++ b/testsuite/libffi.closures/cls_7_1_byte.c @@ -36,6 +36,30 @@ static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, result.a, result.b, result.c, result.d, result.e, result.f, result.g); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + CHECK(a1.f == 5); + CHECK(a1.g == 6); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + CHECK(a2.f == 5); + CHECK(a2.g == 6); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + CHECK(result.f == 10); + CHECK(result.g == 12); + return result; } @@ -96,6 +120,13 @@ int main (void) printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); + CHECK(res_dbl.g == 12); res_dbl.a = 0; res_dbl.b = 0; @@ -112,6 +143,13 @@ int main (void) printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); + CHECK(res_dbl.g == 12); exit(0); } diff --git a/testsuite/libffi.closures/cls_7byte.c b/testsuite/libffi.closures/cls_7byte.c index 3aa8d6cfe..dcfc29b82 100644 --- a/testsuite/libffi.closures/cls_7byte.c +++ b/testsuite/libffi.closures/cls_7byte.c @@ -29,6 +29,22 @@ static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 254); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 255); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 509); + + return result; } @@ -85,6 +101,10 @@ int main (void) /* { dg-output "127 120 1 254 12 128 9 255: 139 248 10 509" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 509" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 509); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); @@ -92,6 +112,10 @@ int main (void) /* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 509" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 509); exit(0); } diff --git a/testsuite/libffi.closures/cls_8byte.c b/testsuite/libffi.closures/cls_8byte.c index f6c1ea570..7a519e95e 100644 --- a/testsuite/libffi.closures/cls_8byte.c +++ b/testsuite/libffi.closures/cls_8byte.c @@ -23,6 +23,15 @@ cls_struct_8byte cls_struct_8byte_fn(struct cls_struct_8byte a1, printf("%d %g %d %g: %d %g\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 1); + CHECK_FLOAT_EQ(a1.b, 2); + + CHECK(a2.a == 4); + CHECK_FLOAT_EQ(a2.b, 5); + + CHECK(result.a == 5); + CHECK_FLOAT_EQ(result.b, 7); + return result; } @@ -76,6 +85,9 @@ int main (void) ffi_call(&cif, FFI_FN(cls_struct_8byte_fn), &res_dbl, args_dbl); /* { dg-output "1 2 4 5: 5 7" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); + CHECK(res_dbl.a == 5); + CHECK_FLOAT_EQ(res_dbl.b, 7); + /* { dg-output "\nres: 5 7" } */ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK); @@ -83,6 +95,8 @@ int main (void) /* { dg-output "\n1 2 4 5: 5 7" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 5 7" } */ + CHECK(res_dbl.a == 5); + CHECK_FLOAT_EQ(res_dbl.b, 7); exit(0); } diff --git a/testsuite/libffi.closures/cls_9byte1.c b/testsuite/libffi.closures/cls_9byte1.c index 6eb452036..9d3b609d3 100644 --- a/testsuite/libffi.closures/cls_9byte1.c +++ b/testsuite/libffi.closures/cls_9byte1.c @@ -26,6 +26,15 @@ static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, printf("%d %g %d %g: %d %g\n", b1.a, b1.b, b2.a, b2.b, result.a, result.b); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + + CHECK(result.a == 8); + CHECK(result.b == 17); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "7 8 1 9: 8 17" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n7 8 1 9: 8 17" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); exit(0); } diff --git a/testsuite/libffi.closures/cls_9byte2.c b/testsuite/libffi.closures/cls_9byte2.c index 26e460bc7..6cfaaf397 100644 --- a/testsuite/libffi.closures/cls_9byte2.c +++ b/testsuite/libffi.closures/cls_9byte2.c @@ -26,6 +26,15 @@ static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b, result.a, result.b); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + + CHECK(result.a == 8); + CHECK(result.b == 17); + return result; } @@ -78,7 +87,8 @@ int main (void) /* { dg-output "7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ - + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); @@ -86,6 +96,8 @@ int main (void) /* { dg-output "\n7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_double.c b/testsuite/libffi.closures/cls_align_double.c index 910e2287d..036cca37f 100644 --- a/testsuite/libffi.closures/cls_align_double.c +++ b/testsuite/libffi.closures/cls_align_double.c @@ -26,6 +26,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -88,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_float.c b/testsuite/libffi.closures/cls_align_float.c index 56161ef63..c7dbdfd8f 100644 --- a/testsuite/libffi.closures/cls_align_float.c +++ b/testsuite/libffi.closures/cls_align_float.c @@ -24,6 +24,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + CHECK(a1.a == 12); + CHECK_FLOAT_EQ(a1.b, 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK_FLOAT_EQ(a2.b, 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK_FLOAT_EQ(result.b, 14271); + CHECK(result.c == 140); + return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK_FLOAT_EQ(res_dbl.b, 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK_FLOAT_EQ(res_dbl.b, 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble.c b/testsuite/libffi.closures/cls_align_longdouble.c index 3dccdef10..1cdb10bdb 100644 --- a/testsuite/libffi.closures/cls_align_longdouble.c +++ b/testsuite/libffi.closures/cls_align_longdouble.c @@ -25,6 +25,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -80,6 +92,10 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -87,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble_split.c b/testsuite/libffi.closures/cls_align_longdouble_split.c index 9b01cbd01..fe874c244 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split.c @@ -39,32 +39,34 @@ static cls_struct_align cls_struct_align_fn( a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, r.a, r.b, r.c, r.d, r.e, r.f, r.g); - return r; -} - -cls_struct_align cls_struct_align_fn2( - cls_struct_align a1) -{ - struct cls_struct_align r; - - r.a = a1.a + 1; - r.b = a1.b + 1; - r.c = a1.c + 1; - r.d = a1.d + 1; - r.e = a1.e + 1; - r.f = a1.f + 1; - r.g = a1.g + 1; - - printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg: " - "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - r.a, r.b, r.c, r.d, r.e, r.f, r.g); - + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + CHECK(a1.d == 4); + CHECK(a1.e == 5); + CHECK(a1.f == 6); + CHECK(a1.g == 7); + + CHECK(a2.a == 8); + CHECK(a2.b == 9); + CHECK(a2.c == 10); + CHECK(a2.d == 11); + CHECK(a2.e == 12); + CHECK(a2.f == 13); + CHECK(a2.g == 14); + + CHECK(r.a == 9); + CHECK(r.b == 11); + CHECK(r.c == 13); + CHECK(r.d == 15); + CHECK(r.e == 17); + CHECK(r.f == 19); + CHECK(r.g == 21); return r; } static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) { struct cls_struct_align a1, a2; @@ -119,6 +121,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -127,6 +136,12 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble_split2.c b/testsuite/libffi.closures/cls_align_longdouble_split2.c index 8a973e7a2..88d239dcf 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split2.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split2.c @@ -40,6 +40,30 @@ static cls_struct_align cls_struct_align_fn( a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, r.a, r.b, r.c, r.d, r.e, r.f, r.g); + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + CHECK(a1.d == 4); + CHECK(a1.e == 5); + CHECK(a1.f == 6); + CHECK(a1.g == 7); + + CHECK(a2.a == 8); + CHECK(a2.b == 9); + CHECK(a2.c == 10); + CHECK(a2.d == 11); + CHECK(a2.e == 12); + CHECK(a2.f == 13); + CHECK(a2.g == 14); + + CHECK(r.a == 9); + CHECK(r.b == 11); + CHECK(r.c == 13); + CHECK(r.d == 15); + CHECK(r.e == 17); + CHECK(r.f == 19); + CHECK(r.g == 21); + return r; } @@ -99,6 +123,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -107,7 +138,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_pointer.c b/testsuite/libffi.closures/cls_align_pointer.c index ef59259df..5fb3f09ac 100644 --- a/testsuite/libffi.closures/cls_align_pointer.c +++ b/testsuite/libffi.closures/cls_align_pointer.c @@ -28,6 +28,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.a, (uintptr_t)result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == (void *)4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == (void *)9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == (void *)14271); + CHECK(result.c == 140); + return result; } @@ -83,6 +95,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == (void *)14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -90,6 +105,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == (void *)14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint16.c b/testsuite/libffi.closures/cls_align_sint16.c index 79977093d..d2c9bf40f 100644 --- a/testsuite/libffi.closures/cls_align_sint16.c +++ b/testsuite/libffi.closures/cls_align_sint16.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,6 +90,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +100,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint32.c b/testsuite/libffi.closures/cls_align_sint32.c index 5edde7224..570f45ffd 100644 --- a/testsuite/libffi.closures/cls_align_sint32.c +++ b/testsuite/libffi.closures/cls_align_sint32.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,13 +90,17 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ - + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ - + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint64.c b/testsuite/libffi.closures/cls_align_sint64.c index bcba22f3e..49ee5612b 100644 --- a/testsuite/libffi.closures/cls_align_sint64.c +++ b/testsuite/libffi.closures/cls_align_sint64.c @@ -24,6 +24,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -80,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -87,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint16.c b/testsuite/libffi.closures/cls_align_uint16.c index f33c0ec68..2204dff92 100644 --- a/testsuite/libffi.closures/cls_align_uint16.c +++ b/testsuite/libffi.closures/cls_align_uint16.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,6 +90,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +100,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint32.c b/testsuite/libffi.closures/cls_align_uint32.c index c96eee6bb..1ce23daf5 100644 --- a/testsuite/libffi.closures/cls_align_uint32.c +++ b/testsuite/libffi.closures/cls_align_uint32.c @@ -24,6 +24,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint64.c b/testsuite/libffi.closures/cls_align_uint64.c index 958e1c2ca..aee958a86 100644 --- a/testsuite/libffi.closures/cls_align_uint64.c +++ b/testsuite/libffi.closures/cls_align_uint64.c @@ -26,6 +26,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -88,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_dbls_struct.c b/testsuite/libffi.closures/cls_dbls_struct.c index 25b8b6350..00e247e7e 100644 --- a/testsuite/libffi.closures/cls_dbls_struct.c +++ b/testsuite/libffi.closures/cls_dbls_struct.c @@ -17,6 +17,8 @@ void closure_test_fn(Dbls p) { printf("%.1f %.1f\n", p.x, p.y); + CHECK(p.x == 1); + CHECK(p.y == 2); } void diff --git a/testsuite/libffi.closures/cls_double_va.c b/testsuite/libffi.closures/cls_double_va.c index e077f92b8..6fc8dfb07 100644 --- a/testsuite/libffi.closures/cls_double_va.c +++ b/testsuite/libffi.closures/cls_double_va.c @@ -10,6 +10,9 @@ #include "ffitest.h" +#define BUF_SIZE 50 +static char buffer[BUF_SIZE]; + static void cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) @@ -18,6 +21,9 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, double doubleValue = *(double*)args[1]; *(ffi_arg*)resp = printf(format, doubleValue); + CHECK(*(ffi_arg*)resp == 4); + snprintf(buffer, BUF_SIZE, format, doubleValue); + CHECK(strncmp(buffer, "7.0\n", BUF_SIZE)); } int main (void) @@ -48,6 +54,7 @@ int main (void) /* { dg-output "7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK); @@ -56,6 +63,7 @@ int main (void) /* { dg-output "\n7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); exit(0); } diff --git a/testsuite/libffi.closures/cls_float.c b/testsuite/libffi.closures/cls_float.c index 0090fed90..97c2ac02b 100644 --- a/testsuite/libffi.closures/cls_float.c +++ b/testsuite/libffi.closures/cls_float.c @@ -14,6 +14,9 @@ static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%g: %g\n",*(float *)args[0], *(float *)resp); + + CHECK((int)(*(float *)args[0]) == -2122); + CHECK((int)(*(float *)resp) == -2122); } typedef float (*cls_ret_float)(float); @@ -38,5 +41,6 @@ int main (void) /* { dg-output "\\-2122.12: \\-2122.12" } */ printf("res: %.6f\n", res); /* { dg-output "\nres: \-2122.120117" } */ + CHECK((int)res == -2122); exit(0); } diff --git a/testsuite/libffi.closures/cls_longdouble.c b/testsuite/libffi.closures/cls_longdouble.c index d24e72e4a..2023172bd 100644 --- a/testsuite/libffi.closures/cls_longdouble.c +++ b/testsuite/libffi.closures/cls_longdouble.c @@ -25,6 +25,14 @@ long double cls_ldouble_fn( printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n", a1, a2, a3, a4, a5, a6, a7, a8, r); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 3); + CHECK(a4 == 4); + CHECK(a5 == 5); + CHECK(a6 == 6); + CHECK(a7 == 7); + CHECK(a8 == 8); return r; } @@ -91,6 +99,7 @@ int main(void) /* { dg-output "1 2 3 4 5 6 7 8: 36" } */ printf("res: %Lg\n", res); /* { dg-output "\nres: 36" } */ + CHECK(res == 36); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK); @@ -100,6 +109,7 @@ int main(void) /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */ printf("res: %Lg\n", res); /* { dg-output "\nres: 36" } */ + CHECK(res == 36); return 0; } diff --git a/testsuite/libffi.closures/cls_longdouble_va.c b/testsuite/libffi.closures/cls_longdouble_va.c index 39b438b28..79b42b0a2 100644 --- a/testsuite/libffi.closures/cls_longdouble_va.c +++ b/testsuite/libffi.closures/cls_longdouble_va.c @@ -10,6 +10,9 @@ #include "ffitest.h" +#define BUF_SIZE 50 +static char buffer[BUF_SIZE]; + static void cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) @@ -18,6 +21,9 @@ cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, long double ldValue = *(long double*)args[1]; *(ffi_arg*)resp = printf(format, ldValue); + CHECK(*(ffi_arg*)resp == 4); + snprintf(buffer, BUF_SIZE, format, ldValue); + CHECK(strncmp(buffer, "7.0\n", BUF_SIZE) == 0); } int main (void) @@ -48,6 +54,7 @@ int main (void) /* { dg-output "7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK); @@ -56,6 +63,7 @@ int main (void) /* { dg-output "\n7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_schar.c b/testsuite/libffi.closures/cls_multi_schar.c index 417f7be82..921777a0f 100644 --- a/testsuite/libffi.closures/cls_multi_schar.c +++ b/testsuite/libffi.closures/cls_multi_schar.c @@ -26,6 +26,8 @@ static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, a1 = *(signed char *)avals[0]; a2 = *(signed char *)avals[1]; + CHECK(a1 == 2); + CHECK(a2 == 125); *(ffi_arg *)rval = test_func_fn(a1, a2); @@ -62,6 +64,7 @@ int main (void) /* { dg-output "2 125: 127" } */ printf("res: %d\n", (signed char)res_call); /* { dg-output "\nres: 127" } */ + CHECK(res_call == 127); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -69,6 +72,7 @@ int main (void) /* { dg-output "\n2 125: 127" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 127" } */ + CHECK(res_closure == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_sshort.c b/testsuite/libffi.closures/cls_multi_sshort.c index 467146dbd..d78c62d2d 100644 --- a/testsuite/libffi.closures/cls_multi_sshort.c +++ b/testsuite/libffi.closures/cls_multi_sshort.c @@ -14,6 +14,9 @@ static signed short test_func_fn(signed short a1, signed short a2) result = a1 + a2; printf("%d %d: %d\n", a1, a2, result); + CHECK(a1 == 2); + CHECK(a2 == 32765); + CHECK(result == 32767); return result; @@ -62,6 +65,7 @@ int main (void) /* { dg-output "2 32765: 32767" } */ printf("res: %d\n", (unsigned short)res_call); /* { dg-output "\nres: 32767" } */ + CHECK(res_call == 32767); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -69,6 +73,7 @@ int main (void) /* { dg-output "\n2 32765: 32767" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32767" } */ + CHECK(res_closure == 32767); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_sshortchar.c b/testsuite/libffi.closures/cls_multi_sshortchar.c index de45b593e..a2b370873 100644 --- a/testsuite/libffi.closures/cls_multi_sshortchar.c +++ b/testsuite/libffi.closures/cls_multi_sshortchar.c @@ -16,6 +16,12 @@ static signed short test_func_fn(signed char a1, signed short a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 32765); + CHECK(a3 == 127); + CHECK(a4 == -128); + CHECK(result == 32765); + return result; } @@ -74,6 +80,7 @@ int main (void) /* { dg-output "1 32765 127 -128: 32765" } */ printf("res: %d\n", (signed short)res_call); /* { dg-output "\nres: 32765" } */ + CHECK(res_call == 32765); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -81,6 +88,7 @@ int main (void) /* { dg-output "\n1 32765 127 -128: 32765" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32765" } */ + CHECK(res_closure == 32765); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_uchar.c b/testsuite/libffi.closures/cls_multi_uchar.c index eb93e95e3..5d6ae7cd3 100644 --- a/testsuite/libffi.closures/cls_multi_uchar.c +++ b/testsuite/libffi.closures/cls_multi_uchar.c @@ -16,6 +16,12 @@ static unsigned char test_func_fn(unsigned char a1, unsigned char a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 127); + CHECK(a4 == 125); + CHECK(result == 255); + return result; } @@ -79,6 +85,7 @@ int main (void) /* { dg-output "1 2 127 125: 255" } */ printf("res: %d\n", (unsigned char)res_call); /* { dg-output "\nres: 255" } */ + CHECK(res_call == 255); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -86,6 +93,7 @@ int main (void) /* { dg-output "\n1 2 127 125: 255" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 255" } */ + CHECK(res_closure == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_ushort.c b/testsuite/libffi.closures/cls_multi_ushort.c index 0e5838df1..f61a62793 100644 --- a/testsuite/libffi.closures/cls_multi_ushort.c +++ b/testsuite/libffi.closures/cls_multi_ushort.c @@ -15,8 +15,11 @@ static unsigned short test_func_fn(unsigned short a1, unsigned short a2) printf("%d %d: %d\n", a1, a2, result); - return result; + CHECK(a1 == 2); + CHECK(a2 == 32765); + CHECK(result == 32767); + return result; } static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, @@ -69,6 +72,7 @@ int main (void) /* { dg-output "\n2 32765: 32767" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32767" } */ + CHECK(res_closure == 32767); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_ushortchar.c b/testsuite/libffi.closures/cls_multi_ushortchar.c index 69aedfe0d..3315c995f 100644 --- a/testsuite/libffi.closures/cls_multi_ushortchar.c +++ b/testsuite/libffi.closures/cls_multi_ushortchar.c @@ -16,6 +16,12 @@ static unsigned short test_func_fn(unsigned char a1, unsigned short a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 127); + CHECK(a4 == 128); + CHECK(result == 258); + return result; } @@ -74,6 +80,7 @@ int main (void) /* { dg-output "1 2 127 128: 258" } */ printf("res: %d\n", (unsigned short)res_call); /* { dg-output "\nres: 258" } */ + CHECK(res_call == 258); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -81,6 +88,7 @@ int main (void) /* { dg-output "\n1 2 127 128: 258" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 258" } */ + CHECK(res_closure == 258); exit(0); } diff --git a/testsuite/libffi.closures/cls_pointer.c b/testsuite/libffi.closures/cls_pointer.c index d82a87a71..73a4cba78 100644 --- a/testsuite/libffi.closures/cls_pointer.c +++ b/testsuite/libffi.closures/cls_pointer.c @@ -16,6 +16,10 @@ void* cls_pointer_fn(void* a1, void* a2) (unsigned int)(uintptr_t) a2, (unsigned int)(uintptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x12345678); + CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef); + CHECK((unsigned int)(uintptr_t) result == 0x9be02467); + return result; } @@ -69,6 +73,7 @@ int main (void) /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */ printf("res: 0x%08x\n", (unsigned int) res); /* { dg-output "\nres: 0x9be02467" } */ + CHECK(res == 0x9be02467); exit(0); } diff --git a/testsuite/libffi.closures/cls_pointer_stack.c b/testsuite/libffi.closures/cls_pointer_stack.c index 1f1d9157b..2054f2547 100644 --- a/testsuite/libffi.closures/cls_pointer_stack.c +++ b/testsuite/libffi.closures/cls_pointer_stack.c @@ -40,6 +40,10 @@ void* cls_pointer_fn2(void* a1, void* a2) (unsigned int)(uintptr_t) a2, (unsigned int)(uintptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x8acf1356); + CHECK((unsigned int)(uintptr_t) a2 == 0x01234567); + CHECK((unsigned int)(uintptr_t) result == 0x8bf258bd); + return result; } @@ -65,6 +69,10 @@ void* cls_pointer_fn1(void* a1, void* a2) (unsigned int)(intptr_t) a2, (unsigned int)(intptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x01234567); + CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef); + CHECK((unsigned int)(uintptr_t) result == 0x8acf1356); + result = cls_pointer_fn2(result, a1); return result; @@ -128,6 +136,7 @@ int main (void) /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ /* { dg-output "\nres: 0x8bf258bd" } */ + CHECK(res == 0x8bf258bd); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); @@ -137,6 +146,7 @@ int main (void) /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ /* { dg-output "\nres: 0x8bf258bd" } */ + CHECK(res == 0x8bf258bd); exit(0); } diff --git a/testsuite/libffi.closures/cls_schar.c b/testsuite/libffi.closures/cls_schar.c index 82986b172..22446c317 100644 --- a/testsuite/libffi.closures/cls_schar.c +++ b/testsuite/libffi.closures/cls_schar.c @@ -15,6 +15,8 @@ static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed char *)args[0]; printf("%d: %d\n",*(signed char *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed char *)args[0] == 127); + CHECK((int)*(ffi_arg *)(resp) == 127); } typedef signed char (*cls_ret_schar)(signed char); @@ -39,6 +41,7 @@ int main (void) /* { dg-output "127: 127" } */ printf("res: %d\n", res); /* { dg-output "\nres: 127" } */ + CHECK(res == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_sint.c b/testsuite/libffi.closures/cls_sint.c index c7e13b73a..a3f72c129 100644 --- a/testsuite/libffi.closures/cls_sint.c +++ b/testsuite/libffi.closures/cls_sint.c @@ -13,6 +13,8 @@ static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed int *)args[0]; printf("%d: %d\n",*(signed int *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed int *)args[0] == 65534); + CHECK((int)*(ffi_arg *)(resp) == 65534); } typedef signed int (*cls_ret_sint)(signed int); diff --git a/testsuite/libffi.closures/cls_sshort.c b/testsuite/libffi.closures/cls_sshort.c index 846d57ed1..8061a0296 100644 --- a/testsuite/libffi.closures/cls_sshort.c +++ b/testsuite/libffi.closures/cls_sshort.c @@ -13,6 +13,8 @@ static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed short *)args[0]; printf("%d: %d\n",*(signed short *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed short *)args[0] == 255); + CHECK((int)*(ffi_arg *)(resp) == 255); } typedef signed short (*cls_ret_sshort)(signed short); @@ -37,6 +39,7 @@ int main (void) /* { dg-output "255: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_struct_va1.c b/testsuite/libffi.closures/cls_struct_va1.c index 6d1fdaeb6..c59a27f3d 100644 --- a/testsuite/libffi.closures/cls_struct_va1.c +++ b/testsuite/libffi.closures/cls_struct_va1.c @@ -35,6 +35,16 @@ test_fn (ffi_cif* cif __UNUSED__, void* resp, 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); + CHECK(n == 4); + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l1.a == 10); + CHECK(l1.b == 11); + CHECK(l1.c == 12); + CHECK(l1.d == 13); + CHECK(l1.e == 14); + CHECK(s2.a == 20); + CHECK(s2.b == 21); * (ffi_arg*) resp = 42; } @@ -109,6 +119,7 @@ main (void) /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 42" } */ + CHECK(res == 42); exit(0); } diff --git a/testsuite/libffi.closures/cls_uchar.c b/testsuite/libffi.closures/cls_uchar.c index c1317e795..aa2023ffd 100644 --- a/testsuite/libffi.closures/cls_uchar.c +++ b/testsuite/libffi.closures/cls_uchar.c @@ -13,6 +13,8 @@ static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(unsigned char *)args[0]; printf("%d: %d\n",*(unsigned char *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(unsigned char *)args[0] == 127); + CHECK((int)*(ffi_arg *)(resp) == 127); } typedef unsigned char (*cls_ret_uchar)(unsigned char); @@ -37,6 +39,7 @@ int main (void) /* { dg-output "127: 127" } */ printf("res: %d\n",res); /* { dg-output "\nres: 127" } */ + CHECK(res == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_uint.c b/testsuite/libffi.closures/cls_uint.c index 885cff5c3..23b88de2d 100644 --- a/testsuite/libffi.closures/cls_uint.c +++ b/testsuite/libffi.closures/cls_uint.c @@ -14,6 +14,9 @@ static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%d: %d\n",*(unsigned int *)args[0], (int)*(ffi_arg *)(resp)); + + CHECK(*(unsigned int *)args[0] == 2147483647); + CHECK((int)*(ffi_arg *)(resp) == 2147483647); } typedef unsigned int (*cls_ret_uint)(unsigned int); @@ -38,6 +41,7 @@ int main (void) /* { dg-output "2147483647: 2147483647" } */ printf("res: %d\n",res); /* { dg-output "\nres: 2147483647" } */ + CHECK(res == 2147483647); exit(0); } diff --git a/testsuite/libffi.closures/cls_uint_va.c b/testsuite/libffi.closures/cls_uint_va.c index b04cfd19c..0048a02d4 100644 --- a/testsuite/libffi.closures/cls_uint_va.c +++ b/testsuite/libffi.closures/cls_uint_va.c @@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg *)resp = *(T *)args[0]; printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]); + CHECK(*(T *)args[0] == 67); + CHECK(*(T *)args[1] == 4); + CHECK((int)*(ffi_arg *)resp == 67); } typedef T (*cls_ret_T)(T, ...); @@ -41,5 +44,6 @@ int main (void) /* { dg-output "67: 67 4" } */ printf("res: %d\n", res); /* { dg-output "\nres: 67" } */ + CHECK(res == 67); exit(0); } diff --git a/testsuite/libffi.closures/cls_ulong_va.c b/testsuite/libffi.closures/cls_ulong_va.c index 0315082e0..79f41706a 100644 --- a/testsuite/libffi.closures/cls_ulong_va.c +++ b/testsuite/libffi.closures/cls_ulong_va.c @@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(T *)resp = *(T *)args[0]; printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + CHECK(*(T *)args[0] == 67); + CHECK(*(T *)args[1] == 4); + CHECK(*(T *)resp == 67); } typedef T (*cls_ret_T)(T, ...); @@ -41,5 +44,6 @@ int main (void) /* { dg-output "67: 67 4" } */ printf("res: %ld\n", res); /* { dg-output "\nres: 67" } */ + CHECK(res == 67); exit(0); } diff --git a/testsuite/libffi.closures/cls_ulonglong.c b/testsuite/libffi.closures/cls_ulonglong.c index 62f2cae63..813bb2eff 100644 --- a/testsuite/libffi.closures/cls_ulonglong.c +++ b/testsuite/libffi.closures/cls_ulonglong.c @@ -37,11 +37,13 @@ int main (void) /* { dg-output "214: 1152921504606846761" } */ printf("res: %" PRIdLL "\n", res); /* { dg-output "\nres: 1152921504606846761" } */ + CHECK(res == 1152921504606846761LL); res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ printf("res: %" PRIdLL "\n", res); /* { dg-output "\nres: 8070450533247928831" } */ + CHECK(res == 8070450533247928831LL); exit(0); } diff --git a/testsuite/libffi.closures/cls_ushort.c b/testsuite/libffi.closures/cls_ushort.c index a00100e07..bfe5e657c 100644 --- a/testsuite/libffi.closures/cls_ushort.c +++ b/testsuite/libffi.closures/cls_ushort.c @@ -14,6 +14,8 @@ static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%d: %d\n",*(unsigned short *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(unsigned short *)args[0] == 65535); + CHECK((int)*(ffi_arg *)(resp) == 65535); } typedef unsigned short (*cls_ret_ushort)(unsigned short); @@ -38,6 +40,7 @@ int main (void) /* { dg-output "65535: 65535" } */ printf("res: %d\n",res); /* { dg-output "\nres: 65535" } */ + CHECK(res == 65535); exit(0); } diff --git a/testsuite/libffi.closures/ffitest.h b/testsuite/libffi.closures/ffitest.h index 95d96a83f..53b009cdf 100644 --- a/testsuite/libffi.closures/ffitest.h +++ b/testsuite/libffi.closures/ffitest.h @@ -5,6 +5,9 @@ #include #include "fficonfig.h" +#include +#include + #if defined HAVE_STDINT_H #include #endif @@ -23,6 +26,22 @@ } \ } while(0) +#define CHECK_FLOAT_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > FLT_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + +#define CHECK_DOUBLE_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > DBL_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) diff --git a/testsuite/libffi.closures/huge_struct.c b/testsuite/libffi.closures/huge_struct.c index e8e1d8601..6dc631f3a 100644 --- a/testsuite/libffi.closures/huge_struct.c +++ b/testsuite/libffi.closures/huge_struct.c @@ -5,7 +5,7 @@ Originator: Blake Chaffin 6/18/2007 */ -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* wasm32*-*-* } } */ /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ /* { dg-options -Wformat=0 { target moxie*-*-elf or1k-*-* } } */ diff --git a/testsuite/libffi.closures/nested_struct.c b/testsuite/libffi.closures/nested_struct.c index 10797a345..8b1b4ba79 100644 --- a/testsuite/libffi.closures/nested_struct.c +++ b/testsuite/libffi.closures/nested_struct.c @@ -46,6 +46,29 @@ static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, result.d.a, result.d.b, result.d.c, result.e.ii, result.e.dd, result.e.ff); + CHECK_DOUBLE_EQ(b0.a, 9); + CHECK_FLOAT_EQ(b0.b, 2); + CHECK(b0.c == 6); + + CHECK(b1.ii == 1); + CHECK_DOUBLE_EQ(b1.dd, 2); + CHECK_FLOAT_EQ(b1.ff, 3); + + CHECK_DOUBLE_EQ(b2.d.a, 4); + CHECK_FLOAT_EQ(b2.d.b, 5); + CHECK(b2.d.c == 6); + + CHECK(b2.e.ii == 3); + CHECK_DOUBLE_EQ(b2.e.dd, 1); + CHECK_FLOAT_EQ(b2.e.ff, 8); + + CHECK_DOUBLE_EQ(result.d.a, 15); + CHECK_FLOAT_EQ(result.d.b, 10); + CHECK(result.d.c == 13); + CHECK(result.e.ii == 10); + CHECK_DOUBLE_EQ(result.e.dd, 12); + CHECK_FLOAT_EQ(result.e.ff, 13); + return result; } @@ -128,12 +151,12 @@ int main (void) ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b)); CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); @@ -142,11 +165,11 @@ int main (void) cls_struct_combined)) (code))(e_dbl, f_dbl, g_dbl); /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b)); CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); exit(0); } diff --git a/testsuite/libffi.closures/nested_struct10.c b/testsuite/libffi.closures/nested_struct10.c index 3cf2b44ab..a2cdc6494 100644 --- a/testsuite/libffi.closures/nested_struct10.c +++ b/testsuite/libffi.closures/nested_struct10.c @@ -38,6 +38,18 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK(b3.z == 255); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 270); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct11.c b/testsuite/libffi.closures/nested_struct11.c index 351049382..c9821e493 100644 --- a/testsuite/libffi.closures/nested_struct11.c +++ b/testsuite/libffi.closures/nested_struct11.c @@ -35,6 +35,13 @@ static C C_fn (int x, int y, int z, C source, int i, int j, int k) printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); + CHECK(x == 1); + CHECK(y == 1); + CHECK(z == 1); + CHECK(i == 1); + CHECK(j == 1); + CHECK(k == 1); + printf ("%.1f, %.1f, %.1f, %.1f, " "%.1f, %.1f, %.1f, %.1f\n", source.a.a_x, source.a.a_y, @@ -42,6 +49,15 @@ static C C_fn (int x, int y, int z, C source, int i, int j, int k) result.a.a_x, result.a.a_y, result.b.b_x, result.b.b_y); + CHECK_FLOAT_EQ(source.a.a_x, 1.0); + CHECK_FLOAT_EQ(source.a.a_y, 2.0); + CHECK_FLOAT_EQ(source.b.b_x, 4.0); + CHECK_FLOAT_EQ(source.b.b_y, 8.0); + CHECK_FLOAT_EQ(result.a.a_x, 1.0); + CHECK_FLOAT_EQ(result.a.a_y, 2.0); + CHECK_FLOAT_EQ(result.b.b_x, 4.0); + CHECK_FLOAT_EQ(result.b.b_y, 8.0); + return result; } @@ -113,9 +129,9 @@ int main (void) 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); + CHECK_FLOAT_EQ(result.a.a_x, source.a.a_x); + CHECK_FLOAT_EQ(result.a.a_y, source.a.a_y); + CHECK_FLOAT_EQ(result.b.b_x, source.b.b_x); + CHECK_FLOAT_EQ(result.b.b_y, source.b.b_y); + exit(0); } diff --git a/testsuite/libffi.closures/nested_struct12.c b/testsuite/libffi.closures/nested_struct12.c index 0d307ae91..7ca16c17d 100644 --- a/testsuite/libffi.closures/nested_struct12.c +++ b/testsuite/libffi.closures/nested_struct12.c @@ -75,7 +75,7 @@ int main (void) CHECK( ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, retType, args) == FFI_OK); ffi_call(&cif, FFI_FN(testNestedFloatStruct), &ts12_result, values); - CHECK(ts12_result == 138.2f); + CHECK_FLOAT_EQ(ts12_result, 138.2f); free(struct_float1); free(struct_float2); diff --git a/testsuite/libffi.closures/nested_struct13.c b/testsuite/libffi.closures/nested_struct13.c index 6c139b952..6edfdcbb5 100644 --- a/testsuite/libffi.closures/nested_struct13.c +++ b/testsuite/libffi.closures/nested_struct13.c @@ -27,6 +27,14 @@ B B_fn(float b0, struct B b1) printf("%g %g %g %g: %g %g %g\n", b0, b1.x, b1.y.a, b1.y.b, result.x, result.y.a, result.y.b); + CHECK_FLOAT_EQ(b0, 12.125); + CHECK_FLOAT_EQ(b1.x, 24.75); + CHECK_FLOAT_EQ(b1.y.a, 31.625); + CHECK_FLOAT_EQ(b1.y.b, 32.25); + CHECK_FLOAT_EQ(result.x, 36.875); + CHECK_FLOAT_EQ(result.y.a, 43.75); + CHECK_FLOAT_EQ(result.y.b, 44.375); + return result; } @@ -91,17 +99,17 @@ int main (void) ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); /* { dg-output "12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ - CHECK( res_dbl.x == (e_dbl + f_dbl.x)); - CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); - CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + CHECK_FLOAT_EQ( res_dbl.x, (e_dbl + f_dbl.x)); + CHECK_FLOAT_EQ( res_dbl.y.a, (e_dbl + f_dbl.y.a)); + CHECK_FLOAT_EQ( res_dbl.y.b, (e_dbl + f_dbl.y.b)); CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); res_dbl = ((B(*)(float, B))(code))(e_dbl, f_dbl); /* { dg-output "\n12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ - CHECK( res_dbl.x == (e_dbl + f_dbl.x)); - CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); - CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + CHECK_FLOAT_EQ( res_dbl.x, (e_dbl + f_dbl.x)); + CHECK_FLOAT_EQ( res_dbl.y.a, (e_dbl + f_dbl.y.a)); + CHECK_FLOAT_EQ( res_dbl.y.b, (e_dbl + f_dbl.y.b)); exit(0); } diff --git a/testsuite/libffi.closures/nested_struct2.c b/testsuite/libffi.closures/nested_struct2.c index d919e5c93..93a913d32 100644 --- a/testsuite/libffi.closures/nested_struct2.c +++ b/testsuite/libffi.closures/nested_struct2.c @@ -30,6 +30,15 @@ static B B_fn(struct A b0, struct B b1) printf("%lu %d %lu %d %d: %lu %d %d\n", b0.a, b0.b, b1.x.a, b1.x.b, b1.y, result.x.a, result.x.b, result.y); + CHECK(b0.a == 1); + CHECK(b0.b == 7); + CHECK(b1.x.a == 12); + CHECK(b1.x.b == 127); + CHECK(b1.y == 99); + CHECK(result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct3.c b/testsuite/libffi.closures/nested_struct3.c index 7d4c2cf80..d39a9ccfe 100644 --- a/testsuite/libffi.closures/nested_struct3.c +++ b/testsuite/libffi.closures/nested_struct3.c @@ -31,6 +31,15 @@ static B B_fn(struct A b0, struct B b1) (int)b1.x.a, b1.x.b, b1.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b0.a == 1); + CHECK(b0.b == 7); + CHECK((int)b1.x.a == 12); + CHECK(b1.x.b == 127); + CHECK(b1.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct4.c b/testsuite/libffi.closures/nested_struct4.c index 2ffb4d65a..d5c960dce 100644 --- a/testsuite/libffi.closures/nested_struct4.c +++ b/testsuite/libffi.closures/nested_struct4.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct5.c b/testsuite/libffi.closures/nested_struct5.c index 6c79845d9..b053f52b0 100644 --- a/testsuite/libffi.closures/nested_struct5.c +++ b/testsuite/libffi.closures/nested_struct5.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct6.c b/testsuite/libffi.closures/nested_struct6.c index 59d35796f..690ec0be8 100644 --- a/testsuite/libffi.closures/nested_struct6.c +++ b/testsuite/libffi.closures/nested_struct6.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct7.c b/testsuite/libffi.closures/nested_struct7.c index 27595e6f5..b3ddd030d 100644 --- a/testsuite/libffi.closures/nested_struct7.c +++ b/testsuite/libffi.closures/nested_struct7.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct8.c b/testsuite/libffi.closures/nested_struct8.c index 0e6c68281..768f3331b 100644 --- a/testsuite/libffi.closures/nested_struct8.c +++ b/testsuite/libffi.closures/nested_struct8.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct9.c b/testsuite/libffi.closures/nested_struct9.c index 5f7ac6775..f88ab0a94 100644 --- a/testsuite/libffi.closures/nested_struct9.c +++ b/testsuite/libffi.closures/nested_struct9.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) b3.x.a, (int)b3.x.b, b3.y, (int)b4.d, b4.e, result.x.a, (int)result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/testclosure.c b/testsuite/libffi.closures/testclosure.c index 600368e0c..e738a01fb 100644 --- a/testsuite/libffi.closures/testclosure.c +++ b/testsuite/libffi.closures/testclosure.c @@ -20,6 +20,11 @@ static void cls_struct_combined_fn(struct cls_struct_combined arg) arg.a, arg.b, arg.c, arg.d); fflush(stdout); + + CHECK_FLOAT_EQ(arg.a, 4); + CHECK_FLOAT_EQ(arg.b, 5); + CHECK_FLOAT_EQ(arg.c, 1); + CHECK_FLOAT_EQ(arg.d, 8); } static void From 4ed23be8e2a59e438c201ca1ba5affc0b0477b15 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 11:08:01 -0400 Subject: [PATCH 217/231] Fix test check --- testsuite/libffi.call/return_sl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/return_sl.c b/testsuite/libffi.call/return_sl.c index 4fe5e9a4b..337236f6b 100644 --- a/testsuite/libffi.call/return_sl.c +++ b/testsuite/libffi.call/return_sl.c @@ -36,7 +36,7 @@ int main (void) printf("res: %ld, %ld\n", (long)res, l1 - l2); /* { dg-output "res: -1, -1" } */ CHECK(res == -1); - CHECK(l1 - l2 == -1); + CHECK(l1 + 1 == l2); exit(0); } From c96b057757446fe4277f30e8423f09851ae5d0fa Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 11:16:39 -0400 Subject: [PATCH 218/231] Fix test check --- testsuite/libffi.call/return_sl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/return_sl.c b/testsuite/libffi.call/return_sl.c index 337236f6b..51bfb4945 100644 --- a/testsuite/libffi.call/return_sl.c +++ b/testsuite/libffi.call/return_sl.c @@ -35,7 +35,7 @@ int main (void) ffi_call(&cif, FFI_FN(return_sl), &res, values); printf("res: %ld, %ld\n", (long)res, l1 - l2); /* { dg-output "res: -1, -1" } */ - CHECK(res == -1); + CHECK((long)res == -1); CHECK(l1 + 1 == l2); exit(0); From 8bcf594749882e9e4966fec2e3d6009d08a554ab Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 11:26:02 -0400 Subject: [PATCH 219/231] Fix test case --- testsuite/libffi.closures/cls_multi_uchar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.closures/cls_multi_uchar.c b/testsuite/libffi.closures/cls_multi_uchar.c index 5d6ae7cd3..76f90a024 100644 --- a/testsuite/libffi.closures/cls_multi_uchar.c +++ b/testsuite/libffi.closures/cls_multi_uchar.c @@ -85,7 +85,7 @@ int main (void) /* { dg-output "1 2 127 125: 255" } */ printf("res: %d\n", (unsigned char)res_call); /* { dg-output "\nres: 255" } */ - CHECK(res_call == 255); + CHECK((unsigned char)res_call == 255); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); From 7db17442a6c9f1399065748b7d5b9fbcac203344 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 11:30:01 -0400 Subject: [PATCH 220/231] Don't check the whole buffer, just what we printed. --- testsuite/libffi.closures/cls_double_va.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/libffi.closures/cls_double_va.c b/testsuite/libffi.closures/cls_double_va.c index 6fc8dfb07..c1e29ec93 100644 --- a/testsuite/libffi.closures/cls_double_va.c +++ b/testsuite/libffi.closures/cls_double_va.c @@ -14,7 +14,7 @@ static char buffer[BUF_SIZE]; static void -cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, +cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) { char* format = *(char**)args[0]; @@ -23,7 +23,7 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, *(ffi_arg*)resp = printf(format, doubleValue); CHECK(*(ffi_arg*)resp == 4); snprintf(buffer, BUF_SIZE, format, doubleValue); - CHECK(strncmp(buffer, "7.0\n", BUF_SIZE)); + CHECK(strncmp(buffer, "7.0\n", 4)); } int main (void) From be0b3b6e75d4890fe18ba4164b91387beaebee06 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 16 Jul 2021 21:51:03 -0400 Subject: [PATCH 221/231] Fix CHECK --- testsuite/libffi.closures/cls_double_va.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.closures/cls_double_va.c b/testsuite/libffi.closures/cls_double_va.c index c1e29ec93..a6c445b82 100644 --- a/testsuite/libffi.closures/cls_double_va.c +++ b/testsuite/libffi.closures/cls_double_va.c @@ -23,7 +23,7 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, *(ffi_arg*)resp = printf(format, doubleValue); CHECK(*(ffi_arg*)resp == 4); snprintf(buffer, BUF_SIZE, format, doubleValue); - CHECK(strncmp(buffer, "7.0\n", 4)); + CHECK(strncmp(buffer, "7.0\n", 4) == 0); } int main (void) From 07f826fdd4d8a23a190f107f7ec6ad830a4864a0 Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Sun, 25 Jul 2021 02:39:37 +0100 Subject: [PATCH 222/231] Fix trampoline_code_table for x32. (#657) x32's struct tramp_parm has 32-bit pointers. This change adjusts the loads and offsets accordingly. --- src/x86/unix64.S | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/x86/unix64.S b/src/x86/unix64.S index ca6fe0cb4..8cf3a2396 100644 --- a/src/x86/unix64.S +++ b/src/x86/unix64.S @@ -505,11 +505,19 @@ C(ffi_closure_unix64_alt): * - restore the stack pointer to what it was when the trampoline was invoked. */ #ifdef ENDBR_PRESENT -#define X86_DATA_OFFSET 4077 -#define X86_CODE_OFFSET 4073 +# define X86_DATA_OFFSET 4077 +# ifdef __ILP32__ +# define X86_CODE_OFFSET 4069 +# else +# define X86_CODE_OFFSET 4073 +# endif #else -#define X86_DATA_OFFSET 4081 -#define X86_CODE_OFFSET 4077 +# define X86_DATA_OFFSET 4081 +# ifdef __ILP32__ +# define X86_CODE_OFFSET 4073 +# else +# define X86_CODE_OFFSET 4077 +# endif #endif .align UNIX64_TRAMP_MAP_SIZE @@ -521,9 +529,17 @@ C(trampoline_code_table): _CET_ENDBR subq $16, %rsp /* Make space on the stack */ movq %r10, (%rsp) /* Save %r10 on stack */ +#ifdef __ILP32__ + movl X86_DATA_OFFSET(%rip), %r10d /* Copy data into %r10 */ +#else movq X86_DATA_OFFSET(%rip), %r10 /* Copy data into %r10 */ +#endif movq %r10, 8(%rsp) /* Save data on stack */ +#ifdef __ILP32__ + movl X86_CODE_OFFSET(%rip), %r10d /* Copy code into %r10 */ +#else movq X86_CODE_OFFSET(%rip), %r10 /* Copy code into %r10 */ +#endif jmp *%r10 /* Jump to code */ .align 8 .endr From 68485e33a413c3d91fbfd7ec270803ae6bd3d3db Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 07:13:35 -0400 Subject: [PATCH 223/231] Mention x32 static tramponline fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 327f4e317..13871b627 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ History See the git log for details at http://github.com/libffi/libffi. 3.4.3 TBD - TBD + Fix x32 static trampolines. 3.4.2 Jun-28-21 Add static trampoline support for Linux on x86_64 and ARM64. From 43e4ad4d7b4bcc87ee447736a1172b2801a47908 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 07:55:59 -0400 Subject: [PATCH 224/231] Test passing structs by value --- testsuite/libffi.call/struct_by_value_big.c | 93 +++++++++++++++++++ testsuite/libffi.call/struct_by_value_small.c | 61 ++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 testsuite/libffi.call/struct_by_value_big.c create mode 100644 testsuite/libffi.call/struct_by_value_small.c diff --git a/testsuite/libffi.call/struct_by_value_big.c b/testsuite/libffi.call/struct_by_value_big.c new file mode 100644 index 000000000..06422cac2 --- /dev/null +++ b/testsuite/libffi.call/struct_by_value_big.c @@ -0,0 +1,93 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned int ui01; + unsigned int ui02; + unsigned int ui03; + unsigned int ui04; + unsigned int ui05; + unsigned int ui06; + unsigned int ui07; + unsigned int ui08; + unsigned int ui09; + unsigned int ui10; + unsigned int ui11; + unsigned int ui12; + unsigned int ui13; + unsigned int ui14; + unsigned int ui15; + unsigned int ui16; + unsigned int ui17; +} test_structure_1; + +static test_structure_1 ABI_ATTR struct1(test_structure_1 ts) +{ + ts.ui17++; + + 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[18]; + + test_structure_1 ts1_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_1 *ts1_result = + (test_structure_1 *) malloc (sizeof(test_structure_1)); + + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + ts1_type_elements[0] = &ffi_type_uint; + ts1_type_elements[1] = &ffi_type_uint; + ts1_type_elements[2] = &ffi_type_uint; + ts1_type_elements[3] = &ffi_type_uint; + ts1_type_elements[4] = &ffi_type_uint; + ts1_type_elements[5] = &ffi_type_uint; + ts1_type_elements[6] = &ffi_type_uint; + ts1_type_elements[7] = &ffi_type_uint; + ts1_type_elements[8] = &ffi_type_uint; + ts1_type_elements[9] = &ffi_type_uint; + ts1_type_elements[10] = &ffi_type_uint; + ts1_type_elements[11] = &ffi_type_uint; + ts1_type_elements[12] = &ffi_type_uint; + ts1_type_elements[13] = &ffi_type_uint; + ts1_type_elements[14] = &ffi_type_uint; + ts1_type_elements[15] = &ffi_type_uint; + ts1_type_elements[16] = &ffi_type_uint; + ts1_type_elements[17] = NULL; + + args[0] = &ts1_type; + values[0] = &ts1_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, + &ts1_type, args) == FFI_OK); + + ts1_arg.ui17 = 555; + + ffi_call(&cif, FFI_FN(struct1), ts1_result, values); + + CHECK(ts1_result->ui17 == 556); + + /* This will fail if ffi_call isn't passing the struct by value. */ + CHECK(ts1_arg.ui17 == 555); + + free (ts1_result); + exit(0); +} diff --git a/testsuite/libffi.call/struct_by_value_small.c b/testsuite/libffi.call/struct_by_value_small.c new file mode 100644 index 000000000..19613f8b0 --- /dev/null +++ b/testsuite/libffi.call/struct_by_value_small.c @@ -0,0 +1,61 @@ +/* Area: ffi_call + Purpose: Check structures. + Limitations: none. + PR: none. + Originator: From the original ffitest.c */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct +{ + unsigned int ui17; +} test_structure_1; + +static test_structure_1 ABI_ATTR struct1(test_structure_1 ts) +{ + ts.ui17++; + + 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[2]; + + test_structure_1 ts1_arg; + + /* This is a hack to get a properly aligned result buffer */ + test_structure_1 *ts1_result = + (test_structure_1 *) malloc (sizeof(test_structure_1)); + + ts1_type.size = 0; + ts1_type.alignment = 0; + ts1_type.type = FFI_TYPE_STRUCT; + ts1_type.elements = ts1_type_elements; + ts1_type_elements[0] = &ffi_type_uint; + ts1_type_elements[1] = NULL; + + args[0] = &ts1_type; + values[0] = &ts1_arg; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, + &ts1_type, args) == FFI_OK); + + ts1_arg.ui17 = 555; + + ffi_call(&cif, FFI_FN(struct1), ts1_result, values); + + CHECK(ts1_result->ui17 == 556); + + /* This will fail if ffi_call isn't passing the struct by value. */ + CHECK(ts1_arg.ui17 == 555); + + free (ts1_result); + exit(0); +} From 339acf3d8f049d296dafac3f482c1b7db29c0bae Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 08:38:18 -0400 Subject: [PATCH 225/231] Debug cross-in-containers builds --- .ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/build.sh b/.ci/build.sh index a6389770e..a46e5173c 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -67,7 +67,7 @@ function build_cross_linux() function build_cross() { ${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST} - ${DOCKER} run --rm -t -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e RUNNER_WORKSPACE=/opt -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.ci/build-cross-in-container.sh + ${DOCKER} run --rm -t -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e RUNNER_WORKSPACE=/opt -e RUNTESTFLAGS="-vv ${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.ci/build-cross-in-container.sh ./rlgl l --key=${RLGL_KEY} https://rl.gl ID=$(./rlgl start) From a04f57bce057604f38bb7c1bf32b7f671d2b56d5 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 08:47:53 -0400 Subject: [PATCH 226/231] Fix m32r testing --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d504734f..4f28687a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: - HOST: "or1k-elf" RUNTESTFLAGS: "--target_board or1k-sim" - HOST: "m32r-elf" - RUNTESTFLAGS: "--target_board m32-sim" + RUNTESTFLAGS: "--target_board m32r-sim" - HOST: "bfin-elf" RUNTESTFLAGS: "--target_board bfin-sim" - MEVAL: "export PATH=/opt/moxielogic/bin:$PATH && CC=moxie-elf-gcc && CXX=moxie-elf-g++" From 7643c6ee68e376810b4185e5f38e156c97bcc090 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 08:51:35 -0400 Subject: [PATCH 227/231] Try to fix ARM QEMU tests --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f28687a7..be17c34bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,10 +41,13 @@ jobs: QEMU_LD_PREFIX: "/usr/alpha-linux-gnu" - HOST: "arm32v7-linux-gnu" LIBFFI_TEST_OPTIMIZATION: "-O0" + QEMU_CPU: 'any' - HOST: "arm32v7-linux-gnu" LIBFFI_TEST_OPTIMIZATION: "-O2" + QEMU_CPU: 'any' - HOST: "arm32v7-linux-gnu" LIBFFI_TEST_OPTIMIZATION: "-O2 -fomit-frame-pointer" + QEMU_CPU: 'any' - HOST: "powerpc-eabisim" RUNTESTFLAGS: "--target_board powerpc-eabisim" - HOST: "or1k-elf" From 4ac18f26ed16588377b1482208212aaa39624e21 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 10:01:40 -0400 Subject: [PATCH 228/231] Add alpha CPU --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be17c34bd..1373a174e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: - HOST: "alpha-linux-gnu" CONFIGURE_OPTIONS: "--disable-shared" QEMU_LD_PREFIX: "/usr/alpha-linux-gnu" + QEMU_CPU: 'ev4-alpha-cpu' - HOST: "arm32v7-linux-gnu" LIBFFI_TEST_OPTIMIZATION: "-O0" QEMU_CPU: 'any' From 03596285ed36b94bb3e1d8bdebfe58590e2766df Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 10:16:42 -0400 Subject: [PATCH 229/231] No more xfail for alpha --- testsuite/libffi.call/va_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/libffi.call/va_2.c b/testsuite/libffi.call/va_2.c index cb88db9af..75d4dfc3d 100644 --- a/testsuite/libffi.call/va_2.c +++ b/testsuite/libffi.call/va_2.c @@ -5,7 +5,7 @@ Originator: ARM Ltd. */ /* { dg-do run } */ -/* { dg-output "" { xfail avr32*-*-* m68k-*-* alpha-*-* } } */ +/* { dg-output "" { xfail avr32*-*-* m68k-*-* } } */ #include "ffitest.h" #include From 86d5ecc5e84fbbc79fcff6a307310630d9d68549 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 16:58:32 -0400 Subject: [PATCH 230/231] Fix struct arg passing --- src/moxie/ffi.c | 53 +++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/moxie/ffi.c b/src/moxie/ffi.c index 16d2bb37c..696581a63 100644 --- a/src/moxie/ffi.c +++ b/src/moxie/ffi.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- - ffi.c - Copyright (C) 2012, 2013, 2018 Anthony Green - - Moxie Foreign Function Interface + ffi.c - Copyright (C) 2012, 2013, 2018, 2021 Anthony Green + + Moxie Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -54,14 +54,14 @@ void *ffi_prep_args(char *stack, extended_cif *ecif) i--, p_arg++) { size_t z; - + z = (*p_arg)->size; if ((*p_arg)->type == FFI_TYPE_STRUCT) { z = sizeof(void*); *(void **) argp = *p_argv; - } + } else if (z < sizeof(int)) { z = sizeof(int); @@ -70,19 +70,19 @@ void *ffi_prep_args(char *stack, extended_cif *ecif) case FFI_TYPE_SINT8: *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); break; - + case FFI_TYPE_UINT8: *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); break; - + case FFI_TYPE_SINT16: *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); break; - + case FFI_TYPE_UINT16: *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); break; - + default: FFI_ASSERT(0); } @@ -116,26 +116,26 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) return FFI_OK; } -extern void ffi_call_EABI(void *(*)(char *, extended_cif *), - extended_cif *, - unsigned, unsigned, - unsigned *, +extern void ffi_call_EABI(void *(*)(char *, extended_cif *), + extended_cif *, + unsigned, unsigned, + unsigned *, void (*fn)(void)); -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, +void ffi_call(ffi_cif *cif, + void (*fn)(void), + void *rvalue, void **avalue) { extended_cif ecif; ecif.cif = cif; ecif.avalue = avalue; - + /* If the return value is a struct and we don't have a return */ /* value address then we need to make one */ - if ((rvalue == NULL) && + if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) { ecif.rvalue = alloca(cif->rtype->size); @@ -143,10 +143,10 @@ void ffi_call(ffi_cif *cif, else ecif.rvalue = rvalue; - switch (cif->abi) + switch (cif->abi) { case FFI_EABI: - ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, + ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, fn); break; default: @@ -172,7 +172,7 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, void *struct_rvalue = (void *) arg1; /* 6 words reserved for register args + 3 words from jsr */ - char *stack_args = frame_pointer + 9*4; + char *stack_args = frame_pointer + 9*4; /* Lay the register arguments down in a continuous chunk of memory. */ unsigned register_args[6] = @@ -211,7 +211,16 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, avalue[i] = ptr; break; case FFI_TYPE_STRUCT: - avalue[i] = *(void**)ptr; + { + if (arg_types[i]->type->size > 4) + { + void *copy = alloca(arg_types[i]->type->size); + memcpy(copy, *(void**)ptr, arg_types[i]->type->size); + avalue[i] = copy; + } + else + avalue[i] = *(void**)ptr; + } break; default: /* This is an 8-byte value. */ From ee1263f7d43bd29b15fc72c4d9520a824e8004df Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 29 Jul 2021 17:46:17 -0400 Subject: [PATCH 231/231] Fix 'type'-o --- src/moxie/ffi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/moxie/ffi.c b/src/moxie/ffi.c index 696581a63..1a65660cf 100644 --- a/src/moxie/ffi.c +++ b/src/moxie/ffi.c @@ -212,10 +212,10 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3, break; case FFI_TYPE_STRUCT: { - if (arg_types[i]->type->size > 4) + if (arg_types[i]->size > 4) { - void *copy = alloca(arg_types[i]->type->size); - memcpy(copy, *(void**)ptr, arg_types[i]->type->size); + void *copy = alloca(arg_types[i]->size); + memcpy(copy, *(void**)ptr, arg_types[i]->size); avalue[i] = copy; } else