ffi 1.1.2 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +456 -0
- data/COPYING +49 -0
- data/Gemfile +21 -0
- data/LICENSE +21 -11
- data/LICENSE.SPECS +22 -0
- data/README.md +137 -0
- data/Rakefile +166 -156
- data/ext/ffi_c/AbstractMemory.c +240 -140
- data/ext/ffi_c/AbstractMemory.h +25 -15
- data/ext/ffi_c/ArrayType.c +78 -29
- data/ext/ffi_c/ArrayType.h +22 -12
- data/ext/ffi_c/Buffer.c +121 -60
- data/ext/ffi_c/Call.c +184 -137
- data/ext/ffi_c/Call.h +46 -22
- data/ext/ffi_c/ClosurePool.c +101 -43
- data/ext/ffi_c/ClosurePool.h +24 -13
- data/ext/ffi_c/DynamicLibrary.c +139 -57
- data/ext/ffi_c/DynamicLibrary.h +70 -12
- data/ext/ffi_c/Function.c +372 -273
- data/ext/ffi_c/Function.h +25 -20
- data/ext/ffi_c/FunctionInfo.c +135 -49
- data/ext/ffi_c/LastError.c +97 -30
- data/ext/ffi_c/LastError.h +21 -12
- data/ext/ffi_c/LongDouble.c +15 -9
- data/ext/ffi_c/LongDouble.h +21 -16
- data/ext/ffi_c/MappedType.c +88 -38
- data/ext/ffi_c/MappedType.h +21 -14
- data/ext/ffi_c/MemoryPointer.c +91 -38
- data/ext/ffi_c/MemoryPointer.h +22 -19
- data/ext/ffi_c/MethodHandle.c +52 -51
- data/ext/ffi_c/MethodHandle.h +24 -14
- data/ext/ffi_c/Platform.c +28 -62
- data/ext/ffi_c/Platform.h +21 -12
- data/ext/ffi_c/Pointer.c +145 -86
- data/ext/ffi_c/Pointer.h +23 -19
- data/ext/ffi_c/Struct.c +363 -163
- data/ext/ffi_c/Struct.h +39 -21
- data/ext/ffi_c/StructByValue.c +72 -37
- data/ext/ffi_c/StructByValue.h +21 -12
- data/ext/ffi_c/StructLayout.c +308 -94
- data/ext/ffi_c/Thread.c +73 -270
- data/ext/ffi_c/Thread.h +32 -35
- data/ext/ffi_c/Type.c +147 -84
- data/ext/ffi_c/Type.h +27 -11
- data/ext/ffi_c/Types.c +40 -24
- data/ext/ffi_c/Types.h +24 -21
- data/ext/ffi_c/Variadic.c +148 -64
- data/ext/ffi_c/compat.h +45 -37
- data/ext/ffi_c/extconf.rb +86 -32
- data/ext/ffi_c/ffi.c +32 -21
- data/ext/ffi_c/libffi/.allow-ai-service +0 -0
- 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 +84 -0
- data/ext/ffi_c/libffi/.ci/ar-lib +270 -0
- 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/compile +351 -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/.ci/moxie-sim.exp +60 -0
- 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/issue_template.md +10 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +479 -0
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +172 -0
- data/ext/ffi_c/libffi/.gitignore +46 -0
- data/ext/ffi_c/libffi/{ChangeLog → ChangeLog.old} +6366 -3559
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +353 -0
- data/ext/ffi_c/libffi/Makefile.am +131 -170
- data/ext/ffi_c/libffi/Makefile.in +1317 -1010
- data/ext/ffi_c/libffi/README.md +531 -0
- data/ext/ffi_c/libffi/acinclude.m4 +289 -4
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/compile +222 -17
- data/ext/ffi_c/libffi/config.guess +1033 -780
- data/ext/ffi_c/libffi/config.sub +1393 -1206
- data/ext/ffi_c/libffi/configure +16340 -10740
- data/ext/ffi_c/libffi/configure.ac +226 -271
- data/ext/ffi_c/libffi/configure.host +330 -4
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/Makefile.in +818 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +525 -79
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +41 -52
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +312 -0
- data/ext/ffi_c/libffi/include/Makefile.am +3 -3
- data/ext/ffi_c/libffi/include/Makefile.in +201 -79
- data/ext/ffi_c/libffi/include/ffi.h.in +190 -99
- data/ext/ffi_c/libffi/include/ffi_cfi.h +76 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +72 -14
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +231 -210
- data/ext/ffi_c/libffi/libffi.map.in +81 -0
- data/ext/ffi_c/libffi/libffi.pc.in +3 -2
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +997 -0
- data/ext/ffi_c/libffi/libtool-ldflags +106 -0
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +3868 -2068
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +50 -0
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +47 -25
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +110 -147
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +53 -0
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +75 -19
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +8 -29
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +11 -9
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +104 -52
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +18 -8
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/man/Makefile.am +2 -2
- data/ext/ffi_c/libffi/man/Makefile.in +156 -57
- data/ext/ffi_c/libffi/man/ffi.3 +10 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +6 -4
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
- data/ext/ffi_c/libffi/missing +153 -314
- 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/{include/ffi.h.vc64 → msvc_build/aarch64/aarch64_include/ffi.h} +151 -67
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
- data/ext/ffi_c/libffi/msvcc.sh +176 -20
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +1142 -0
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +97 -0
- data/ext/ffi_c/libffi/src/aarch64/internal.h +100 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +695 -0
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +335 -98
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +10 -1
- data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +161 -266
- data/ext/ffi_c/libffi/src/arc/arcompact.S +210 -0
- data/ext/ffi_c/libffi/src/arc/ffi.c +443 -0
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +67 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +706 -513
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +32 -8
- data/ext/ffi_c/libffi/src/arm/internal.h +17 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +372 -413
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
- data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
- data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
- data/ext/ffi_c/libffi/src/closures.c +565 -73
- data/ext/ffi_c/libffi/src/cris/ffi.c +10 -7
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +6 -1
- 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/debug.c +8 -3
- data/ext/ffi_c/libffi/src/dlmalloc.c +23 -13
- data/ext/ffi_c/libffi/src/frv/ffi.c +2 -2
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +47 -13
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +8 -2
- data/ext/ffi_c/libffi/src/ia64/unix.S +28 -3
- data/ext/ffi_c/libffi/src/java_raw_api.c +23 -5
- 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 +624 -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 +32 -15
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/ffi.c +87 -13
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/sysv.S +119 -32
- data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
- data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
- data/ext/ffi_c/libffi/{fficonfig.hw → src/metag/ffitarget.h} +22 -26
- data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
- data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
- data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +382 -101
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +23 -14
- data/ext/ffi_c/libffi/src/mips/n32.S +321 -89
- data/ext/ffi_c/libffi/src/mips/o32.S +211 -31
- data/ext/ffi_c/libffi/src/moxie/eabi.S +55 -82
- data/ext/ffi_c/libffi/src/moxie/ffi.c +100 -66
- data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
- data/ext/ffi_c/libffi/src/or1k/ffi.c +341 -0
- data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
- data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
- 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 +28 -12
- 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/aix.S +245 -7
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +253 -4
- data/ext/ffi_c/libffi/src/powerpc/asm.h +2 -2
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +2 -7
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +22 -26
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +105 -1378
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +157 -52
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1153 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +105 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +110 -45
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +191 -85
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +438 -108
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +73 -119
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +131 -25
- data/ext/ffi_c/libffi/src/raw_api.c +18 -5
- data/ext/ffi_c/libffi/src/riscv/ffi.c +514 -0
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +69 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +293 -0
- data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +9 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
- data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sparc/ffi.c +326 -527
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +630 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -7
- data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
- data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
- data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
- data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
- data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/types.c +48 -19
- data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
- data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
- data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
- data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
- data/ext/ffi_c/libffi/src/x86/asmnames.h +30 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +686 -498
- data/ext/ffi_c/libffi/src/x86/ffi64.c +444 -129
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +79 -36
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +361 -0
- data/ext/ffi_c/libffi/src/x86/internal.h +43 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +36 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +1198 -394
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +585 -300
- data/ext/ffi_c/libffi/src/x86/win64.S +244 -458
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +238 -0
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +306 -0
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +57 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +268 -0
- data/ext/ffi_c/libffi/stamp-h.in +1 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +80 -73
- data/ext/ffi_c/libffi/testsuite/Makefile.in +233 -117
- 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 +86 -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 +360 -28
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +22 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1746 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +747 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +28 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +52 -42
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +15 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +110 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
- 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 +9 -10
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
- 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/uninitialized.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +78 -0
- 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 +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +140 -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/closure_stdcall.c → libffi.closures/closure_simple.c} +13 -16
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +22 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +26 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +28 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +33 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +8 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +25 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +40 -8
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +23 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +17 -4
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +113 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +26 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +17 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +33 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +29 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +32 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +28 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +43 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +29 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +18 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +18 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +18 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +24 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +44 -31
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +44 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +22 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +22 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +23 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +7 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +19 -10
- 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 +14 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +32 -12
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +55 -0
- 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 +6 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +21 -9
- 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.closures/cls_struct_va1.c +125 -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.closures/cls_uint_va.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +49 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +7 -5
- 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 +41 -40
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +38 -15
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +9 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +19 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +137 -0
- 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 +15 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +15 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +17 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +14 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +17 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +17 -6
- 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_large.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +8 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest.cc +4 -10
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest_ffi_call.cc +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.special/special.exp → libffi.complex/complex.exp} +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
- data/ext/ffi_c/libffi.bsd.mk +13 -7
- data/ext/ffi_c/libffi.darwin.mk +25 -13
- data/ext/ffi_c/libffi.gnu.mk +4 -3
- data/ext/ffi_c/libffi.mk +11 -6
- data/ext/ffi_c/libffi.vc.mk +1 -1
- data/ext/ffi_c/libffi.vc64.mk +1 -1
- data/ext/ffi_c/rbffi.h +23 -15
- data/ext/ffi_c/rbffi_endian.h +11 -2
- data/ffi.gemspec +42 -0
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +65 -68
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/dynamic_library.rb +118 -0
- data/lib/ffi/enum.rb +166 -25
- data/lib/ffi/errno.rb +21 -11
- data/lib/ffi/ffi.rb +28 -11
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/io.rb +25 -15
- data/lib/ffi/library.rb +227 -136
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +64 -35
- 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 +175 -0
- 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 +3 -0
- 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-linux/types.conf +77 -77
- data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
- data/lib/ffi/platform/i386-openbsd/types.conf +89 -87
- 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 +104 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
- 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 +104 -0
- 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-linux/types.conf +102 -0
- 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 +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +93 -63
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -88
- 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 -87
- data/lib/ffi/platform/x86_64-openbsd/types.conf +100 -92
- data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
- data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
- data/lib/ffi/platform.rb +91 -34
- data/lib/ffi/pointer.rb +78 -33
- data/lib/ffi/struct.rb +100 -66
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +84 -19
- data/lib/ffi/tools/const_generator.rb +11 -8
- data/lib/ffi/tools/generator.rb +48 -1
- data/lib/ffi/tools/generator_task.rb +13 -16
- data/lib/ffi/tools/struct_generator.rb +6 -5
- data/lib/ffi/tools/types_generator.rb +14 -10
- data/lib/ffi/types.rb +96 -51
- data/lib/ffi/union.rb +23 -12
- data/lib/ffi/variadic.rb +44 -29
- data/lib/ffi/version.rb +3 -0
- data/lib/ffi.rb +20 -8
- data/rakelib/ffi_gem_helper.rb +65 -0
- data/samples/getlogin.rb +8 -0
- data/samples/getpid.rb +8 -0
- data/samples/gettimeofday.rb +18 -0
- data/samples/hello.rb +8 -0
- data/samples/hello_ractor.rb +11 -0
- data/samples/inotify.rb +60 -0
- data/samples/pty.rb +75 -0
- data/samples/qsort.rb +20 -0
- data/samples/qsort_ractor.rb +28 -0
- data/sig/ffi/abstract_memory.rbs +165 -0
- data/sig/ffi/auto_pointer.rbs +27 -0
- data/sig/ffi/buffer.rbs +18 -0
- data/sig/ffi/data_converter.rbs +10 -0
- data/sig/ffi/dynamic_library.rbs +9 -0
- data/sig/ffi/enum.rbs +38 -0
- data/sig/ffi/function.rbs +39 -0
- data/sig/ffi/library.rbs +42 -0
- data/sig/ffi/native_type.rbs +86 -0
- data/sig/ffi/pointer.rbs +42 -0
- data/sig/ffi/struct.rbs +76 -0
- data/sig/ffi/struct_by_reference.rbs +11 -0
- data/sig/ffi/struct_by_value.rbs +7 -0
- data/sig/ffi/struct_layout.rbs +9 -0
- data/sig/ffi/struct_layout_builder.rbs +5 -0
- data/sig/ffi/type.rbs +39 -0
- data/sig/ffi.rbs +26 -0
- data.tar.gz.sig +0 -0
- metadata +508 -268
- metadata.gz.sig +1 -0
- data/History.txt +0 -1
- data/README.rdoc +0 -102
- data/ext/ffi_c/DataConverter.c +0 -91
- data/ext/ffi_c/Ffi_c.iml +0 -12
- data/ext/ffi_c/StructByReference.c +0 -158
- 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/libffi/Makefile.vc +0 -141
- data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
- data/ext/ffi_c/libffi/README +0 -342
- data/ext/ffi_c/libffi/aclocal.m4 +0 -1873
- data/ext/ffi_c/libffi/build-ios.sh +0 -67
- data/ext/ffi_c/libffi/depcomp +0 -630
- data/ext/ffi_c/libffi/doc/libffi.info +0 -593
- data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
- data/ext/ffi_c/libffi/include/ffi.h.vc +0 -427
- data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +0 -76
- data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7831
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -369
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
- data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -98
- data/ext/ffi_c/libffi/mdate-sh +0 -201
- data/ext/ffi_c/libffi/src/arm/gentramp.sh +0 -118
- data/ext/ffi_c/libffi/src/arm/trampoline.S +0 -4450
- data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
- data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
- data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
- data/ext/ffi_c/libffi/src/x86/win32.S +0 -1065
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
- data/ext/ffi_c/libffi/texinfo.tex +0 -7210
- data/ext/ffi_c/win32/stdint.h +0 -199
- data/gen/Rakefile +0 -30
- data/lib/Lib.iml +0 -13
- data/spec/ffi/Ffi.iml +0 -12
- data/spec/ffi/async_callback_spec.rb +0 -46
- data/spec/ffi/bool_spec.rb +0 -40
- data/spec/ffi/buffer_spec.rb +0 -215
- data/spec/ffi/callback_spec.rb +0 -668
- data/spec/ffi/custom_param_type.rb +0 -47
- data/spec/ffi/custom_type_spec.rb +0 -85
- data/spec/ffi/dup_spec.rb +0 -65
- data/spec/ffi/enum_spec.rb +0 -227
- data/spec/ffi/errno_spec.rb +0 -29
- data/spec/ffi/ffi_spec.rb +0 -40
- data/spec/ffi/function_spec.rb +0 -87
- data/spec/ffi/library_spec.rb +0 -208
- data/spec/ffi/long_double.rb +0 -41
- data/spec/ffi/managed_struct_spec.rb +0 -72
- data/spec/ffi/number_spec.rb +0 -247
- data/spec/ffi/pointer_spec.rb +0 -214
- data/spec/ffi/rbx/attach_function_spec.rb +0 -28
- data/spec/ffi/rbx/memory_pointer_spec.rb +0 -111
- data/spec/ffi/rbx/spec_helper.rb +0 -1
- data/spec/ffi/rbx/struct_spec.rb +0 -13
- data/spec/ffi/spec_helper.rb +0 -35
- data/spec/ffi/string_spec.rb +0 -119
- data/spec/ffi/strptr_spec.rb +0 -61
- data/spec/ffi/struct_callback_spec.rb +0 -80
- data/spec/ffi/struct_initialize_spec.rb +0 -46
- data/spec/ffi/struct_packed_spec.rb +0 -62
- data/spec/ffi/struct_spec.rb +0 -719
- data/spec/ffi/typedef_spec.rb +0 -89
- data/spec/ffi/union_spec.rb +0 -76
- data/spec/ffi/variadic_spec.rb +0 -103
- data/spec/spec.opts +0 -4
- data/tasks/ann.rake +0 -80
- data/tasks/extension.rake +0 -32
- data/tasks/gem.rake +0 -199
- data/tasks/git.rake +0 -41
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -50
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -301
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/yard.rake +0 -11
- 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}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/lib/ffi/platform/{i486-gnu → i386-gnu}/types.conf +84 -84
@@ -1,10 +1,11 @@
|
|
1
1
|
/* -----------------------------------------------------------------------
|
2
|
-
ffi.c - Copyright (c) 2011
|
2
|
+
ffi.c - Copyright (c) 2011 Timothy Wall
|
3
|
+
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
|
3
4
|
Copyright (c) 2011 Anthony Green
|
4
5
|
Copyright (c) 2011 Free Software Foundation
|
5
6
|
Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
|
6
|
-
|
7
|
-
ARM Foreign Function Interface
|
7
|
+
|
8
|
+
ARM Foreign Function Interface
|
8
9
|
|
9
10
|
Permission is hereby granted, free of charge, to any person obtaining
|
10
11
|
a copy of this software and associated documentation files (the
|
@@ -27,660 +28,833 @@
|
|
27
28
|
DEALINGS IN THE SOFTWARE.
|
28
29
|
----------------------------------------------------------------------- */
|
29
30
|
|
31
|
+
#if defined(__arm__) || defined(_M_ARM)
|
32
|
+
#include <fficonfig.h>
|
30
33
|
#include <ffi.h>
|
31
34
|
#include <ffi_common.h>
|
32
|
-
|
35
|
+
#include <stdint.h>
|
33
36
|
#include <stdlib.h>
|
37
|
+
#include <tramp.h>
|
38
|
+
#include "internal.h"
|
39
|
+
|
40
|
+
#if defined(_WIN32)
|
41
|
+
#define WIN32_LEAN_AND_MEAN
|
42
|
+
#include <windows.h>
|
43
|
+
#endif
|
44
|
+
|
45
|
+
#if FFI_EXEC_TRAMPOLINE_TABLE
|
46
|
+
|
47
|
+
#ifdef __MACH__
|
48
|
+
#include <mach/machine/vm_param.h>
|
49
|
+
#endif
|
50
|
+
|
51
|
+
#else
|
52
|
+
#ifndef _WIN32
|
53
|
+
extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN;
|
54
|
+
#else
|
55
|
+
// Declare this as an array of char, instead of array of int,
|
56
|
+
// otherwise Clang optimizes out the "& 0xFFFFFFFE" for clearing
|
57
|
+
// the thumb bit.
|
58
|
+
extern unsigned char ffi_arm_trampoline[12] FFI_HIDDEN;
|
59
|
+
#endif
|
60
|
+
#endif
|
61
|
+
|
62
|
+
#if defined(__FreeBSD__) && defined(__arm__)
|
63
|
+
#include <sys/types.h>
|
64
|
+
#include <machine/sysarch.h>
|
65
|
+
#endif
|
66
|
+
|
67
|
+
#if defined(__QNX__)
|
68
|
+
#include <sys/mman.h>
|
69
|
+
#endif
|
34
70
|
|
35
71
|
/* Forward declares. */
|
36
|
-
static int vfp_type_p (ffi_type *);
|
72
|
+
static int vfp_type_p (const ffi_type *);
|
37
73
|
static void layout_vfp_args (ffi_cif *);
|
38
74
|
|
39
|
-
|
40
|
-
|
41
|
-
|
75
|
+
static void *
|
76
|
+
ffi_align (ffi_type *ty, void *p)
|
77
|
+
{
|
78
|
+
/* Align if necessary */
|
79
|
+
size_t alignment;
|
80
|
+
#ifdef _WIN32_WCE
|
81
|
+
alignment = 4;
|
82
|
+
#else
|
83
|
+
alignment = ty->alignment;
|
84
|
+
if (alignment < 4)
|
85
|
+
alignment = 4;
|
86
|
+
#endif
|
87
|
+
return (void *) FFI_ALIGN (p, alignment);
|
88
|
+
}
|
89
|
+
|
90
|
+
static size_t
|
91
|
+
ffi_put_arg (ffi_type *ty, void *src, void *dst)
|
92
|
+
{
|
93
|
+
size_t z = ty->size;
|
94
|
+
|
95
|
+
switch (ty->type)
|
96
|
+
{
|
97
|
+
case FFI_TYPE_SINT8:
|
98
|
+
*(UINT32 *)dst = *(SINT8 *)src;
|
99
|
+
break;
|
100
|
+
case FFI_TYPE_UINT8:
|
101
|
+
*(UINT32 *)dst = *(UINT8 *)src;
|
102
|
+
break;
|
103
|
+
case FFI_TYPE_SINT16:
|
104
|
+
*(UINT32 *)dst = *(SINT16 *)src;
|
105
|
+
break;
|
106
|
+
case FFI_TYPE_UINT16:
|
107
|
+
*(UINT32 *)dst = *(UINT16 *)src;
|
108
|
+
break;
|
109
|
+
|
110
|
+
case FFI_TYPE_INT:
|
111
|
+
case FFI_TYPE_SINT32:
|
112
|
+
case FFI_TYPE_UINT32:
|
113
|
+
case FFI_TYPE_POINTER:
|
114
|
+
#ifndef _WIN32
|
115
|
+
case FFI_TYPE_FLOAT:
|
116
|
+
#endif
|
117
|
+
*(UINT32 *)dst = *(UINT32 *)src;
|
118
|
+
break;
|
119
|
+
|
120
|
+
#ifdef _WIN32
|
121
|
+
// casting a float* to a UINT32* doesn't work on Windows
|
122
|
+
case FFI_TYPE_FLOAT:
|
123
|
+
*(uintptr_t *)dst = 0;
|
124
|
+
*(float *)dst = *(float *)src;
|
125
|
+
break;
|
126
|
+
#endif
|
127
|
+
|
128
|
+
case FFI_TYPE_SINT64:
|
129
|
+
case FFI_TYPE_UINT64:
|
130
|
+
case FFI_TYPE_DOUBLE:
|
131
|
+
*(UINT64 *)dst = *(UINT64 *)src;
|
132
|
+
break;
|
133
|
+
|
134
|
+
case FFI_TYPE_STRUCT:
|
135
|
+
case FFI_TYPE_COMPLEX:
|
136
|
+
memcpy (dst, src, z);
|
137
|
+
break;
|
138
|
+
|
139
|
+
default:
|
140
|
+
abort();
|
141
|
+
}
|
142
|
+
|
143
|
+
return FFI_ALIGN (z, 4);
|
144
|
+
}
|
145
|
+
|
146
|
+
/* ffi_prep_args is called once stack space has been allocated
|
147
|
+
for the function's arguments.
|
148
|
+
|
42
149
|
The vfp_space parameter is the load area for VFP regs, the return
|
43
150
|
value is cif->vfp_used (word bitset of VFP regs used for passing
|
44
151
|
arguments). These are only used for the VFP hard-float ABI.
|
45
152
|
*/
|
46
|
-
|
153
|
+
static void
|
154
|
+
ffi_prep_args_SYSV (ffi_cif *cif, int flags, void *rvalue,
|
155
|
+
void **avalue, char *argp)
|
47
156
|
{
|
48
|
-
|
49
|
-
|
50
|
-
register char *argp;
|
51
|
-
register ffi_type **p_arg;
|
157
|
+
ffi_type **arg_types = cif->arg_types;
|
158
|
+
int i, n;
|
52
159
|
|
53
|
-
|
160
|
+
if (flags == ARM_TYPE_STRUCT)
|
161
|
+
{
|
162
|
+
*(void **) argp = rvalue;
|
163
|
+
argp += 4;
|
164
|
+
}
|
54
165
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
166
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
167
|
+
{
|
168
|
+
ffi_type *ty = arg_types[i];
|
169
|
+
argp = ffi_align (ty, argp);
|
170
|
+
argp += ffi_put_arg (ty, avalue[i], argp);
|
171
|
+
}
|
172
|
+
}
|
59
173
|
|
60
|
-
|
174
|
+
static void
|
175
|
+
ffi_prep_args_VFP (ffi_cif *cif, int flags, void *rvalue,
|
176
|
+
void **avalue, char *stack, char *vfp_space)
|
177
|
+
{
|
178
|
+
ffi_type **arg_types = cif->arg_types;
|
179
|
+
int i, n, vi = 0;
|
180
|
+
char *argp, *regp, *eo_regp;
|
181
|
+
char stack_used = 0;
|
182
|
+
char done_with_regs = 0;
|
183
|
+
|
184
|
+
/* The first 4 words on the stack are used for values
|
185
|
+
passed in core registers. */
|
186
|
+
regp = stack;
|
187
|
+
eo_regp = argp = regp + 16;
|
188
|
+
|
189
|
+
/* If the function returns an FFI_TYPE_STRUCT in memory,
|
190
|
+
that address is passed in r0 to the function. */
|
191
|
+
if (flags == ARM_TYPE_STRUCT)
|
192
|
+
{
|
193
|
+
*(void **) regp = rvalue;
|
194
|
+
regp += 4;
|
195
|
+
}
|
61
196
|
|
62
|
-
for (i =
|
63
|
-
(i != 0);
|
64
|
-
i--, p_arg++)
|
197
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
65
198
|
{
|
66
|
-
|
199
|
+
ffi_type *ty = arg_types[i];
|
200
|
+
void *a = avalue[i];
|
201
|
+
int is_vfp_type = vfp_type_p (ty);
|
67
202
|
|
68
203
|
/* Allocated in VFP registers. */
|
69
|
-
if (
|
70
|
-
&& vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
|
204
|
+
if (vi < cif->vfp_nargs && is_vfp_type)
|
71
205
|
{
|
72
|
-
|
73
|
-
|
74
|
-
*((float*)vfp_slot) = *((float*)*p_argv);
|
75
|
-
else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
|
76
|
-
*((double*)vfp_slot) = *((double*)*p_argv);
|
77
|
-
else
|
78
|
-
memcpy(vfp_slot, *p_argv, (*p_arg)->size);
|
79
|
-
p_argv++;
|
206
|
+
char *vfp_slot = vfp_space + cif->vfp_args[vi++] * 4;
|
207
|
+
ffi_put_arg (ty, a, vfp_slot);
|
80
208
|
continue;
|
81
209
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
z = (*p_arg)->size;
|
92
|
-
if (z < sizeof(int))
|
93
|
-
{
|
94
|
-
z = sizeof(int);
|
95
|
-
switch ((*p_arg)->type)
|
96
|
-
{
|
97
|
-
case FFI_TYPE_SINT8:
|
98
|
-
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
|
99
|
-
break;
|
100
|
-
|
101
|
-
case FFI_TYPE_UINT8:
|
102
|
-
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
|
103
|
-
break;
|
104
|
-
|
105
|
-
case FFI_TYPE_SINT16:
|
106
|
-
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
|
107
|
-
break;
|
108
|
-
|
109
|
-
case FFI_TYPE_UINT16:
|
110
|
-
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
|
111
|
-
break;
|
112
|
-
|
113
|
-
case FFI_TYPE_STRUCT:
|
114
|
-
memcpy(argp, *p_argv, (*p_arg)->size);
|
115
|
-
break;
|
116
|
-
|
117
|
-
default:
|
118
|
-
FFI_ASSERT(0);
|
119
|
-
}
|
120
|
-
}
|
121
|
-
else if (z == sizeof(int))
|
210
|
+
/* Try allocating in core registers. */
|
211
|
+
else if (!done_with_regs && !is_vfp_type)
|
212
|
+
{
|
213
|
+
char *tregp = ffi_align (ty, regp);
|
214
|
+
size_t size = ty->size;
|
215
|
+
size = (size < 4) ? 4 : size; // pad
|
216
|
+
/* Check if there is space left in the aligned register
|
217
|
+
area to place the argument. */
|
218
|
+
if (tregp + size <= eo_regp)
|
122
219
|
{
|
123
|
-
|
220
|
+
regp = tregp + ffi_put_arg (ty, a, tregp);
|
221
|
+
done_with_regs = (regp == argp);
|
222
|
+
// ensure we did not write into the stack area
|
223
|
+
FFI_ASSERT (regp <= argp);
|
224
|
+
continue;
|
124
225
|
}
|
125
|
-
|
226
|
+
/* In case there are no arguments in the stack area yet,
|
227
|
+
the argument is passed in the remaining core registers
|
228
|
+
and on the stack. */
|
229
|
+
else if (!stack_used)
|
126
230
|
{
|
127
|
-
|
231
|
+
stack_used = 1;
|
232
|
+
done_with_regs = 1;
|
233
|
+
argp = tregp + ffi_put_arg (ty, a, tregp);
|
234
|
+
FFI_ASSERT (eo_regp < argp);
|
235
|
+
continue;
|
128
236
|
}
|
129
|
-
|
130
|
-
|
237
|
+
}
|
238
|
+
/* Base case, arguments are passed on the stack */
|
239
|
+
stack_used = 1;
|
240
|
+
argp = ffi_align (ty, argp);
|
241
|
+
argp += ffi_put_arg (ty, a, argp);
|
131
242
|
}
|
132
|
-
|
133
|
-
/* Indicate the VFP registers used. */
|
134
|
-
return ecif->cif->vfp_used;
|
135
243
|
}
|
136
244
|
|
137
245
|
/* Perform machine dependent cif processing */
|
138
|
-
ffi_status
|
246
|
+
ffi_status FFI_HIDDEN
|
247
|
+
ffi_prep_cif_machdep (ffi_cif *cif)
|
139
248
|
{
|
140
|
-
int
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
249
|
+
int flags = 0, cabi = cif->abi;
|
250
|
+
size_t bytes = cif->bytes;
|
251
|
+
|
252
|
+
/* Map out the register placements of VFP register args. The VFP
|
253
|
+
hard-float calling conventions are slightly more sophisticated
|
254
|
+
than the base calling conventions, so we do it here instead of
|
255
|
+
in ffi_prep_args(). */
|
256
|
+
if (cabi == FFI_VFP)
|
257
|
+
layout_vfp_args (cif);
|
145
258
|
|
146
259
|
/* Set the return type flag */
|
147
260
|
switch (cif->rtype->type)
|
148
261
|
{
|
149
262
|
case FFI_TYPE_VOID:
|
150
|
-
|
151
|
-
|
152
|
-
|
263
|
+
flags = ARM_TYPE_VOID;
|
264
|
+
break;
|
265
|
+
|
266
|
+
case FFI_TYPE_INT:
|
267
|
+
case FFI_TYPE_UINT8:
|
268
|
+
case FFI_TYPE_SINT8:
|
269
|
+
case FFI_TYPE_UINT16:
|
270
|
+
case FFI_TYPE_SINT16:
|
271
|
+
case FFI_TYPE_UINT32:
|
272
|
+
case FFI_TYPE_SINT32:
|
273
|
+
case FFI_TYPE_POINTER:
|
274
|
+
flags = ARM_TYPE_INT;
|
153
275
|
break;
|
154
276
|
|
155
277
|
case FFI_TYPE_SINT64:
|
156
278
|
case FFI_TYPE_UINT64:
|
157
|
-
|
279
|
+
flags = ARM_TYPE_INT64;
|
280
|
+
break;
|
281
|
+
|
282
|
+
case FFI_TYPE_FLOAT:
|
283
|
+
flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_S : ARM_TYPE_INT);
|
284
|
+
break;
|
285
|
+
case FFI_TYPE_DOUBLE:
|
286
|
+
flags = (cabi == FFI_VFP ? ARM_TYPE_VFP_D : ARM_TYPE_INT64);
|
158
287
|
break;
|
159
288
|
|
160
289
|
case FFI_TYPE_STRUCT:
|
161
|
-
|
162
|
-
|
290
|
+
case FFI_TYPE_COMPLEX:
|
291
|
+
if (cabi == FFI_VFP)
|
163
292
|
{
|
164
|
-
|
165
|
-
|
166
|
-
|
293
|
+
int h = vfp_type_p (cif->rtype);
|
294
|
+
|
295
|
+
flags = ARM_TYPE_VFP_N;
|
296
|
+
if (h == 0x100 + FFI_TYPE_FLOAT)
|
297
|
+
flags = ARM_TYPE_VFP_S;
|
298
|
+
if (h == 0x100 + FFI_TYPE_DOUBLE)
|
299
|
+
flags = ARM_TYPE_VFP_D;
|
300
|
+
if (h != 0)
|
301
|
+
break;
|
167
302
|
}
|
168
|
-
|
169
|
-
|
170
|
-
|
303
|
+
|
304
|
+
/* A Composite Type not larger than 4 bytes is returned in r0.
|
305
|
+
A Composite Type larger than 4 bytes, or whose size cannot
|
306
|
+
be determined statically ... is stored in memory at an
|
307
|
+
address passed [in r0]. */
|
308
|
+
if (cif->rtype->size <= 4)
|
309
|
+
flags = ARM_TYPE_INT;
|
171
310
|
else
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
311
|
+
{
|
312
|
+
flags = ARM_TYPE_STRUCT;
|
313
|
+
bytes += 4;
|
314
|
+
}
|
176
315
|
break;
|
177
316
|
|
178
317
|
default:
|
179
|
-
|
180
|
-
break;
|
318
|
+
abort();
|
181
319
|
}
|
182
320
|
|
183
|
-
/*
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
321
|
+
/* Round the stack up to a multiple of 8 bytes. This isn't needed
|
322
|
+
everywhere, but it is on some platforms, and it doesn't harm anything
|
323
|
+
when it isn't needed. */
|
324
|
+
bytes = FFI_ALIGN (bytes, 8);
|
325
|
+
|
326
|
+
/* Minimum stack space is the 4 register arguments that we pop. */
|
327
|
+
if (bytes < 4*4)
|
328
|
+
bytes = 4*4;
|
329
|
+
|
330
|
+
cif->bytes = bytes;
|
331
|
+
cif->flags = flags;
|
188
332
|
|
189
333
|
return FFI_OK;
|
190
334
|
}
|
191
335
|
|
192
|
-
/*
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
336
|
+
/* Perform machine dependent cif processing for variadic calls */
|
337
|
+
ffi_status FFI_HIDDEN
|
338
|
+
ffi_prep_cif_machdep_var (ffi_cif * cif,
|
339
|
+
unsigned int nfixedargs, unsigned int ntotalargs)
|
197
340
|
{
|
198
|
-
|
341
|
+
/* VFP variadic calls actually use the SYSV ABI */
|
342
|
+
if (cif->abi == FFI_VFP)
|
343
|
+
cif->abi = FFI_SYSV;
|
344
|
+
|
345
|
+
return ffi_prep_cif_machdep (cif);
|
346
|
+
}
|
199
347
|
|
200
|
-
|
201
|
-
&& cif->rtype->type == FFI_TYPE_STRUCT);
|
202
|
-
int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT
|
203
|
-
|| cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE);
|
348
|
+
/* Prototypes for assembly functions, in sysv.S. */
|
204
349
|
|
205
|
-
|
206
|
-
|
350
|
+
struct call_frame
|
351
|
+
{
|
352
|
+
void *fp;
|
353
|
+
void *lr;
|
354
|
+
void *rvalue;
|
355
|
+
int flags;
|
356
|
+
void *closure;
|
357
|
+
};
|
207
358
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
359
|
+
extern void ffi_call_SYSV (void *stack, struct call_frame *,
|
360
|
+
void (*fn) (void)) FFI_HIDDEN;
|
361
|
+
extern void ffi_call_VFP (void *vfp_space, struct call_frame *,
|
362
|
+
void (*fn) (void), unsigned vfp_used) FFI_HIDDEN;
|
212
363
|
|
213
|
-
|
214
|
-
|
364
|
+
static void
|
365
|
+
ffi_call_int (ffi_cif * cif, void (*fn) (void), void *rvalue,
|
366
|
+
void **avalue, void *closure)
|
367
|
+
{
|
368
|
+
int flags = cif->flags;
|
369
|
+
ffi_type *rtype = cif->rtype;
|
370
|
+
size_t bytes, rsize, vfp_size;
|
371
|
+
char *stack, *vfp_space, *new_rvalue;
|
372
|
+
struct call_frame *frame;
|
373
|
+
|
374
|
+
rsize = 0;
|
375
|
+
if (rvalue == NULL)
|
215
376
|
{
|
216
|
-
|
377
|
+
/* If the return value is a struct and we don't have a return
|
378
|
+
value address then we need to make one. Otherwise the return
|
379
|
+
value is in registers and we can ignore them. */
|
380
|
+
if (flags == ARM_TYPE_STRUCT)
|
381
|
+
rsize = rtype->size;
|
382
|
+
else
|
383
|
+
flags = ARM_TYPE_VOID;
|
217
384
|
}
|
218
|
-
else if (
|
219
|
-
ecif.rvalue = &temp;
|
220
|
-
else if (vfp_struct)
|
385
|
+
else if (flags == ARM_TYPE_VFP_N)
|
221
386
|
{
|
222
387
|
/* Largest case is double x 4. */
|
223
|
-
|
388
|
+
rsize = 32;
|
224
389
|
}
|
225
|
-
else
|
226
|
-
|
390
|
+
else if (flags == ARM_TYPE_INT && rtype->type == FFI_TYPE_STRUCT)
|
391
|
+
rsize = 4;
|
227
392
|
|
228
|
-
|
229
|
-
|
230
|
-
case FFI_SYSV:
|
231
|
-
ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
|
232
|
-
break;
|
393
|
+
/* Largest case. */
|
394
|
+
vfp_size = (cif->abi == FFI_VFP && cif->vfp_used ? 8*8: 0);
|
233
395
|
|
234
|
-
|
235
|
-
|
236
|
-
break;
|
396
|
+
bytes = cif->bytes;
|
397
|
+
stack = alloca (vfp_size + bytes + sizeof(struct call_frame) + rsize);
|
237
398
|
|
238
|
-
|
239
|
-
|
240
|
-
|
399
|
+
vfp_space = NULL;
|
400
|
+
if (vfp_size)
|
401
|
+
{
|
402
|
+
vfp_space = stack;
|
403
|
+
stack += vfp_size;
|
241
404
|
}
|
242
|
-
if (small_struct)
|
243
|
-
memcpy (rvalue, &temp, cif->rtype->size);
|
244
|
-
else if (vfp_struct)
|
245
|
-
memcpy (rvalue, ecif.rvalue, cif->rtype->size);
|
246
|
-
}
|
247
405
|
|
248
|
-
|
406
|
+
frame = (struct call_frame *)(stack + bytes);
|
407
|
+
|
408
|
+
new_rvalue = rvalue;
|
409
|
+
if (rsize)
|
410
|
+
new_rvalue = (void *)(frame + 1);
|
249
411
|
|
250
|
-
|
251
|
-
|
412
|
+
frame->rvalue = new_rvalue;
|
413
|
+
frame->flags = flags;
|
414
|
+
frame->closure = closure;
|
252
415
|
|
253
|
-
|
416
|
+
if (vfp_space)
|
417
|
+
{
|
418
|
+
ffi_prep_args_VFP (cif, flags, new_rvalue, avalue, stack, vfp_space);
|
419
|
+
ffi_call_VFP (vfp_space, frame, fn, cif->vfp_used);
|
420
|
+
}
|
421
|
+
else
|
422
|
+
{
|
423
|
+
ffi_prep_args_SYSV (cif, flags, new_rvalue, avalue, stack);
|
424
|
+
ffi_call_SYSV (stack, frame, fn);
|
425
|
+
}
|
254
426
|
|
255
|
-
|
427
|
+
if (rvalue && rvalue != new_rvalue)
|
428
|
+
memcpy (rvalue, new_rvalue, rtype->size);
|
429
|
+
}
|
256
430
|
|
257
|
-
|
431
|
+
void
|
432
|
+
ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
|
433
|
+
{
|
434
|
+
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
435
|
+
}
|
258
436
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
void *args;
|
264
|
-
void *vfp_args;
|
437
|
+
#ifdef FFI_GO_CLOSURES
|
438
|
+
void
|
439
|
+
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
|
440
|
+
void **avalue, void *closure)
|
265
441
|
{
|
266
|
-
|
267
|
-
|
268
|
-
|
442
|
+
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
443
|
+
}
|
444
|
+
#endif
|
269
445
|
|
270
|
-
|
271
|
-
|
446
|
+
static void *
|
447
|
+
ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue,
|
448
|
+
char *argp, void **avalue)
|
449
|
+
{
|
450
|
+
ffi_type **arg_types = cif->arg_types;
|
451
|
+
int i, n;
|
272
452
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
453
|
+
if (cif->flags == ARM_TYPE_STRUCT)
|
454
|
+
{
|
455
|
+
rvalue = *(void **) argp;
|
456
|
+
argp += 4;
|
457
|
+
}
|
458
|
+
else
|
459
|
+
{
|
460
|
+
if (cif->rtype->size && cif->rtype->size < 4)
|
461
|
+
*(uint32_t *) rvalue = 0;
|
462
|
+
}
|
278
463
|
|
279
|
-
|
464
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
465
|
+
{
|
466
|
+
ffi_type *ty = arg_types[i];
|
467
|
+
size_t z = ty->size;
|
280
468
|
|
281
|
-
|
469
|
+
argp = ffi_align (ty, argp);
|
470
|
+
avalue[i] = (void *) argp;
|
471
|
+
argp += z;
|
472
|
+
}
|
282
473
|
|
283
|
-
return
|
474
|
+
return rvalue;
|
284
475
|
}
|
285
476
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
void **avalue, ffi_cif *cif,
|
290
|
-
/* Used only under VFP hard-float ABI. */
|
291
|
-
float *vfp_stack)
|
292
|
-
/*@=exportheader@*/
|
477
|
+
static void *
|
478
|
+
ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack,
|
479
|
+
char *vfp_space, void **avalue)
|
293
480
|
{
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
481
|
+
ffi_type **arg_types = cif->arg_types;
|
482
|
+
int i, n, vi = 0;
|
483
|
+
char *argp, *regp, *eo_regp;
|
484
|
+
char done_with_regs = 0;
|
485
|
+
char stack_used = 0;
|
298
486
|
|
299
|
-
|
487
|
+
regp = stack;
|
488
|
+
eo_regp = argp = regp + 16;
|
300
489
|
|
301
|
-
if (
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
p_argv = avalue;
|
490
|
+
if (cif->flags == ARM_TYPE_STRUCT)
|
491
|
+
{
|
492
|
+
rvalue = *(void **) regp;
|
493
|
+
regp += 4;
|
494
|
+
}
|
307
495
|
|
308
|
-
for (i =
|
496
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
309
497
|
{
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
498
|
+
ffi_type *ty = arg_types[i];
|
499
|
+
int is_vfp_type = vfp_type_p (ty);
|
500
|
+
size_t z = ty->size;
|
501
|
+
|
502
|
+
if (vi < cif->vfp_nargs && is_vfp_type)
|
315
503
|
{
|
316
|
-
|
504
|
+
avalue[i] = vfp_space + cif->vfp_args[vi++] * 4;
|
317
505
|
continue;
|
318
506
|
}
|
507
|
+
else if (!done_with_regs && !is_vfp_type)
|
508
|
+
{
|
509
|
+
char *tregp = ffi_align (ty, regp);
|
319
510
|
|
320
|
-
|
321
|
-
if (alignment < 4)
|
322
|
-
alignment = 4;
|
323
|
-
/* Align if necessary */
|
324
|
-
if ((alignment - 1) & (unsigned) argp) {
|
325
|
-
argp = (char *) ALIGN(argp, alignment);
|
326
|
-
}
|
327
|
-
|
328
|
-
z = (*p_arg)->size;
|
329
|
-
|
330
|
-
/* because we're little endian, this is what it turns into. */
|
511
|
+
z = (z < 4) ? 4 : z; // pad
|
331
512
|
|
332
|
-
|
513
|
+
/* If the arguments either fits into the registers or uses registers
|
514
|
+
and stack, while we haven't read other things from the stack */
|
515
|
+
if (tregp + z <= eo_regp || !stack_used)
|
516
|
+
{
|
517
|
+
/* Because we're little endian, this is what it turns into. */
|
518
|
+
avalue[i] = (void *) tregp;
|
519
|
+
regp = tregp + z;
|
520
|
+
|
521
|
+
/* If we read past the last core register, make sure we
|
522
|
+
have not read from the stack before and continue
|
523
|
+
reading after regp. */
|
524
|
+
if (regp > eo_regp)
|
525
|
+
{
|
526
|
+
FFI_ASSERT (!stack_used);
|
527
|
+
argp = regp;
|
528
|
+
}
|
529
|
+
if (regp >= eo_regp)
|
530
|
+
{
|
531
|
+
done_with_regs = 1;
|
532
|
+
stack_used = 1;
|
533
|
+
}
|
534
|
+
continue;
|
535
|
+
}
|
536
|
+
}
|
333
537
|
|
334
|
-
|
538
|
+
stack_used = 1;
|
539
|
+
argp = ffi_align (ty, argp);
|
540
|
+
avalue[i] = (void *) argp;
|
335
541
|
argp += z;
|
336
542
|
}
|
337
|
-
|
338
|
-
return;
|
339
|
-
}
|
340
|
-
|
341
|
-
/* How to make a trampoline. */
|
342
543
|
|
343
|
-
|
344
|
-
|
345
|
-
#include <mach/mach.h>
|
346
|
-
#include <pthread.h>
|
347
|
-
#include <stdio.h>
|
348
|
-
#include <stdlib.h>
|
349
|
-
|
350
|
-
extern void *ffi_closure_trampoline_table_page;
|
351
|
-
|
352
|
-
typedef struct ffi_trampoline_table ffi_trampoline_table;
|
353
|
-
typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry;
|
354
|
-
|
355
|
-
struct ffi_trampoline_table {
|
356
|
-
/* contigious writable and executable pages */
|
357
|
-
vm_address_t config_page;
|
358
|
-
vm_address_t trampoline_page;
|
359
|
-
|
360
|
-
/* free list tracking */
|
361
|
-
uint16_t free_count;
|
362
|
-
ffi_trampoline_table_entry *free_list;
|
363
|
-
ffi_trampoline_table_entry *free_list_pool;
|
544
|
+
return rvalue;
|
545
|
+
}
|
364
546
|
|
365
|
-
|
366
|
-
ffi_trampoline_table *next;
|
367
|
-
};
|
547
|
+
#if FFI_CLOSURES
|
368
548
|
|
369
|
-
struct
|
370
|
-
|
371
|
-
|
549
|
+
struct closure_frame
|
550
|
+
{
|
551
|
+
char vfp_space[8*8] __attribute__((aligned(8)));
|
552
|
+
char result[8*4];
|
553
|
+
char argp[];
|
372
554
|
};
|
373
555
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */
|
380
|
-
#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080));
|
381
|
-
|
382
|
-
/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */
|
383
|
-
#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16
|
384
|
-
|
385
|
-
/* Total number of trampolines that fit in one trampoline table */
|
386
|
-
#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE)
|
387
|
-
|
388
|
-
static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER;
|
389
|
-
static ffi_trampoline_table *ffi_trampoline_tables = NULL;
|
390
|
-
|
391
|
-
static ffi_trampoline_table *
|
392
|
-
ffi_trampoline_table_alloc ()
|
556
|
+
int FFI_HIDDEN
|
557
|
+
ffi_closure_inner_SYSV (ffi_cif *cif,
|
558
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
559
|
+
void *user_data,
|
560
|
+
struct closure_frame *frame)
|
393
561
|
{
|
394
|
-
|
562
|
+
void **avalue = (void **) alloca (cif->nargs * sizeof (void *));
|
563
|
+
void *rvalue = ffi_prep_incoming_args_SYSV (cif, frame->result,
|
564
|
+
frame->argp, avalue);
|
565
|
+
fun (cif, rvalue, avalue, user_data);
|
566
|
+
return cif->flags;
|
567
|
+
}
|
395
568
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
569
|
+
int FFI_HIDDEN
|
570
|
+
ffi_closure_inner_VFP (ffi_cif *cif,
|
571
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
572
|
+
void *user_data,
|
573
|
+
struct closure_frame *frame)
|
574
|
+
{
|
575
|
+
void **avalue = (void **) alloca (cif->nargs * sizeof (void *));
|
576
|
+
void *rvalue = ffi_prep_incoming_args_VFP (cif, frame->result, frame->argp,
|
577
|
+
frame->vfp_space, avalue);
|
578
|
+
fun (cif, rvalue, avalue, user_data);
|
579
|
+
return cif->flags;
|
580
|
+
}
|
400
581
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
582
|
+
void ffi_closure_SYSV (void) FFI_HIDDEN;
|
583
|
+
void ffi_closure_VFP (void) FFI_HIDDEN;
|
584
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
585
|
+
void ffi_closure_SYSV_alt (void) FFI_HIDDEN;
|
586
|
+
void ffi_closure_VFP_alt (void) FFI_HIDDEN;
|
587
|
+
#endif
|
407
588
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
|
413
|
-
break;
|
414
|
-
}
|
589
|
+
#ifdef FFI_GO_CLOSURES
|
590
|
+
void ffi_go_closure_SYSV (void) FFI_HIDDEN;
|
591
|
+
void ffi_go_closure_VFP (void) FFI_HIDDEN;
|
592
|
+
#endif
|
415
593
|
|
416
|
-
|
417
|
-
vm_prot_t cur_prot;
|
418
|
-
vm_prot_t max_prot;
|
594
|
+
/* the cif must already be prep'ed */
|
419
595
|
|
420
|
-
|
596
|
+
#if defined(__FreeBSD__) && defined(__arm__)
|
597
|
+
#define __clear_cache(start, end) do { \
|
598
|
+
struct arm_sync_icache_args ua; \
|
599
|
+
\
|
600
|
+
ua.addr = (uintptr_t)(start); \
|
601
|
+
ua.len = (char *)(end) - (char *)start; \
|
602
|
+
sysarch(ARM_SYNC_ICACHE, &ua); \
|
603
|
+
} while (0);
|
604
|
+
#endif
|
421
605
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
606
|
+
ffi_status
|
607
|
+
ffi_prep_closure_loc (ffi_closure * closure,
|
608
|
+
ffi_cif * cif,
|
609
|
+
void (*fun) (ffi_cif *, void *, void **, void *),
|
610
|
+
void *user_data, void *codeloc)
|
611
|
+
{
|
612
|
+
void (*closure_func) (void) = ffi_closure_SYSV;
|
428
613
|
|
429
|
-
|
430
|
-
|
614
|
+
if (cif->abi == FFI_VFP)
|
615
|
+
{
|
616
|
+
/* We only need take the vfp path if there are vfp arguments. */
|
617
|
+
if (cif->vfp_used)
|
618
|
+
closure_func = ffi_closure_VFP;
|
431
619
|
}
|
620
|
+
else if (cif->abi != FFI_SYSV)
|
621
|
+
return FFI_BAD_ABI;
|
432
622
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
/* Create and initialize the free list */
|
440
|
-
table->free_list_pool = calloc(FFI_TRAMPOLINE_COUNT, sizeof(ffi_trampoline_table_entry));
|
441
|
-
|
442
|
-
uint16_t i;
|
443
|
-
for (i = 0; i < table->free_count; i++) {
|
444
|
-
ffi_trampoline_table_entry *entry = &table->free_list_pool[i];
|
445
|
-
entry->trampoline = (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE));
|
623
|
+
#if FFI_EXEC_TRAMPOLINE_TABLE
|
624
|
+
void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
|
625
|
+
config[0] = closure;
|
626
|
+
config[1] = closure_func;
|
627
|
+
#else
|
446
628
|
|
447
|
-
|
448
|
-
|
629
|
+
# if defined(FFI_EXEC_STATIC_TRAMP)
|
630
|
+
if (ffi_tramp_is_present(closure))
|
631
|
+
{
|
632
|
+
/* Initialize the static trampoline's parameters. */
|
633
|
+
if (closure_func == ffi_closure_SYSV)
|
634
|
+
closure_func = ffi_closure_SYSV_alt;
|
635
|
+
else
|
636
|
+
closure_func = ffi_closure_VFP_alt;
|
637
|
+
ffi_tramp_set_parms (closure->ftramp, closure_func, closure);
|
638
|
+
goto out;
|
449
639
|
}
|
640
|
+
# endif
|
641
|
+
|
642
|
+
/* Initialize the dynamic trampoline. */
|
643
|
+
# ifndef _WIN32
|
644
|
+
memcpy(closure->tramp, ffi_arm_trampoline, 8);
|
645
|
+
# else
|
646
|
+
// cast away function type so MSVC doesn't set the lower bit of the function pointer
|
647
|
+
memcpy(closure->tramp, (void*)((uintptr_t)ffi_arm_trampoline & 0xFFFFFFFE), FFI_TRAMPOLINE_CLOSURE_OFFSET);
|
648
|
+
# endif
|
649
|
+
|
650
|
+
# if defined(__QNX__)
|
651
|
+
msync (closure->tramp, 8, MS_INVALIDATE_ICACHE); /* clear data map */
|
652
|
+
msync (codeloc, 8, MS_INVALIDATE_ICACHE); /* clear insn map */
|
653
|
+
# elif defined(_WIN32)
|
654
|
+
FlushInstructionCache(GetCurrentProcess(), closure->tramp, FFI_TRAMPOLINE_SIZE);
|
655
|
+
# else
|
656
|
+
__clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */
|
657
|
+
__clear_cache(codeloc, codeloc + 8); /* clear insn map */
|
658
|
+
# endif
|
659
|
+
# ifdef _WIN32
|
660
|
+
*(void(**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func;
|
661
|
+
# else
|
662
|
+
*(void (**)(void))(closure->tramp + 8) = closure_func;
|
663
|
+
# endif
|
664
|
+
# if defined(FFI_EXEC_STATIC_TRAMP)
|
665
|
+
out:
|
666
|
+
# endif
|
667
|
+
#endif
|
450
668
|
|
451
|
-
|
452
|
-
|
669
|
+
closure->cif = cif;
|
670
|
+
closure->fun = fun;
|
671
|
+
closure->user_data = user_data;
|
453
672
|
|
454
|
-
return
|
673
|
+
return FFI_OK;
|
455
674
|
}
|
456
675
|
|
457
|
-
|
458
|
-
|
676
|
+
#ifdef FFI_GO_CLOSURES
|
677
|
+
ffi_status
|
678
|
+
ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
|
679
|
+
void (*fun) (ffi_cif *, void *, void **, void *))
|
459
680
|
{
|
460
|
-
|
461
|
-
ffi_closure *closure = malloc(size);
|
462
|
-
if (closure == NULL)
|
463
|
-
return NULL;
|
464
|
-
|
465
|
-
pthread_mutex_lock(&ffi_trampoline_lock);
|
466
|
-
|
467
|
-
/* Check for an active trampoline table with available entries. */
|
468
|
-
ffi_trampoline_table *table = ffi_trampoline_tables;
|
469
|
-
if (table == NULL || table->free_list == NULL) {
|
470
|
-
table = ffi_trampoline_table_alloc ();
|
471
|
-
if (table == NULL) {
|
472
|
-
free(closure);
|
473
|
-
return NULL;
|
474
|
-
}
|
681
|
+
void (*closure_func) (void) = ffi_go_closure_SYSV;
|
475
682
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
683
|
+
if (cif->abi == FFI_VFP)
|
684
|
+
{
|
685
|
+
/* We only need take the vfp path if there are vfp arguments. */
|
686
|
+
if (cif->vfp_used)
|
687
|
+
closure_func = ffi_go_closure_VFP;
|
688
|
+
}
|
689
|
+
else if (cif->abi != FFI_SYSV)
|
690
|
+
return FFI_BAD_ABI;
|
480
691
|
|
481
|
-
|
482
|
-
|
692
|
+
closure->tramp = closure_func;
|
693
|
+
closure->cif = cif;
|
694
|
+
closure->fun = fun;
|
483
695
|
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
ffi_trampoline_tables->free_count--;
|
488
|
-
entry->next = NULL;
|
696
|
+
return FFI_OK;
|
697
|
+
}
|
698
|
+
#endif
|
489
699
|
|
490
|
-
|
700
|
+
#endif /* FFI_CLOSURES */
|
491
701
|
|
492
|
-
|
493
|
-
*code = entry->trampoline;
|
494
|
-
closure->trampoline_table = table;
|
495
|
-
closure->trampoline_table_entry = entry;
|
702
|
+
/* Below are routines for VFP hard-float support. */
|
496
703
|
|
497
|
-
return
|
498
|
-
|
704
|
+
/* A subroutine of vfp_type_p. Given a structure type, return the type code
|
705
|
+
of the first non-structure element. Recurse for structure elements.
|
706
|
+
Return -1 if the structure is in fact empty, i.e. no nested elements. */
|
499
707
|
|
500
|
-
|
501
|
-
|
708
|
+
static int
|
709
|
+
is_hfa0 (const ffi_type *ty)
|
502
710
|
{
|
503
|
-
|
504
|
-
|
505
|
-
pthread_mutex_lock(&ffi_trampoline_lock);
|
506
|
-
|
507
|
-
/* Fetch the table and entry references */
|
508
|
-
ffi_trampoline_table *table = closure->trampoline_table;
|
509
|
-
ffi_trampoline_table_entry *entry = closure->trampoline_table_entry;
|
510
|
-
|
511
|
-
/* Return the entry to the free list */
|
512
|
-
entry->next = table->free_list;
|
513
|
-
table->free_list = entry;
|
514
|
-
table->free_count++;
|
515
|
-
|
516
|
-
/* If all trampolines within this table are free, and at least one other table exists, deallocate
|
517
|
-
* the table */
|
518
|
-
if (table->free_count == FFI_TRAMPOLINE_COUNT && ffi_trampoline_tables != table) {
|
519
|
-
/* Remove from the list */
|
520
|
-
if (table->prev != NULL)
|
521
|
-
table->prev->next = table->next;
|
522
|
-
|
523
|
-
if (table->next != NULL)
|
524
|
-
table->next->prev = table->prev;
|
525
|
-
|
526
|
-
/* Deallocate pages */
|
527
|
-
kern_return_t kt;
|
528
|
-
kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE);
|
529
|
-
if (kt != KERN_SUCCESS)
|
530
|
-
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
|
531
|
-
|
532
|
-
kt = vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE);
|
533
|
-
if (kt != KERN_SUCCESS)
|
534
|
-
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
|
535
|
-
|
536
|
-
/* Deallocate free list */
|
537
|
-
free (table->free_list_pool);
|
538
|
-
free (table);
|
539
|
-
} else if (ffi_trampoline_tables != table) {
|
540
|
-
/* Otherwise, bump this table to the top of the list */
|
541
|
-
table->prev = NULL;
|
542
|
-
table->next = ffi_trampoline_tables;
|
543
|
-
if (ffi_trampoline_tables != NULL)
|
544
|
-
ffi_trampoline_tables->prev = table;
|
545
|
-
|
546
|
-
ffi_trampoline_tables = table;
|
547
|
-
}
|
548
|
-
|
549
|
-
pthread_mutex_unlock (&ffi_trampoline_lock);
|
550
|
-
|
551
|
-
/* Free the closure */
|
552
|
-
free (closure);
|
553
|
-
}
|
711
|
+
ffi_type **elements = ty->elements;
|
712
|
+
int i, ret = -1;
|
554
713
|
|
555
|
-
|
714
|
+
if (elements != NULL)
|
715
|
+
for (i = 0; elements[i]; ++i)
|
716
|
+
{
|
717
|
+
ret = elements[i]->type;
|
718
|
+
if (ret == FFI_TYPE_STRUCT || ret == FFI_TYPE_COMPLEX)
|
719
|
+
{
|
720
|
+
ret = is_hfa0 (elements[i]);
|
721
|
+
if (ret < 0)
|
722
|
+
continue;
|
723
|
+
}
|
724
|
+
break;
|
725
|
+
}
|
556
726
|
|
557
|
-
|
558
|
-
|
559
|
-
unsigned int __fun = (unsigned int)(FUN); \
|
560
|
-
unsigned int __ctx = (unsigned int)(CTX); \
|
561
|
-
unsigned char *insns = (unsigned char *)(CTX); \
|
562
|
-
*(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \
|
563
|
-
*(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \
|
564
|
-
*(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \
|
565
|
-
*(unsigned int*) &__tramp[12] = __ctx; \
|
566
|
-
*(unsigned int*) &__tramp[16] = __fun; \
|
567
|
-
__clear_cache((&__tramp[0]), (&__tramp[19])); /* Clear data mapping. */ \
|
568
|
-
__clear_cache(insns, insns + 3 * sizeof (unsigned int)); \
|
569
|
-
/* Clear instruction \
|
570
|
-
mapping. */ \
|
571
|
-
})
|
727
|
+
return ret;
|
728
|
+
}
|
572
729
|
|
573
|
-
|
730
|
+
/* A subroutine of vfp_type_p. Given a structure type, return true if all
|
731
|
+
of the non-structure elements are the same as CANDIDATE. */
|
574
732
|
|
575
|
-
|
576
|
-
|
577
|
-
ffi_status
|
578
|
-
ffi_prep_closure_loc (ffi_closure* closure,
|
579
|
-
ffi_cif* cif,
|
580
|
-
void (*fun)(ffi_cif*,void*,void**,void*),
|
581
|
-
void *user_data,
|
582
|
-
void *codeloc)
|
733
|
+
static int
|
734
|
+
is_hfa1 (const ffi_type *ty, int candidate)
|
583
735
|
{
|
584
|
-
|
585
|
-
|
586
|
-
if (cif->abi == FFI_SYSV)
|
587
|
-
closure_func = &ffi_closure_SYSV;
|
588
|
-
else if (cif->abi == FFI_VFP)
|
589
|
-
closure_func = &ffi_closure_VFP;
|
590
|
-
else
|
591
|
-
return FFI_BAD_ABI;
|
592
|
-
|
593
|
-
#if FFI_EXEC_TRAMPOLINE_TABLE
|
594
|
-
void **config = FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc);
|
595
|
-
config[0] = closure;
|
596
|
-
config[1] = closure_func;
|
597
|
-
#else
|
598
|
-
FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
|
599
|
-
closure_func, \
|
600
|
-
codeloc);
|
601
|
-
#endif
|
736
|
+
ffi_type **elements = ty->elements;
|
737
|
+
int i;
|
602
738
|
|
603
|
-
|
604
|
-
|
605
|
-
|
739
|
+
if (elements != NULL)
|
740
|
+
for (i = 0; elements[i]; ++i)
|
741
|
+
{
|
742
|
+
int t = elements[i]->type;
|
743
|
+
if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX)
|
744
|
+
{
|
745
|
+
if (!is_hfa1 (elements[i], candidate))
|
746
|
+
return 0;
|
747
|
+
}
|
748
|
+
else if (t != candidate)
|
749
|
+
return 0;
|
750
|
+
}
|
606
751
|
|
607
|
-
return
|
752
|
+
return 1;
|
608
753
|
}
|
609
754
|
|
610
|
-
/*
|
755
|
+
/* Determine if TY is an homogenous floating point aggregate (HFA).
|
756
|
+
That is, a structure consisting of 1 to 4 members of all the same type,
|
757
|
+
where that type is a floating point scalar.
|
611
758
|
|
612
|
-
|
759
|
+
Returns non-zero iff TY is an HFA. The result is an encoded value where
|
760
|
+
bits 0-7 contain the type code, and bits 8-10 contain the element count. */
|
761
|
+
|
762
|
+
static int
|
763
|
+
vfp_type_p (const ffi_type *ty)
|
613
764
|
{
|
614
|
-
|
765
|
+
ffi_type **elements;
|
766
|
+
int candidate, i;
|
767
|
+
size_t size, ele_count;
|
768
|
+
|
769
|
+
/* Quickest tests first. */
|
770
|
+
candidate = ty->type;
|
771
|
+
switch (ty->type)
|
615
772
|
{
|
773
|
+
default:
|
774
|
+
return 0;
|
616
775
|
case FFI_TYPE_FLOAT:
|
617
776
|
case FFI_TYPE_DOUBLE:
|
618
|
-
|
619
|
-
|
620
|
-
|
777
|
+
ele_count = 1;
|
778
|
+
goto done;
|
779
|
+
case FFI_TYPE_COMPLEX:
|
780
|
+
candidate = ty->elements[0]->type;
|
781
|
+
if (candidate != FFI_TYPE_FLOAT && candidate != FFI_TYPE_DOUBLE)
|
782
|
+
return 0;
|
783
|
+
ele_count = 2;
|
784
|
+
goto done;
|
785
|
+
case FFI_TYPE_STRUCT:
|
786
|
+
break;
|
787
|
+
}
|
621
788
|
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
789
|
+
/* No HFA types are smaller than 4 bytes, or larger than 32 bytes. */
|
790
|
+
size = ty->size;
|
791
|
+
if (size < 4 || size > 32)
|
792
|
+
return 0;
|
626
793
|
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
794
|
+
/* Find the type of the first non-structure member. */
|
795
|
+
elements = ty->elements;
|
796
|
+
candidate = elements[0]->type;
|
797
|
+
if (candidate == FFI_TYPE_STRUCT || candidate == FFI_TYPE_COMPLEX)
|
798
|
+
{
|
799
|
+
for (i = 0; ; ++i)
|
800
|
+
{
|
801
|
+
candidate = is_hfa0 (elements[i]);
|
802
|
+
if (candidate >= 0)
|
803
|
+
break;
|
804
|
+
}
|
805
|
+
}
|
631
806
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
*elt = base_elt;
|
649
|
-
return 1;
|
650
|
-
}
|
651
|
-
default: ;
|
807
|
+
/* If the first member is not a floating point type, it's not an HFA.
|
808
|
+
Also quickly re-check the size of the structure. */
|
809
|
+
switch (candidate)
|
810
|
+
{
|
811
|
+
case FFI_TYPE_FLOAT:
|
812
|
+
ele_count = size / sizeof(float);
|
813
|
+
if (size != ele_count * sizeof(float))
|
814
|
+
return 0;
|
815
|
+
break;
|
816
|
+
case FFI_TYPE_DOUBLE:
|
817
|
+
ele_count = size / sizeof(double);
|
818
|
+
if (size != ele_count * sizeof(double))
|
819
|
+
return 0;
|
820
|
+
break;
|
821
|
+
default:
|
822
|
+
return 0;
|
652
823
|
}
|
653
|
-
|
654
|
-
|
824
|
+
if (ele_count > 4)
|
825
|
+
return 0;
|
655
826
|
|
656
|
-
|
657
|
-
|
658
|
-
int elt, elnum;
|
659
|
-
if (rec_vfp_type_p (t, &elt, &elnum))
|
827
|
+
/* Finally, make sure that all scalar elements are the same type. */
|
828
|
+
for (i = 0; elements[i]; ++i)
|
660
829
|
{
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
}
|
670
|
-
return (int) t->type;
|
830
|
+
int t = elements[i]->type;
|
831
|
+
if (t == FFI_TYPE_STRUCT || t == FFI_TYPE_COMPLEX)
|
832
|
+
{
|
833
|
+
if (!is_hfa1 (elements[i], candidate))
|
834
|
+
return 0;
|
835
|
+
}
|
836
|
+
else if (t != candidate)
|
837
|
+
return 0;
|
671
838
|
}
|
672
|
-
|
839
|
+
|
840
|
+
/* All tests succeeded. Encode the result. */
|
841
|
+
done:
|
842
|
+
return (ele_count << 8) | candidate;
|
673
843
|
}
|
674
844
|
|
675
|
-
static
|
845
|
+
static int
|
846
|
+
place_vfp_arg (ffi_cif *cif, int h)
|
676
847
|
{
|
677
|
-
|
678
|
-
int nregs =
|
679
|
-
|
680
|
-
|
848
|
+
unsigned short reg = cif->vfp_reg_free;
|
849
|
+
int align = 1, nregs = h >> 8;
|
850
|
+
|
851
|
+
if ((h & 0xff) == FFI_TYPE_DOUBLE)
|
852
|
+
align = 2, nregs *= 2;
|
853
|
+
|
681
854
|
/* Align register number. */
|
682
855
|
if ((reg & 1) && align == 2)
|
683
856
|
reg++;
|
857
|
+
|
684
858
|
while (reg + nregs <= 16)
|
685
859
|
{
|
686
860
|
int s, new_used = 0;
|
@@ -695,7 +869,7 @@ static void place_vfp_arg (ffi_cif *cif, ffi_type *t)
|
|
695
869
|
}
|
696
870
|
/* Found regs to allocate. */
|
697
871
|
cif->vfp_used |= new_used;
|
698
|
-
cif->vfp_args[cif->vfp_nargs++] = reg;
|
872
|
+
cif->vfp_args[cif->vfp_nargs++] = (signed char)reg;
|
699
873
|
|
700
874
|
/* Update vfp_reg_free. */
|
701
875
|
if (cif->vfp_used & (1 << cif->vfp_reg_free))
|
@@ -705,24 +879,43 @@ static void place_vfp_arg (ffi_cif *cif, ffi_type *t)
|
|
705
879
|
reg += 1;
|
706
880
|
cif->vfp_reg_free = reg;
|
707
881
|
}
|
708
|
-
return;
|
709
|
-
next_reg
|
882
|
+
return 0;
|
883
|
+
next_reg:;
|
710
884
|
}
|
885
|
+
// done, mark all regs as used
|
886
|
+
cif->vfp_reg_free = 16;
|
887
|
+
cif->vfp_used = 0xFFFF;
|
888
|
+
return 1;
|
711
889
|
}
|
712
890
|
|
713
|
-
static void
|
891
|
+
static void
|
892
|
+
layout_vfp_args (ffi_cif * cif)
|
714
893
|
{
|
715
|
-
int i;
|
894
|
+
unsigned int i;
|
716
895
|
/* Init VFP fields */
|
717
896
|
cif->vfp_used = 0;
|
718
897
|
cif->vfp_nargs = 0;
|
719
898
|
cif->vfp_reg_free = 0;
|
720
|
-
memset (cif->vfp_args, -1, 16);
|
899
|
+
memset (cif->vfp_args, -1, 16); /* Init to -1. */
|
721
900
|
|
722
901
|
for (i = 0; i < cif->nargs; i++)
|
723
902
|
{
|
724
|
-
|
725
|
-
if (
|
726
|
-
|
903
|
+
int h = vfp_type_p (cif->arg_types[i]);
|
904
|
+
if (h && place_vfp_arg (cif, h) == 1)
|
905
|
+
break;
|
727
906
|
}
|
728
907
|
}
|
908
|
+
|
909
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
910
|
+
void *
|
911
|
+
ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
|
912
|
+
{
|
913
|
+
extern void *trampoline_code_table;
|
914
|
+
|
915
|
+
*tramp_size = ARM_TRAMP_SIZE;
|
916
|
+
*map_size = ARM_TRAMP_MAP_SIZE;
|
917
|
+
return &trampoline_code_table;
|
918
|
+
}
|
919
|
+
#endif
|
920
|
+
|
921
|
+
#endif /* __arm__ or _M_ARM */
|