ffi 1.9.25 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +212 -0
- data/Gemfile +3 -4
- data/README.md +38 -18
- data/Rakefile +55 -146
- data/ext/ffi_c/AbstractMemory.c +29 -34
- data/ext/ffi_c/Buffer.c +4 -9
- data/ext/ffi_c/Call.c +16 -49
- data/ext/ffi_c/Call.h +4 -7
- data/ext/ffi_c/ClosurePool.c +75 -25
- data/ext/ffi_c/ClosurePool.h +3 -1
- data/ext/ffi_c/DynamicLibrary.c +2 -7
- data/ext/ffi_c/Function.c +47 -131
- data/ext/ffi_c/Function.h +0 -4
- data/ext/ffi_c/FunctionInfo.c +3 -8
- data/ext/ffi_c/LastError.c +49 -8
- data/ext/ffi_c/LongDouble.c +12 -10
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +3 -8
- data/ext/ffi_c/MemoryPointer.h +0 -4
- data/ext/ffi_c/MethodHandle.c +21 -31
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +3 -54
- data/ext/ffi_c/Pointer.c +25 -26
- data/ext/ffi_c/Pointer.h +0 -4
- data/ext/ffi_c/Struct.c +49 -56
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructByValue.c +2 -7
- data/ext/ffi_c/StructLayout.c +22 -20
- data/ext/ffi_c/Thread.c +4 -228
- data/ext/ffi_c/Thread.h +1 -20
- data/ext/ffi_c/Type.c +1 -19
- data/ext/ffi_c/Type.h +0 -1
- data/ext/ffi_c/Types.c +7 -8
- data/ext/ffi_c/Types.h +3 -4
- data/ext/ffi_c/Variadic.c +23 -24
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +53 -30
- data/ext/ffi_c/ffi.c +3 -8
- data/ext/ffi_c/libffi.darwin.mk +1 -1
- data/ext/ffi_c/libffi/.appveyor.yml +29 -13
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.travis.yml +51 -2
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
- data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
- data/ext/ffi_c/libffi/.travis/build.sh +116 -8
- data/ext/ffi_c/libffi/.travis/install.sh +65 -16
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/site.exp +10 -1
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
- data/ext/ffi_c/libffi/Makefile.am +56 -72
- data/ext/ffi_c/libffi/README.md +33 -8
- data/ext/ffi_c/libffi/config.guess +552 -331
- data/ext/ffi_c/libffi/config.sub +1321 -1306
- data/ext/ffi_c/libffi/configure.ac +37 -12
- data/ext/ffi_c/libffi/configure.host +56 -27
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
- data/ext/ffi_c/libffi/doc/version.texi +4 -0
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
- data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
- data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
- data/ext/ffi_c/libffi/msvcc.sh +38 -13
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
- data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/closures.c +69 -14
- data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
- data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
- data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
- data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
- data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
- data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
- data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
- data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
- data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
- data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
- data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
- data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
- data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
- data/ext/ffi_c/rbffi.h +0 -2
- data/ffi.gemspec +13 -6
- data/lib/ffi.rb +10 -2
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +1 -1
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/io.rb +3 -3
- data/lib/ffi/library.rb +12 -8
- data/lib/ffi/managedstruct.rb +2 -2
- data/lib/ffi/platform.rb +34 -10
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
- data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/arm-linux/types.conf +110 -82
- data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
- data/lib/ffi/platform/i386-darwin/types.conf +63 -63
- data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
- data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +84 -84
- data/lib/ffi/platform/i386-linux/types.conf +77 -77
- data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
- data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
- data/lib/ffi/platform/i386-solaris/types.conf +96 -96
- data/lib/ffi/platform/i386-windows/types.conf +43 -96
- data/lib/ffi/platform/ia64-linux/types.conf +79 -79
- data/lib/ffi/platform/mips-linux/types.conf +79 -79
- data/lib/ffi/platform/mips64-linux/types.conf +81 -81
- data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
- data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
- data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
- data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
- data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
- data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
- data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +79 -79
- data/lib/ffi/platform/s390x-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
- data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
- data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
- data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
- data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
- data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
- data/lib/ffi/pointer.rb +26 -20
- data/lib/ffi/struct.rb +13 -68
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/tools/const_generator.rb +5 -4
- data/lib/ffi/tools/generator.rb +47 -2
- data/lib/ffi/tools/generator_task.rb +13 -17
- data/lib/ffi/tools/struct_generator.rb +4 -4
- data/lib/ffi/tools/types_generator.rb +7 -4
- data/lib/ffi/types.rb +1 -1
- data/lib/ffi/variadic.rb +1 -10
- data/lib/ffi/version.rb +1 -1
- data/rakelib/ffi_gem_helper.rb +65 -0
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +160 -122
- data/.gitignore +0 -22
- data/.gitmodules +0 -3
- data/.travis.yml +0 -52
- data/.yardopts +0 -5
- data/appveyor.yml +0 -22
- data/ext/ffi_c/DataConverter.c +0 -91
- data/ext/ffi_c/StructByReference.c +0 -190
- data/ext/ffi_c/StructByReference.h +0 -50
- data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
- data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
- data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
- data/ext/ffi_c/win32/stdbool.h +0 -8
- data/ext/ffi_c/win32/stdint.h +0 -201
- data/samples/sample_helper.rb +0 -6
@@ -129,7 +129,9 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
|
|
129
129
|
cif->rtype = rtype;
|
130
130
|
|
131
131
|
cif->flags = 0;
|
132
|
-
|
132
|
+
#if (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32)
|
133
|
+
cif->is_variadic = isvariadic;
|
134
|
+
#endif
|
133
135
|
#if HAVE_LONG_DOUBLE_VARIANT
|
134
136
|
ffi_prep_types (abi);
|
135
137
|
#endif
|
@@ -199,7 +201,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
|
|
199
201
|
bytes = 6*4;
|
200
202
|
#endif
|
201
203
|
|
202
|
-
bytes += STACK_ARG_SIZE((*ptr)->size);
|
204
|
+
bytes += (unsigned int)STACK_ARG_SIZE((*ptr)->size);
|
203
205
|
}
|
204
206
|
#endif
|
205
207
|
}
|
@@ -324,9 +324,12 @@ ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsig
|
|
324
324
|
}
|
325
325
|
|
326
326
|
/* Low level routine for calling functions */
|
327
|
-
extern void ffi_call_asm(void *stack, struct call_context *regs,
|
327
|
+
extern void ffi_call_asm (void *stack, struct call_context *regs,
|
328
|
+
void (*fn) (void), void *closure) FFI_HIDDEN;
|
328
329
|
|
329
|
-
|
330
|
+
static void
|
331
|
+
ffi_call_int (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
|
332
|
+
void *closure)
|
330
333
|
{
|
331
334
|
/* this is a conservative estimate, assuming a complex return value and
|
332
335
|
that all remaining arguments are long long / __int128 */
|
@@ -366,13 +369,26 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
366
369
|
for (i = 0; i < cif->nargs; i++)
|
367
370
|
marshal(&cb, cif->arg_types[i], i >= cif->riscv_nfixedargs, avalue[i]);
|
368
371
|
|
369
|
-
ffi_call_asm((void*)alloc_base, cb.aregs, fn);
|
372
|
+
ffi_call_asm ((void *) alloc_base, cb.aregs, fn, closure);
|
370
373
|
|
371
374
|
cb.used_float = cb.used_integer = 0;
|
372
375
|
if (!return_by_ref && rvalue)
|
373
376
|
unmarshal(&cb, cif->rtype, 0, rvalue);
|
374
377
|
}
|
375
378
|
|
379
|
+
void
|
380
|
+
ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
|
381
|
+
{
|
382
|
+
ffi_call_int(cif, fn, rvalue, avalue, NULL);
|
383
|
+
}
|
384
|
+
|
385
|
+
void
|
386
|
+
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
|
387
|
+
void **avalue, void *closure)
|
388
|
+
{
|
389
|
+
ffi_call_int(cif, fn, rvalue, avalue, closure);
|
390
|
+
}
|
391
|
+
|
376
392
|
extern void ffi_closure_asm(void) FFI_HIDDEN;
|
377
393
|
|
378
394
|
ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void (*fun)(ffi_cif*,void*,void**,void*), void *user_data, void *codeloc)
|
@@ -406,11 +422,31 @@ ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void (*fun)(
|
|
406
422
|
return FFI_OK;
|
407
423
|
}
|
408
424
|
|
425
|
+
extern void ffi_go_closure_asm (void) FFI_HIDDEN;
|
426
|
+
|
427
|
+
ffi_status
|
428
|
+
ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
|
429
|
+
void (*fun) (ffi_cif *, void *, void **, void *))
|
430
|
+
{
|
431
|
+
if (cif->abi <= FFI_FIRST_ABI || cif->abi >= FFI_LAST_ABI)
|
432
|
+
return FFI_BAD_ABI;
|
433
|
+
|
434
|
+
closure->tramp = (void *) ffi_go_closure_asm;
|
435
|
+
closure->cif = cif;
|
436
|
+
closure->fun = fun;
|
437
|
+
|
438
|
+
return FFI_OK;
|
439
|
+
}
|
440
|
+
|
409
441
|
/* Called by the assembly code with aregs pointing to saved argument registers
|
410
442
|
and stack pointing to the stacked arguments. Return values passed in
|
411
443
|
registers will be reloaded from aregs. */
|
412
|
-
void FFI_HIDDEN
|
413
|
-
|
444
|
+
void FFI_HIDDEN
|
445
|
+
ffi_closure_inner (ffi_cif *cif,
|
446
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
447
|
+
void *user_data,
|
448
|
+
size_t *stack, call_context *aregs)
|
449
|
+
{
|
414
450
|
void **avalue = alloca(cif->nargs * sizeof(void*));
|
415
451
|
/* storage for arguments which will be copied by unmarshal(). We could
|
416
452
|
theoretically avoid the copies in many cases and use at most 128 bytes
|
@@ -436,7 +472,7 @@ void FFI_HIDDEN ffi_closure_inner(size_t *stack, call_context *aregs, ffi_closur
|
|
436
472
|
avalue[i] = unmarshal(&cb, cif->arg_types[i],
|
437
473
|
i >= cif->riscv_nfixedargs, astorage + i*MAXCOPYARG);
|
438
474
|
|
439
|
-
|
475
|
+
fun (cif, rvalue, avalue, user_data);
|
440
476
|
|
441
477
|
if (!return_by_ref && cif->rtype->type != FFI_TYPE_VOID) {
|
442
478
|
cb.used_integer = cb.used_float = 0;
|
@@ -59,6 +59,7 @@ typedef enum ffi_abi {
|
|
59
59
|
/* ---- Definitions for closures ----------------------------------------- */
|
60
60
|
|
61
61
|
#define FFI_CLOSURES 1
|
62
|
+
#define FFI_GO_CLOSURES 1
|
62
63
|
#define FFI_TRAMPOLINE_SIZE 24
|
63
64
|
#define FFI_NATIVE_RAW_API 0
|
64
65
|
#define FFI_EXTRA_CIF_FIELDS unsigned riscv_nfixedargs; unsigned riscv_unused;
|
@@ -67,8 +67,8 @@
|
|
67
67
|
intreg pad[rv32 ? 2 : 0];
|
68
68
|
intreg save_fp, save_ra;
|
69
69
|
}
|
70
|
-
void ffi_call_asm(size_t *stackargs, struct call_context *regargs,
|
71
|
-
|
70
|
+
void ffi_call_asm (size_t *stackargs, struct call_context *regargs,
|
71
|
+
void (*fn) (void), void *closure);
|
72
72
|
*/
|
73
73
|
|
74
74
|
#define FRAME_LEN (8 * FLTS + 8 * PTRS + 16)
|
@@ -98,6 +98,7 @@ ffi_call_asm:
|
|
98
98
|
|
99
99
|
# Load arguments
|
100
100
|
mv t1, a2
|
101
|
+
mv t2, a3
|
101
102
|
|
102
103
|
#if FLTS
|
103
104
|
FLARG fa0, -FRAME_LEN+0*FLTS(fp)
|
@@ -145,8 +146,10 @@ ffi_call_asm:
|
|
145
146
|
|
146
147
|
/*
|
147
148
|
ffi_closure_asm. Expects address of the passed-in ffi_closure in t1.
|
148
|
-
void ffi_closure_inner(
|
149
|
-
|
149
|
+
void ffi_closure_inner (ffi_cif *cif,
|
150
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
151
|
+
void *user_data,
|
152
|
+
size_t *stackargs, struct call_context *regargs)
|
150
153
|
*/
|
151
154
|
|
152
155
|
.globl ffi_closure_asm
|
@@ -187,9 +190,11 @@ ffi_closure_asm:
|
|
187
190
|
SARG a7, 8*FLTS+7*PTRS(sp)
|
188
191
|
|
189
192
|
/* enter C */
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
+
LARG a0, FFI_TRAMPOLINE_SIZE+0*PTRS(t1)
|
194
|
+
LARG a1, FFI_TRAMPOLINE_SIZE+1*PTRS(t1)
|
195
|
+
LARG a2, FFI_TRAMPOLINE_SIZE+2*PTRS(t1)
|
196
|
+
addi a3, sp, FRAME_LEN
|
197
|
+
mv a4, sp
|
193
198
|
|
194
199
|
call ffi_closure_inner
|
195
200
|
|
@@ -212,3 +217,77 @@ ffi_closure_asm:
|
|
212
217
|
ret
|
213
218
|
.cfi_endproc
|
214
219
|
.size ffi_closure_asm, .-ffi_closure_asm
|
220
|
+
|
221
|
+
/*
|
222
|
+
ffi_go_closure_asm. Expects address of the passed-in ffi_go_closure in t2.
|
223
|
+
void ffi_closure_inner (ffi_cif *cif,
|
224
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
225
|
+
void *user_data,
|
226
|
+
size_t *stackargs, struct call_context *regargs)
|
227
|
+
*/
|
228
|
+
|
229
|
+
.globl ffi_go_closure_asm
|
230
|
+
.hidden ffi_go_closure_asm
|
231
|
+
.type ffi_go_closure_asm, @function
|
232
|
+
ffi_go_closure_asm:
|
233
|
+
.cfi_startproc
|
234
|
+
|
235
|
+
addi sp, sp, -FRAME_LEN
|
236
|
+
.cfi_def_cfa_offset FRAME_LEN
|
237
|
+
|
238
|
+
/* make a frame */
|
239
|
+
SARG fp, FRAME_LEN - 2*PTRS(sp)
|
240
|
+
.cfi_offset 8, -2*PTRS
|
241
|
+
SARG ra, FRAME_LEN - 1*PTRS(sp)
|
242
|
+
.cfi_offset 1, -1*PTRS
|
243
|
+
addi fp, sp, FRAME_LEN
|
244
|
+
|
245
|
+
/* save arguments */
|
246
|
+
#if FLTS
|
247
|
+
FSARG fa0, 0*FLTS(sp)
|
248
|
+
FSARG fa1, 1*FLTS(sp)
|
249
|
+
FSARG fa2, 2*FLTS(sp)
|
250
|
+
FSARG fa3, 3*FLTS(sp)
|
251
|
+
FSARG fa4, 4*FLTS(sp)
|
252
|
+
FSARG fa5, 5*FLTS(sp)
|
253
|
+
FSARG fa6, 6*FLTS(sp)
|
254
|
+
FSARG fa7, 7*FLTS(sp)
|
255
|
+
#endif
|
256
|
+
|
257
|
+
SARG a0, 8*FLTS+0*PTRS(sp)
|
258
|
+
SARG a1, 8*FLTS+1*PTRS(sp)
|
259
|
+
SARG a2, 8*FLTS+2*PTRS(sp)
|
260
|
+
SARG a3, 8*FLTS+3*PTRS(sp)
|
261
|
+
SARG a4, 8*FLTS+4*PTRS(sp)
|
262
|
+
SARG a5, 8*FLTS+5*PTRS(sp)
|
263
|
+
SARG a6, 8*FLTS+6*PTRS(sp)
|
264
|
+
SARG a7, 8*FLTS+7*PTRS(sp)
|
265
|
+
|
266
|
+
/* enter C */
|
267
|
+
LARG a0, 1*PTRS(t2)
|
268
|
+
LARG a1, 2*PTRS(t2)
|
269
|
+
mv a2, t2
|
270
|
+
addi a3, sp, FRAME_LEN
|
271
|
+
mv a4, sp
|
272
|
+
|
273
|
+
call ffi_closure_inner
|
274
|
+
|
275
|
+
/* return values */
|
276
|
+
#if FLTS
|
277
|
+
FLARG fa0, 0*FLTS(sp)
|
278
|
+
FLARG fa1, 1*FLTS(sp)
|
279
|
+
#endif
|
280
|
+
|
281
|
+
LARG a0, 8*FLTS+0*PTRS(sp)
|
282
|
+
LARG a1, 8*FLTS+1*PTRS(sp)
|
283
|
+
|
284
|
+
/* restore and return */
|
285
|
+
LARG ra, FRAME_LEN-1*PTRS(sp)
|
286
|
+
.cfi_restore 1
|
287
|
+
LARG fp, FRAME_LEN-2*PTRS(sp)
|
288
|
+
.cfi_restore 8
|
289
|
+
addi sp, sp, FRAME_LEN
|
290
|
+
.cfi_def_cfa_offset 0
|
291
|
+
ret
|
292
|
+
.cfi_endproc
|
293
|
+
.size ffi_go_closure_asm, .-ffi_go_closure_asm
|
@@ -29,7 +29,7 @@
|
|
29
29
|
DEALINGS IN THE SOFTWARE.
|
30
30
|
----------------------------------------------------------------------- */
|
31
31
|
|
32
|
-
#
|
32
|
+
#if defined(__i386__) || defined(_M_IX86)
|
33
33
|
#include <ffi.h>
|
34
34
|
#include <ffi_common.h>
|
35
35
|
#include <stdint.h>
|
@@ -51,6 +51,13 @@
|
|
51
51
|
# define __declspec(x) __attribute__((x))
|
52
52
|
#endif
|
53
53
|
|
54
|
+
#if defined(_MSC_VER) && defined(_M_IX86)
|
55
|
+
/* Stack is not 16-byte aligned on Windows. */
|
56
|
+
#define STACK_ALIGN(bytes) (bytes)
|
57
|
+
#else
|
58
|
+
#define STACK_ALIGN(bytes) FFI_ALIGN (bytes, 16)
|
59
|
+
#endif
|
60
|
+
|
54
61
|
/* Perform machine dependent cif processing. */
|
55
62
|
ffi_status FFI_HIDDEN
|
56
63
|
ffi_prep_cif_machdep(ffi_cif *cif)
|
@@ -177,7 +184,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
|
177
184
|
bytes = FFI_ALIGN (bytes, t->alignment);
|
178
185
|
bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
|
179
186
|
}
|
180
|
-
cif->bytes =
|
187
|
+
cif->bytes = bytes;
|
181
188
|
|
182
189
|
return FFI_OK;
|
183
190
|
}
|
@@ -285,7 +292,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
285
292
|
}
|
286
293
|
}
|
287
294
|
|
288
|
-
bytes = cif->bytes;
|
295
|
+
bytes = STACK_ALIGN (cif->bytes);
|
289
296
|
stack = alloca(bytes + sizeof(*frame) + rsize);
|
290
297
|
argp = (dir < 0 ? stack + bytes : stack);
|
291
298
|
frame = (struct call_frame *)(stack + bytes);
|
@@ -346,7 +353,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
346
353
|
size_t align = FFI_SIZEOF_ARG;
|
347
354
|
|
348
355
|
/* Issue 434: For thiscall and fastcall, if the paramter passed
|
349
|
-
as 64-bit integer or struct, all following integer
|
356
|
+
as 64-bit integer or struct, all following integer parameters
|
350
357
|
will be passed on stack. */
|
351
358
|
if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
|
352
359
|
&& (t == FFI_TYPE_SINT64
|
@@ -390,12 +397,14 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
390
397
|
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
391
398
|
}
|
392
399
|
|
400
|
+
#ifdef FFI_GO_CLOSURES
|
393
401
|
void
|
394
402
|
ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
395
403
|
void **avalue, void *closure)
|
396
404
|
{
|
397
405
|
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
398
406
|
}
|
407
|
+
#endif
|
399
408
|
|
400
409
|
/** private members **/
|
401
410
|
|
@@ -429,7 +438,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
|
|
429
438
|
rvalue = frame->rettemp;
|
430
439
|
pabi = &abi_params[cabi];
|
431
440
|
dir = pabi->dir;
|
432
|
-
argp = (dir < 0 ? stack + cif->bytes : stack);
|
441
|
+
argp = (dir < 0 ? stack + STACK_ALIGN (cif->bytes) : stack);
|
433
442
|
|
434
443
|
switch (flags)
|
435
444
|
{
|
@@ -485,7 +494,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
|
|
485
494
|
align = 16;
|
486
495
|
|
487
496
|
/* Issue 434: For thiscall and fastcall, if the paramter passed
|
488
|
-
as 64-bit integer or struct, all following integer
|
497
|
+
as 64-bit integer or struct, all following integer parameters
|
489
498
|
will be passed on stack. */
|
490
499
|
if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
|
491
500
|
&& (t == FFI_TYPE_SINT64
|
@@ -545,17 +554,21 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
545
554
|
case FFI_REGISTER:
|
546
555
|
dest = ffi_closure_REGISTER;
|
547
556
|
op = 0x68; /* pushl imm */
|
557
|
+
break;
|
548
558
|
default:
|
549
559
|
return FFI_BAD_ABI;
|
550
560
|
}
|
551
561
|
|
562
|
+
/* endbr32. */
|
563
|
+
*(UINT32 *) tramp = 0xfb1e0ff3;
|
564
|
+
|
552
565
|
/* movl or pushl immediate. */
|
553
|
-
tramp[
|
554
|
-
*(void **)(tramp +
|
566
|
+
tramp[4] = op;
|
567
|
+
*(void **)(tramp + 5) = codeloc;
|
555
568
|
|
556
569
|
/* jmp dest */
|
557
|
-
tramp[
|
558
|
-
*(unsigned *)(tramp +
|
570
|
+
tramp[9] = 0xe9;
|
571
|
+
*(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14);
|
559
572
|
|
560
573
|
closure->cif = cif;
|
561
574
|
closure->fun = fun;
|
@@ -564,6 +577,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
564
577
|
return FFI_OK;
|
565
578
|
}
|
566
579
|
|
580
|
+
#ifdef FFI_GO_CLOSURES
|
581
|
+
|
567
582
|
void FFI_HIDDEN ffi_go_closure_EAX(void);
|
568
583
|
void FFI_HIDDEN ffi_go_closure_ECX(void);
|
569
584
|
void FFI_HIDDEN ffi_go_closure_STDCALL(void);
|
@@ -600,6 +615,8 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
|
|
600
615
|
return FFI_OK;
|
601
616
|
}
|
602
617
|
|
618
|
+
#endif /* FFI_GO_CLOSURES */
|
619
|
+
|
603
620
|
/* ------- Native raw API support -------------------------------- */
|
604
621
|
|
605
622
|
#if !FFI_NO_RAW_API
|
@@ -692,7 +709,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
|
|
692
709
|
}
|
693
710
|
}
|
694
711
|
|
695
|
-
bytes = cif->bytes;
|
712
|
+
bytes = STACK_ALIGN (cif->bytes);
|
696
713
|
argp = stack =
|
697
714
|
(void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
|
698
715
|
frame = (struct call_frame *)(stack + bytes);
|
@@ -750,4 +767,4 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
|
|
750
767
|
ffi_call_i386 (frame, stack);
|
751
768
|
}
|
752
769
|
#endif /* !FFI_NO_RAW_API */
|
753
|
-
#endif /*
|
770
|
+
#endif /* __i386__ */
|
@@ -282,7 +282,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
282
282
|
|
283
283
|
/* The X86_64_SSEUP_CLASS should be always preceded by
|
284
284
|
X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
|
285
|
-
if (classes[i] == X86_64_SSEUP_CLASS
|
285
|
+
if (i > 1 && classes[i] == X86_64_SSEUP_CLASS
|
286
286
|
&& classes[i - 1] != X86_64_SSE_CLASS
|
287
287
|
&& classes[i - 1] != X86_64_SSEUP_CLASS)
|
288
288
|
{
|
@@ -293,7 +293,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
293
293
|
|
294
294
|
/* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
|
295
295
|
everything should be passed in memory. */
|
296
|
-
if (classes[i] == X86_64_X87UP_CLASS
|
296
|
+
if (i > 1 && classes[i] == X86_64_X87UP_CLASS
|
297
297
|
&& (classes[i - 1] != X86_64_X87_CLASS))
|
298
298
|
{
|
299
299
|
/* The first one should never be X86_64_X87UP_CLASS. */
|
@@ -394,7 +394,7 @@ extern ffi_status
|
|
394
394
|
ffi_prep_cif_machdep_efi64(ffi_cif *cif);
|
395
395
|
#endif
|
396
396
|
|
397
|
-
ffi_status
|
397
|
+
ffi_status FFI_HIDDEN
|
398
398
|
ffi_prep_cif_machdep (ffi_cif *cif)
|
399
399
|
{
|
400
400
|
int gprcount, ssecount, i, avn, ngpr, nsse;
|
@@ -451,9 +451,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
451
451
|
case FFI_TYPE_DOUBLE:
|
452
452
|
flags = UNIX64_RET_XMM64;
|
453
453
|
break;
|
454
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
454
455
|
case FFI_TYPE_LONGDOUBLE:
|
455
456
|
flags = UNIX64_RET_X87;
|
456
457
|
break;
|
458
|
+
#endif
|
457
459
|
case FFI_TYPE_STRUCT:
|
458
460
|
n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
|
459
461
|
if (n == 0)
|
@@ -686,6 +688,8 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
686
688
|
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
687
689
|
}
|
688
690
|
|
691
|
+
#ifdef FFI_GO_CLOSURES
|
692
|
+
|
689
693
|
#ifndef __ILP32__
|
690
694
|
extern void
|
691
695
|
ffi_call_go_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue,
|
@@ -706,6 +710,7 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
706
710
|
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
707
711
|
}
|
708
712
|
|
713
|
+
#endif /* FFI_GO_CLOSURES */
|
709
714
|
|
710
715
|
extern void ffi_closure_unix64(void) FFI_HIDDEN;
|
711
716
|
extern void ffi_closure_unix64_sse(void) FFI_HIDDEN;
|
@@ -726,13 +731,15 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
726
731
|
void *user_data,
|
727
732
|
void *codeloc)
|
728
733
|
{
|
729
|
-
static const unsigned char trampoline[
|
730
|
-
/*
|
731
|
-
|
732
|
-
/*
|
733
|
-
|
734
|
-
/*
|
735
|
-
|
734
|
+
static const unsigned char trampoline[24] = {
|
735
|
+
/* endbr64 */
|
736
|
+
0xf3, 0x0f, 0x1e, 0xfa,
|
737
|
+
/* leaq -0xb(%rip),%r10 # 0x0 */
|
738
|
+
0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
|
739
|
+
/* jmpq *0x7(%rip) # 0x18 */
|
740
|
+
0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
|
741
|
+
/* nopl 0(%rax) */
|
742
|
+
0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
|
736
743
|
};
|
737
744
|
void (*dest)(void);
|
738
745
|
char *tramp = closure->tramp;
|
@@ -750,7 +757,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
750
757
|
dest = ffi_closure_unix64;
|
751
758
|
|
752
759
|
memcpy (tramp, trampoline, sizeof(trampoline));
|
753
|
-
*(UINT64 *)(tramp +
|
760
|
+
*(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest;
|
754
761
|
|
755
762
|
closure->cif = cif;
|
756
763
|
closure->fun = fun;
|
@@ -852,6 +859,8 @@ ffi_closure_unix64_inner(ffi_cif *cif,
|
|
852
859
|
return flags;
|
853
860
|
}
|
854
861
|
|
862
|
+
#ifdef FFI_GO_CLOSURES
|
863
|
+
|
855
864
|
extern void ffi_go_closure_unix64(void) FFI_HIDDEN;
|
856
865
|
extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN;
|
857
866
|
|
@@ -881,4 +890,6 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
|
|
881
890
|
return FFI_OK;
|
882
891
|
}
|
883
892
|
|
893
|
+
#endif /* FFI_GO_CLOSURES */
|
894
|
+
|
884
895
|
#endif /* __x86_64__ */
|