ffi 1.9.24 → 1.16.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +348 -0
- data/Gemfile +4 -5
- data/README.md +44 -17
- data/Rakefile +74 -148
- data/ext/ffi_c/AbstractMemory.c +89 -70
- data/ext/ffi_c/AbstractMemory.h +3 -2
- data/ext/ffi_c/ArrayType.c +49 -13
- data/ext/ffi_c/ArrayType.h +1 -0
- data/ext/ffi_c/Buffer.c +90 -38
- data/ext/ffi_c/Call.c +55 -56
- data/ext/ffi_c/Call.h +12 -6
- data/ext/ffi_c/ClosurePool.c +333 -0
- data/ext/ffi_c/{Closure.h → ClosurePool.h} +25 -13
- data/ext/ffi_c/DynamicLibrary.c +91 -33
- data/ext/ffi_c/Function.c +306 -235
- data/ext/ffi_c/Function.h +3 -5
- data/ext/ffi_c/FunctionInfo.c +87 -32
- data/ext/ffi_c/LastError.c +74 -15
- data/ext/ffi_c/LongDouble.c +12 -10
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MappedType.c +66 -23
- data/ext/ffi_c/MappedType.h +0 -2
- data/ext/ffi_c/MemoryPointer.c +37 -15
- data/ext/ffi_c/MemoryPointer.h +0 -4
- data/ext/ffi_c/MethodHandle.c +265 -38
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +5 -56
- data/ext/ffi_c/Pointer.c +93 -55
- data/ext/ffi_c/Pointer.h +1 -4
- data/ext/ffi_c/Struct.c +202 -134
- data/ext/ffi_c/Struct.h +18 -9
- data/ext/ffi_c/StructByValue.c +50 -23
- data/ext/ffi_c/StructLayout.c +135 -64
- data/ext/ffi_c/Thread.c +4 -228
- data/ext/ffi_c/Thread.h +1 -20
- data/ext/ffi_c/Type.c +105 -55
- data/ext/ffi_c/Type.h +3 -2
- data/ext/ffi_c/Types.c +8 -9
- data/ext/ffi_c/Types.h +3 -4
- data/ext/ffi_c/Variadic.c +88 -47
- data/ext/ffi_c/compat.h +26 -22
- data/ext/ffi_c/extconf.rb +75 -32
- data/ext/ffi_c/ffi.c +9 -10
- data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
- data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
- data/ext/ffi_c/libffi/.appveyor.yml +53 -19
- data/ext/ffi_c/libffi/.ci/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
- data/ext/ffi_c/libffi/.ci/build-in-container.sh +10 -0
- data/ext/ffi_c/libffi/.ci/build.sh +124 -0
- data/ext/ffi_c/libffi/.ci/install.sh +78 -0
- data/ext/ffi_c/libffi/.ci/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +1 -1
- data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
- data/ext/ffi_c/libffi/.ci/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.ci/site.exp +29 -0
- data/ext/ffi_c/libffi/.ci/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +460 -0
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +171 -0
- data/ext/ffi_c/libffi/.gitignore +10 -2
- 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 +64 -73
- data/ext/ffi_c/libffi/Makefile.in +553 -235
- data/ext/ffi_c/libffi/README.md +165 -100
- data/ext/ffi_c/libffi/acinclude.m4 +10 -112
- data/ext/ffi_c/libffi/compile +348 -0
- data/ext/ffi_c/libffi/config.guess +950 -662
- data/ext/ffi_c/libffi/config.sub +1362 -1306
- data/ext/ffi_c/libffi/configure +4909 -4096
- data/ext/ffi_c/libffi/configure.ac +93 -32
- data/ext/ffi_c/libffi/configure.host +76 -28
- data/ext/ffi_c/libffi/doc/Makefile.in +15 -8
- data/ext/ffi_c/libffi/doc/libffi.texi +107 -46
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +22 -44
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +165 -56
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +17 -12
- data/ext/ffi_c/libffi/include/ffi.h.in +64 -48
- data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +34 -1
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +107 -74
- 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 +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +576 -284
- 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_cc_maxopt.m4 +18 -14
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -44
- 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/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/man/Makefile.in +15 -8
- data/ext/ffi_c/libffi/missing +8 -8
- 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/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
- data/ext/ffi_c/libffi/msvcc.sh +39 -14
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +286 -98
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
- data/ext/ffi_c/libffi/src/aarch64/internal.h +33 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +142 -37
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
- data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +112 -10
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +117 -44
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/closures.c +189 -48
- 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 +6 -1
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
- data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
- 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/loongarch64/ffi.c +621 -0
- data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
- data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
- data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/mips/ffi.c +245 -66
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
- data/ext/ffi_c/libffi/src/mips/o32.S +63 -4
- data/ext/ffi_c/libffi/src/moxie/ffi.c +48 -23
- data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
- data/ext/ffi_c/libffi/src/pa/ffi.c +62 -108
- data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +20 -11
- data/ext/ffi_c/libffi/src/pa/hpux32.S +87 -38
- data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +109 -39
- 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 +93 -28
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +83 -5
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +26 -4
- data/ext/ffi_c/libffi/src/riscv/ffi.c +79 -10
- 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/sparc/ffi64.c +16 -0
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
- data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +128 -49
- data/ext/ffi_c/libffi/src/x86/ffi64.c +89 -23
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +21 -4
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +63 -10
- data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +274 -45
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +190 -4
- data/ext/ffi_c/libffi/src/x86/win64.S +32 -10
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
- data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -109
- data/ext/ffi_c/libffi/testsuite/Makefile.in +144 -88
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +71 -25
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +5 -4
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
- 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 +3 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +21 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +7 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +6 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +18 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +29 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +21 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +35 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +19 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +13 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +18 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +29 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +28 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +24 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +39 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +25 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +14 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +14 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +14 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +20 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +40 -25
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +40 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +18 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +18 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +19 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +11 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +22 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +5 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +6 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +6 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +5 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +10 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +11 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +2 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +24 -22
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +32 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +12 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +21 -5
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +10 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +10 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +9 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +9 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +11 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +9 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +11 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +6 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +2 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +1 -0
- data/ext/ffi_c/libffi.bsd.mk +2 -2
- data/ext/ffi_c/libffi.darwin.mk +1 -1
- data/ext/ffi_c/libffi.gnu.mk +2 -2
- data/ext/ffi_c/rbffi.h +1 -3
- data/ffi.gemspec +15 -9
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +8 -23
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/dynamic_library.rb +89 -0
- data/lib/ffi/enum.rb +18 -11
- data/lib/ffi/ffi.rb +6 -0
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/io.rb +3 -3
- data/lib/ffi/library.rb +65 -77
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +3 -3
- 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 +181 -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/aarch64-windows/types.conf +52 -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/hppa1.1-linux/types.conf +178 -0
- data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
- 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/loongarch64-linux/types.conf +141 -0
- 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/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- 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/platform.rb +43 -20
- data/lib/ffi/pointer.rb +26 -20
- data/lib/ffi/struct.rb +14 -68
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +1 -1
- data/lib/ffi/tools/const_generator.rb +11 -8
- data/lib/ffi/tools/generator.rb +47 -2
- data/lib/ffi/tools/generator_task.rb +13 -17
- data/lib/ffi/tools/struct_generator.rb +6 -5
- data/lib/ffi/tools/types_generator.rb +7 -4
- data/lib/ffi/types.rb +33 -7
- data/lib/ffi/variadic.rb +20 -18
- data/lib/ffi/version.rb +1 -1
- data/lib/ffi.rb +10 -3
- 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/hello_ractor.rb +11 -0
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- data/samples/qsort_ractor.rb +28 -0
- data.tar.gz.sig +0 -0
- metadata +252 -153
- metadata.gz.sig +0 -0
- 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/Closure.c +0 -54
- 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/.travis/build.sh +0 -34
- data/ext/ffi_c/libffi/.travis/install.sh +0 -22
- data/ext/ffi_c/libffi/.travis/site.exp +0 -18
- data/ext/ffi_c/libffi/.travis.yml +0 -34
- 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/libffi/testsuite/libffi.call/cls_uchar_va.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +0 -44
- 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
- data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.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_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}/err_bad_abi.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/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +79 -79
@@ -19,6 +19,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
19
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
20
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
21
21
|
|
22
|
+
#if defined(__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)
|
22
23
|
#include <stdio.h>
|
23
24
|
#include <stdlib.h>
|
24
25
|
#include <stdint.h>
|
@@ -26,6 +27,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
26
27
|
#include <ffi.h>
|
27
28
|
#include <ffi_common.h>
|
28
29
|
#include "internal.h"
|
30
|
+
#ifdef _WIN32
|
31
|
+
#include <windows.h> /* FlushInstructionCache */
|
32
|
+
#endif
|
33
|
+
#include <tramp.h>
|
29
34
|
|
30
35
|
/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
|
31
36
|
all further uses in this file will refer to the 128-bit type. */
|
@@ -58,6 +63,9 @@ struct call_context
|
|
58
63
|
#if FFI_EXEC_TRAMPOLINE_TABLE
|
59
64
|
|
60
65
|
#ifdef __MACH__
|
66
|
+
#ifdef HAVE_PTRAUTH
|
67
|
+
#include <ptrauth.h>
|
68
|
+
#endif
|
61
69
|
#include <mach/vm_param.h>
|
62
70
|
#endif
|
63
71
|
|
@@ -74,6 +82,8 @@ ffi_clear_cache (void *start, void *end)
|
|
74
82
|
sys_icache_invalidate (start, (char *)end - (char *)start);
|
75
83
|
#elif defined (__GNUC__)
|
76
84
|
__builtin___clear_cache (start, end);
|
85
|
+
#elif defined (_WIN32)
|
86
|
+
FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start);
|
77
87
|
#else
|
78
88
|
#error "Missing builtin to flush instruction cache"
|
79
89
|
#endif
|
@@ -238,13 +248,18 @@ is_vfp_type (const ffi_type *ty)
|
|
238
248
|
state.
|
239
249
|
|
240
250
|
The terse state variable names match the names used in the AARCH64
|
241
|
-
PCS.
|
251
|
+
PCS.
|
252
|
+
|
253
|
+
The struct area is allocated downwards from the top of the argument
|
254
|
+
area. It is used to hold copies of structures passed by value that are
|
255
|
+
bigger than 16 bytes. */
|
242
256
|
|
243
257
|
struct arg_state
|
244
258
|
{
|
245
259
|
unsigned ngrn; /* Next general-purpose register number. */
|
246
260
|
unsigned nsrn; /* Next vector register number. */
|
247
261
|
size_t nsaa; /* Next stack offset. */
|
262
|
+
size_t next_struct_area; /* Place to allocate big structs. */
|
248
263
|
|
249
264
|
#if defined (__APPLE__)
|
250
265
|
unsigned allocating_variadic;
|
@@ -253,11 +268,12 @@ struct arg_state
|
|
253
268
|
|
254
269
|
/* Initialize a procedure call argument marshalling state. */
|
255
270
|
static void
|
256
|
-
arg_init (struct arg_state *state)
|
271
|
+
arg_init (struct arg_state *state, size_t size)
|
257
272
|
{
|
258
273
|
state->ngrn = 0;
|
259
274
|
state->nsrn = 0;
|
260
275
|
state->nsaa = 0;
|
276
|
+
state->next_struct_area = size;
|
261
277
|
#if defined (__APPLE__)
|
262
278
|
state->allocating_variadic = 0;
|
263
279
|
#endif
|
@@ -279,42 +295,91 @@ allocate_to_stack (struct arg_state *state, void *stack,
|
|
279
295
|
if (alignment < 8)
|
280
296
|
alignment = 8;
|
281
297
|
#endif
|
282
|
-
|
298
|
+
|
283
299
|
nsaa = FFI_ALIGN (nsaa, alignment);
|
284
300
|
state->nsaa = nsaa + size;
|
285
301
|
|
286
302
|
return (char *)stack + nsaa;
|
287
303
|
}
|
288
304
|
|
305
|
+
/* Allocate and copy a structure that is passed by value on the stack and
|
306
|
+
return a pointer to it. */
|
307
|
+
static void *
|
308
|
+
allocate_and_copy_struct_to_stack (struct arg_state *state, void *stack,
|
309
|
+
size_t alignment, size_t size, void *value)
|
310
|
+
{
|
311
|
+
size_t dest = state->next_struct_area - size;
|
312
|
+
|
313
|
+
/* Round down to the natural alignment of the value. */
|
314
|
+
dest = FFI_ALIGN_DOWN (dest, alignment);
|
315
|
+
state->next_struct_area = dest;
|
316
|
+
|
317
|
+
return memcpy ((char *) stack + dest, value, size);
|
318
|
+
}
|
319
|
+
|
289
320
|
static ffi_arg
|
290
321
|
extend_integer_type (void *source, int type)
|
291
322
|
{
|
292
323
|
switch (type)
|
293
324
|
{
|
294
325
|
case FFI_TYPE_UINT8:
|
295
|
-
|
326
|
+
{
|
327
|
+
UINT8 u8;
|
328
|
+
memcpy (&u8, source, sizeof (u8));
|
329
|
+
return u8;
|
330
|
+
}
|
296
331
|
case FFI_TYPE_SINT8:
|
297
|
-
|
332
|
+
{
|
333
|
+
SINT8 s8;
|
334
|
+
memcpy (&s8, source, sizeof (s8));
|
335
|
+
return s8;
|
336
|
+
}
|
298
337
|
case FFI_TYPE_UINT16:
|
299
|
-
|
338
|
+
{
|
339
|
+
UINT16 u16;
|
340
|
+
memcpy (&u16, source, sizeof (u16));
|
341
|
+
return u16;
|
342
|
+
}
|
300
343
|
case FFI_TYPE_SINT16:
|
301
|
-
|
344
|
+
{
|
345
|
+
SINT16 s16;
|
346
|
+
memcpy (&s16, source, sizeof (s16));
|
347
|
+
return s16;
|
348
|
+
}
|
302
349
|
case FFI_TYPE_UINT32:
|
303
|
-
|
350
|
+
{
|
351
|
+
UINT32 u32;
|
352
|
+
memcpy (&u32, source, sizeof (u32));
|
353
|
+
return u32;
|
354
|
+
}
|
304
355
|
case FFI_TYPE_INT:
|
305
356
|
case FFI_TYPE_SINT32:
|
306
|
-
|
357
|
+
{
|
358
|
+
SINT32 s32;
|
359
|
+
memcpy (&s32, source, sizeof (s32));
|
360
|
+
return s32;
|
361
|
+
}
|
307
362
|
case FFI_TYPE_UINT64:
|
308
363
|
case FFI_TYPE_SINT64:
|
309
|
-
|
310
|
-
|
364
|
+
{
|
365
|
+
UINT64 u64;
|
366
|
+
memcpy (&u64, source, sizeof (u64));
|
367
|
+
return u64;
|
368
|
+
}
|
311
369
|
case FFI_TYPE_POINTER:
|
312
|
-
|
370
|
+
{
|
371
|
+
uintptr_t uptr;
|
372
|
+
memcpy (&uptr, source, sizeof (uptr));
|
373
|
+
return uptr;
|
374
|
+
}
|
313
375
|
default:
|
314
376
|
abort();
|
315
377
|
}
|
316
378
|
}
|
317
379
|
|
380
|
+
#if defined(_MSC_VER)
|
381
|
+
void extend_hfa_type (void *dest, void *src, int h);
|
382
|
+
#else
|
318
383
|
static void
|
319
384
|
extend_hfa_type (void *dest, void *src, int h)
|
320
385
|
{
|
@@ -350,10 +415,10 @@ extend_hfa_type (void *dest, void *src, int h)
|
|
350
415
|
" b 1f\n"
|
351
416
|
" nop\n"
|
352
417
|
" ldp q16, q17, [%3]\n" /* Q4 */
|
353
|
-
" ldp q18, q19, [%3, #
|
418
|
+
" ldp q18, q19, [%3, #32]\n"
|
354
419
|
" b 4f\n"
|
355
420
|
" ldp q16, q17, [%3]\n" /* Q3 */
|
356
|
-
" ldr q18, [%3, #
|
421
|
+
" ldr q18, [%3, #32]\n"
|
357
422
|
" b 3f\n"
|
358
423
|
" ldp q16, q17, [%3]\n" /* Q2 */
|
359
424
|
" b 2f\n"
|
@@ -368,7 +433,11 @@ extend_hfa_type (void *dest, void *src, int h)
|
|
368
433
|
: "r"(f * 12), "r"(dest), "r"(src)
|
369
434
|
: "memory", "v16", "v17", "v18", "v19");
|
370
435
|
}
|
436
|
+
#endif
|
371
437
|
|
438
|
+
#if defined(_MSC_VER)
|
439
|
+
void* compress_hfa_type (void *dest, void *src, int h);
|
440
|
+
#else
|
372
441
|
static void *
|
373
442
|
compress_hfa_type (void *dest, void *reg, int h)
|
374
443
|
{
|
@@ -437,6 +506,7 @@ compress_hfa_type (void *dest, void *reg, int h)
|
|
437
506
|
}
|
438
507
|
return dest;
|
439
508
|
}
|
509
|
+
#endif
|
440
510
|
|
441
511
|
/* Either allocate an appropriate register for the argument type, or if
|
442
512
|
none are available, allocate a stack slot and return a pointer
|
@@ -454,7 +524,7 @@ allocate_int_to_reg_or_stack (struct call_context *context,
|
|
454
524
|
return allocate_to_stack (state, stack, size, size);
|
455
525
|
}
|
456
526
|
|
457
|
-
ffi_status
|
527
|
+
ffi_status FFI_HIDDEN
|
458
528
|
ffi_prep_cif_machdep (ffi_cif *cif)
|
459
529
|
{
|
460
530
|
ffi_type *rtype = cif->rtype;
|
@@ -539,14 +609,22 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
539
609
|
|
540
610
|
#if defined (__APPLE__)
|
541
611
|
/* Perform Apple-specific cif processing for variadic calls */
|
542
|
-
ffi_status
|
543
|
-
|
544
|
-
|
612
|
+
ffi_status FFI_HIDDEN
|
613
|
+
ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
|
614
|
+
unsigned int ntotalargs)
|
545
615
|
{
|
546
616
|
ffi_status status = ffi_prep_cif_machdep (cif);
|
547
617
|
cif->aarch64_nfixedargs = nfixedargs;
|
548
618
|
return status;
|
549
619
|
}
|
620
|
+
#else
|
621
|
+
ffi_status FFI_HIDDEN
|
622
|
+
ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs)
|
623
|
+
{
|
624
|
+
ffi_status status = ffi_prep_cif_machdep (cif);
|
625
|
+
cif->flags |= AARCH64_FLAG_VARARG;
|
626
|
+
return status;
|
627
|
+
}
|
550
628
|
#endif /* __APPLE__ */
|
551
629
|
|
552
630
|
extern void ffi_call_SYSV (struct call_context *context, void *frame,
|
@@ -563,7 +641,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
563
641
|
void *stack, *frame, *rvalue;
|
564
642
|
struct arg_state state;
|
565
643
|
size_t stack_bytes, rtype_size, rsize;
|
566
|
-
int i, nargs, flags;
|
644
|
+
int i, nargs, flags, isvariadic = 0;
|
567
645
|
ffi_type *rtype;
|
568
646
|
|
569
647
|
flags = cif->flags;
|
@@ -571,6 +649,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
571
649
|
rtype_size = rtype->size;
|
572
650
|
stack_bytes = cif->bytes;
|
573
651
|
|
652
|
+
if (flags & AARCH64_FLAG_VARARG)
|
653
|
+
{
|
654
|
+
isvariadic = 1;
|
655
|
+
flags &= ~AARCH64_FLAG_VARARG;
|
656
|
+
}
|
657
|
+
|
574
658
|
/* If the target function returns a structure via hidden pointer,
|
575
659
|
then we cannot allow a null rvalue. Otherwise, mash a null
|
576
660
|
rvalue to void return type. */
|
@@ -585,19 +669,21 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
585
669
|
else if (flags & AARCH64_RET_NEED_COPY)
|
586
670
|
rsize = 16;
|
587
671
|
|
588
|
-
/* Allocate consectutive stack for everything we'll need.
|
589
|
-
|
672
|
+
/* Allocate consectutive stack for everything we'll need.
|
673
|
+
The frame uses 40 bytes for: lr, fp, rvalue, flags, sp */
|
674
|
+
context = alloca (sizeof(struct call_context) + stack_bytes + 40 + rsize);
|
590
675
|
stack = context + 1;
|
591
|
-
frame = stack + stack_bytes;
|
592
|
-
rvalue = (rsize ? frame +
|
676
|
+
frame = (void*)((uintptr_t)stack + (uintptr_t)stack_bytes);
|
677
|
+
rvalue = (rsize ? (void*)((uintptr_t)frame + 40) : orig_rvalue);
|
593
678
|
|
594
|
-
arg_init (&state);
|
679
|
+
arg_init (&state, stack_bytes);
|
595
680
|
for (i = 0, nargs = cif->nargs; i < nargs; i++)
|
596
681
|
{
|
597
682
|
ffi_type *ty = cif->arg_types[i];
|
598
683
|
size_t s = ty->size;
|
599
684
|
void *a = avalue[i];
|
600
685
|
int h, t;
|
686
|
+
void *dest;
|
601
687
|
|
602
688
|
t = ty->type;
|
603
689
|
switch (t)
|
@@ -645,28 +731,44 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
645
731
|
case FFI_TYPE_STRUCT:
|
646
732
|
case FFI_TYPE_COMPLEX:
|
647
733
|
{
|
648
|
-
void *dest;
|
649
|
-
|
650
734
|
h = is_vfp_type (ty);
|
651
735
|
if (h)
|
652
736
|
{
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
737
|
+
int elems = 4 - (h & 3);
|
738
|
+
if (cif->abi == FFI_WIN64 && isvariadic)
|
739
|
+
{
|
740
|
+
if (state.ngrn + elems <= N_X_ARG_REG)
|
741
|
+
{
|
742
|
+
dest = &context->x[state.ngrn];
|
743
|
+
state.ngrn += elems;
|
744
|
+
extend_hfa_type(dest, a, h);
|
745
|
+
break;
|
746
|
+
}
|
747
|
+
state.nsrn = N_X_ARG_REG;
|
748
|
+
dest = allocate_to_stack(&state, stack, ty->alignment, s);
|
749
|
+
}
|
750
|
+
else
|
751
|
+
{
|
752
|
+
if (state.nsrn + elems <= N_V_ARG_REG)
|
753
|
+
{
|
754
|
+
dest = &context->v[state.nsrn];
|
755
|
+
state.nsrn += elems;
|
756
|
+
extend_hfa_type (dest, a, h);
|
757
|
+
break;
|
758
|
+
}
|
759
|
+
state.nsrn = N_V_ARG_REG;
|
760
|
+
dest = allocate_to_stack (&state, stack, ty->alignment, s);
|
761
|
+
}
|
663
762
|
}
|
664
763
|
else if (s > 16)
|
665
764
|
{
|
666
765
|
/* If the argument is a composite type that is larger than 16
|
667
|
-
bytes, then the argument
|
766
|
+
bytes, then the argument is copied to memory, and
|
668
767
|
the argument is replaced by a pointer to the copy. */
|
669
|
-
|
768
|
+
dest = allocate_and_copy_struct_to_stack (&state, stack,
|
769
|
+
ty->alignment, s,
|
770
|
+
avalue[i]);
|
771
|
+
a = &dest;
|
670
772
|
t = FFI_TYPE_POINTER;
|
671
773
|
s = sizeof (void *);
|
672
774
|
goto do_pointer;
|
@@ -681,7 +783,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
|
|
681
783
|
X registers, then the argument is copied into
|
682
784
|
consecutive X registers. */
|
683
785
|
dest = &context->x[state.ngrn];
|
684
|
-
|
786
|
+
state.ngrn += (unsigned int)n;
|
685
787
|
}
|
686
788
|
else
|
687
789
|
{
|
@@ -723,6 +825,8 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
|
|
723
825
|
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
724
826
|
}
|
725
827
|
|
828
|
+
#if FFI_CLOSURES
|
829
|
+
|
726
830
|
#ifdef FFI_GO_CLOSURES
|
727
831
|
void
|
728
832
|
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
|
@@ -736,6 +840,10 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
|
|
736
840
|
|
737
841
|
extern void ffi_closure_SYSV (void) FFI_HIDDEN;
|
738
842
|
extern void ffi_closure_SYSV_V (void) FFI_HIDDEN;
|
843
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
844
|
+
extern void ffi_closure_SYSV_alt (void) FFI_HIDDEN;
|
845
|
+
extern void ffi_closure_SYSV_V_alt (void) FFI_HIDDEN;
|
846
|
+
#endif
|
739
847
|
|
740
848
|
ffi_status
|
741
849
|
ffi_prep_closure_loc (ffi_closure *closure,
|
@@ -744,22 +852,25 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
744
852
|
void *user_data,
|
745
853
|
void *codeloc)
|
746
854
|
{
|
747
|
-
if (cif->abi != FFI_SYSV)
|
855
|
+
if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64)
|
748
856
|
return FFI_BAD_ABI;
|
749
857
|
|
750
858
|
void (*start)(void);
|
751
|
-
|
859
|
+
|
752
860
|
if (cif->flags & AARCH64_FLAG_ARG_V)
|
753
861
|
start = ffi_closure_SYSV_V;
|
754
862
|
else
|
755
863
|
start = ffi_closure_SYSV;
|
756
864
|
|
757
865
|
#if FFI_EXEC_TRAMPOLINE_TABLE
|
758
|
-
#ifdef __MACH__
|
866
|
+
# ifdef __MACH__
|
867
|
+
# ifdef HAVE_PTRAUTH
|
868
|
+
codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0);
|
869
|
+
# endif
|
759
870
|
void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
|
760
871
|
config[0] = closure;
|
761
872
|
config[1] = start;
|
762
|
-
#endif
|
873
|
+
# endif
|
763
874
|
#else
|
764
875
|
static const unsigned char trampoline[16] = {
|
765
876
|
0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */
|
@@ -767,12 +878,39 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
767
878
|
0x00, 0x02, 0x1f, 0xd6 /* br x16 */
|
768
879
|
};
|
769
880
|
char *tramp = closure->tramp;
|
770
|
-
|
881
|
+
|
882
|
+
# if defined(FFI_EXEC_STATIC_TRAMP)
|
883
|
+
if (ffi_tramp_is_present(closure))
|
884
|
+
{
|
885
|
+
/* Initialize the static trampoline's parameters. */
|
886
|
+
if (start == ffi_closure_SYSV_V)
|
887
|
+
start = ffi_closure_SYSV_V_alt;
|
888
|
+
else
|
889
|
+
start = ffi_closure_SYSV_alt;
|
890
|
+
ffi_tramp_set_parms (closure->ftramp, start, closure);
|
891
|
+
goto out;
|
892
|
+
}
|
893
|
+
# endif
|
894
|
+
|
895
|
+
/* Initialize the dynamic trampoline. */
|
771
896
|
memcpy (tramp, trampoline, sizeof(trampoline));
|
772
|
-
|
897
|
+
|
773
898
|
*(UINT64 *)(tramp + 16) = (uintptr_t)start;
|
774
899
|
|
775
900
|
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
|
901
|
+
|
902
|
+
/* Also flush the cache for code mapping. */
|
903
|
+
# ifdef _WIN32
|
904
|
+
// Not using dlmalloc.c for Windows ARM64 builds
|
905
|
+
// so calling ffi_data_to_code_pointer() isn't necessary
|
906
|
+
unsigned char *tramp_code = tramp;
|
907
|
+
# else
|
908
|
+
unsigned char *tramp_code = ffi_data_to_code_pointer (tramp);
|
909
|
+
# endif
|
910
|
+
ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE);
|
911
|
+
# if defined(FFI_EXEC_STATIC_TRAMP)
|
912
|
+
out:
|
913
|
+
# endif
|
776
914
|
#endif
|
777
915
|
|
778
916
|
closure->cif = cif;
|
@@ -792,7 +930,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif,
|
|
792
930
|
{
|
793
931
|
void (*start)(void);
|
794
932
|
|
795
|
-
if (cif->abi != FFI_SYSV)
|
933
|
+
if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64)
|
796
934
|
return FFI_BAD_ABI;
|
797
935
|
|
798
936
|
if (cif->flags & AARCH64_FLAG_ARG_V)
|
@@ -832,10 +970,17 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
832
970
|
void *stack, void *rvalue, void *struct_rvalue)
|
833
971
|
{
|
834
972
|
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
|
835
|
-
int i, h, nargs, flags;
|
973
|
+
int i, h, nargs, flags, isvariadic = 0;
|
836
974
|
struct arg_state state;
|
837
975
|
|
838
|
-
arg_init (&state);
|
976
|
+
arg_init (&state, cif->bytes);
|
977
|
+
|
978
|
+
flags = cif->flags;
|
979
|
+
if (flags & AARCH64_FLAG_VARARG)
|
980
|
+
{
|
981
|
+
isvariadic = 1;
|
982
|
+
flags &= ~AARCH64_FLAG_VARARG;
|
983
|
+
}
|
839
984
|
|
840
985
|
for (i = 0, nargs = cif->nargs; i < nargs; i++)
|
841
986
|
{
|
@@ -871,55 +1016,83 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
871
1016
|
if (h)
|
872
1017
|
{
|
873
1018
|
n = 4 - (h & 3);
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
1019
|
+
if (cif->abi == FFI_WIN64 && isvariadic)
|
1020
|
+
{
|
1021
|
+
if (state.ngrn + n <= N_X_ARG_REG)
|
1022
|
+
{
|
1023
|
+
void *reg = &context->x[state.ngrn];
|
1024
|
+
state.ngrn += (unsigned int)n;
|
1025
|
+
|
1026
|
+
/* Eeek! We need a pointer to the structure, however the
|
1027
|
+
homogeneous float elements are being passed in individual
|
1028
|
+
registers, therefore for float and double the structure
|
1029
|
+
is not represented as a contiguous sequence of bytes in
|
1030
|
+
our saved register context. We don't need the original
|
1031
|
+
contents of the register storage, so we reformat the
|
1032
|
+
structure into the same memory. */
|
1033
|
+
avalue[i] = compress_hfa_type(reg, reg, h);
|
1034
|
+
}
|
1035
|
+
else
|
1036
|
+
{
|
1037
|
+
state.ngrn = N_X_ARG_REG;
|
1038
|
+
state.nsrn = N_V_ARG_REG;
|
1039
|
+
avalue[i] = allocate_to_stack(&state, stack,
|
1040
|
+
ty->alignment, s);
|
1041
|
+
}
|
1042
|
+
}
|
1043
|
+
else
|
1044
|
+
{
|
1045
|
+
if (state.nsrn + n <= N_V_ARG_REG)
|
1046
|
+
{
|
1047
|
+
void *reg = &context->v[state.nsrn];
|
1048
|
+
state.nsrn += (unsigned int)n;
|
1049
|
+
avalue[i] = compress_hfa_type(reg, reg, h);
|
1050
|
+
}
|
1051
|
+
else
|
1052
|
+
{
|
1053
|
+
state.nsrn = N_V_ARG_REG;
|
1054
|
+
avalue[i] = allocate_to_stack(&state, stack,
|
1055
|
+
ty->alignment, s);
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
}
|
1059
|
+
else if (s > 16)
|
1060
|
+
{
|
1061
|
+
/* Replace Composite type of size greater than 16 with a
|
1062
|
+
pointer. */
|
1063
|
+
#ifdef __ILP32__
|
1064
|
+
UINT64 avalue_tmp;
|
1065
|
+
memcpy (&avalue_tmp,
|
1066
|
+
allocate_int_to_reg_or_stack (context, &state,
|
1067
|
+
stack, sizeof (void *)),
|
1068
|
+
sizeof (UINT64));
|
1069
|
+
avalue[i] = (void *)(UINT32)avalue_tmp;
|
1070
|
+
#else
|
1071
|
+
avalue[i] = *(void **)
|
1072
|
+
allocate_int_to_reg_or_stack (context, &state, stack,
|
1073
|
+
sizeof (void *));
|
1074
|
+
#endif
|
1075
|
+
}
|
1076
|
+
else
|
1077
|
+
{
|
1078
|
+
n = (s + 7) / 8;
|
1079
|
+
if (state.ngrn + n <= N_X_ARG_REG)
|
1080
|
+
{
|
1081
|
+
avalue[i] = &context->x[state.ngrn];
|
1082
|
+
state.ngrn += (unsigned int)n;
|
1083
|
+
}
|
1084
|
+
else
|
1085
|
+
{
|
1086
|
+
state.ngrn = N_X_ARG_REG;
|
1087
|
+
avalue[i] = allocate_to_stack(&state, stack,
|
1088
|
+
ty->alignment, s);
|
1089
|
+
}
|
1090
|
+
}
|
1091
|
+
break;
|
1092
|
+
|
1093
|
+
default:
|
1094
|
+
abort();
|
1095
|
+
}
|
923
1096
|
|
924
1097
|
#if defined (__APPLE__)
|
925
1098
|
if (i + 1 == cif->aarch64_nfixedargs)
|
@@ -931,7 +1104,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
931
1104
|
#endif
|
932
1105
|
}
|
933
1106
|
|
934
|
-
flags = cif->flags;
|
935
1107
|
if (flags & AARCH64_RET_IN_MEM)
|
936
1108
|
rvalue = struct_rvalue;
|
937
1109
|
|
@@ -939,3 +1111,19 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
|
|
939
1111
|
|
940
1112
|
return flags;
|
941
1113
|
}
|
1114
|
+
|
1115
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
1116
|
+
void *
|
1117
|
+
ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
|
1118
|
+
{
|
1119
|
+
extern void *trampoline_code_table;
|
1120
|
+
|
1121
|
+
*tramp_size = AARCH64_TRAMP_SIZE;
|
1122
|
+
*map_size = AARCH64_TRAMP_MAP_SIZE;
|
1123
|
+
return &trampoline_code_table;
|
1124
|
+
}
|
1125
|
+
#endif
|
1126
|
+
|
1127
|
+
#endif /* FFI_CLOSURES */
|
1128
|
+
|
1129
|
+
#endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/
|
@@ -32,6 +32,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
32
32
|
#define FFI_SIZEOF_JAVA_RAW 4
|
33
33
|
typedef unsigned long long ffi_arg;
|
34
34
|
typedef signed long long ffi_sarg;
|
35
|
+
#elif defined(_WIN32)
|
36
|
+
#define FFI_SIZEOF_ARG 8
|
37
|
+
typedef unsigned long long ffi_arg;
|
38
|
+
typedef signed long long ffi_sarg;
|
35
39
|
#else
|
36
40
|
typedef unsigned long ffi_arg;
|
37
41
|
typedef signed long ffi_sarg;
|
@@ -41,8 +45,13 @@ typedef enum ffi_abi
|
|
41
45
|
{
|
42
46
|
FFI_FIRST_ABI = 0,
|
43
47
|
FFI_SYSV,
|
48
|
+
FFI_WIN64,
|
44
49
|
FFI_LAST_ABI,
|
50
|
+
#if defined(_WIN32)
|
51
|
+
FFI_DEFAULT_ABI = FFI_WIN64
|
52
|
+
#else
|
45
53
|
FFI_DEFAULT_ABI = FFI_SYSV
|
54
|
+
#endif
|
46
55
|
} ffi_abi;
|
47
56
|
#endif
|
48
57
|
|
@@ -65,17 +74,24 @@ typedef enum ffi_abi
|
|
65
74
|
#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
|
66
75
|
#endif
|
67
76
|
|
77
|
+
#ifdef _WIN32
|
78
|
+
#define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
|
79
|
+
#endif
|
80
|
+
#define FFI_TARGET_SPECIFIC_VARIADIC
|
81
|
+
|
68
82
|
/* ---- Internal ---- */
|
69
83
|
|
70
84
|
#if defined (__APPLE__)
|
71
|
-
#define FFI_TARGET_SPECIFIC_VARIADIC
|
72
85
|
#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
|
73
|
-
#
|
74
|
-
/* iOS
|
86
|
+
#elif !defined(_WIN32)
|
87
|
+
/* iOS and Windows reserve x18 for the system. Disable Go closures until
|
75
88
|
a new static chain is chosen. */
|
76
89
|
#define FFI_GO_CLOSURES 1
|
77
90
|
#endif
|
78
91
|
|
92
|
+
#ifndef _WIN32
|
93
|
+
/* No complex type on Windows */
|
79
94
|
#define FFI_TARGET_HAS_COMPLEX_TYPE
|
95
|
+
#endif
|
80
96
|
|
81
97
|
#endif
|