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
@@ -1,120 +1,52 @@
|
|
1
|
-
rbx.platform.typedef.
|
2
|
-
rbx.platform.typedef.
|
3
|
-
rbx.platform.typedef.
|
4
|
-
rbx.platform.typedef.
|
5
|
-
rbx.platform.typedef.
|
6
|
-
rbx.platform.typedef.__uint_least16_t = ushort
|
7
|
-
rbx.platform.typedef.__int32_t = int
|
8
|
-
rbx.platform.typedef.__uint32_t = uint
|
9
|
-
rbx.platform.typedef.__int_least32_t = int
|
10
|
-
rbx.platform.typedef.__uint_least32_t = uint
|
11
|
-
rbx.platform.typedef.__int64_t = long_long
|
12
|
-
rbx.platform.typedef.__uint64_t = ulong_long
|
13
|
-
rbx.platform.typedef._off_t = long
|
14
|
-
rbx.platform.typedef.__dev_t = short
|
15
|
-
rbx.platform.typedef.__uid_t = ushort
|
16
|
-
rbx.platform.typedef.__gid_t = ushort
|
1
|
+
rbx.platform.typedef.__time32_t = long
|
2
|
+
rbx.platform.typedef.__time64_t = long_long
|
3
|
+
rbx.platform.typedef._dev_t = uint
|
4
|
+
rbx.platform.typedef._ino_t = ushort
|
5
|
+
rbx.platform.typedef._mode_t = ushort
|
17
6
|
rbx.platform.typedef._off64_t = long_long
|
18
|
-
rbx.platform.typedef.
|
19
|
-
rbx.platform.typedef.
|
20
|
-
rbx.platform.typedef.
|
21
|
-
rbx.platform.typedef.
|
22
|
-
rbx.platform.typedef.
|
23
|
-
rbx.platform.typedef.
|
24
|
-
rbx.platform.typedef.wctype_t = ushort
|
25
|
-
rbx.platform.typedef.ptrdiff_t = long_long
|
26
|
-
rbx.platform.typedef.size_t = ulong_long
|
27
|
-
rbx.platform.typedef.__off_t = long
|
28
|
-
rbx.platform.typedef.__pid_t = int
|
29
|
-
rbx.platform.typedef.__loff_t = long_long
|
30
|
-
rbx.platform.typedef.u_char = uchar
|
31
|
-
rbx.platform.typedef.u_short = ushort
|
32
|
-
rbx.platform.typedef.u_int = uint
|
33
|
-
rbx.platform.typedef.u_long = ulong
|
34
|
-
rbx.platform.typedef.ushort = ushort
|
35
|
-
rbx.platform.typedef.uint = uint
|
36
|
-
rbx.platform.typedef.ulong = ulong
|
37
|
-
rbx.platform.typedef.clock_t = ulong
|
38
|
-
rbx.platform.typedef.time_t = long_long
|
39
|
-
rbx.platform.typedef.daddr_t = long
|
40
|
-
rbx.platform.typedef.caddr_t = string
|
41
|
-
rbx.platform.typedef.pid_t = int
|
42
|
-
rbx.platform.typedef.ssize_t = int
|
43
|
-
rbx.platform.typedef.nlink_t = ushort
|
44
|
-
rbx.platform.typedef.fd_mask = long
|
45
|
-
rbx.platform.typedef.clockid_t = ulong
|
46
|
-
rbx.platform.typedef.timer_t = ulong
|
47
|
-
rbx.platform.typedef.useconds_t = ulong
|
48
|
-
rbx.platform.typedef.suseconds_t = long
|
49
|
-
rbx.platform.typedef.int8_t = char
|
7
|
+
rbx.platform.typedef._off_t = long
|
8
|
+
rbx.platform.typedef._pid_t = long_long
|
9
|
+
rbx.platform.typedef._sigset_t = ulong_long
|
10
|
+
rbx.platform.typedef.dev_t = uint
|
11
|
+
rbx.platform.typedef.errno_t = int
|
12
|
+
rbx.platform.typedef.ino_t = ushort
|
50
13
|
rbx.platform.typedef.int16_t = short
|
51
14
|
rbx.platform.typedef.int32_t = int
|
52
15
|
rbx.platform.typedef.int64_t = long_long
|
53
|
-
rbx.platform.typedef.
|
54
|
-
rbx.platform.typedef.
|
55
|
-
rbx.platform.typedef.
|
56
|
-
rbx.platform.typedef.
|
57
|
-
rbx.platform.typedef.
|
16
|
+
rbx.platform.typedef.int8_t = char
|
17
|
+
rbx.platform.typedef.int_fast16_t = short
|
18
|
+
rbx.platform.typedef.int_fast32_t = int
|
19
|
+
rbx.platform.typedef.int_fast64_t = long_long
|
20
|
+
rbx.platform.typedef.int_fast8_t = char
|
58
21
|
rbx.platform.typedef.int_least16_t = short
|
59
22
|
rbx.platform.typedef.int_least32_t = int
|
60
23
|
rbx.platform.typedef.int_least64_t = long_long
|
61
|
-
rbx.platform.typedef.
|
62
|
-
rbx.platform.typedef.
|
63
|
-
rbx.platform.typedef.
|
64
|
-
rbx.platform.typedef.
|
65
|
-
rbx.platform.typedef.
|
66
|
-
rbx.platform.typedef.
|
67
|
-
rbx.platform.typedef.
|
68
|
-
rbx.platform.typedef.
|
69
|
-
rbx.platform.typedef.
|
70
|
-
rbx.platform.typedef.
|
24
|
+
rbx.platform.typedef.int_least8_t = char
|
25
|
+
rbx.platform.typedef.intmax_t = long_long
|
26
|
+
rbx.platform.typedef.intptr_t = long_long
|
27
|
+
rbx.platform.typedef.mode_t = ushort
|
28
|
+
rbx.platform.typedef.off32_t = long
|
29
|
+
rbx.platform.typedef.off64_t = long_long
|
30
|
+
rbx.platform.typedef.off_t = long_long
|
31
|
+
rbx.platform.typedef.pid_t = long_long
|
32
|
+
rbx.platform.typedef.ptrdiff_t = long_long
|
33
|
+
rbx.platform.typedef.rsize_t = ulong_long
|
34
|
+
rbx.platform.typedef.size_t = ulong_long
|
35
|
+
rbx.platform.typedef.ssize_t = long_long
|
36
|
+
rbx.platform.typedef.time_t = long_long
|
37
|
+
rbx.platform.typedef.uint16_t = ushort
|
38
|
+
rbx.platform.typedef.uint64_t = ulong_long
|
39
|
+
rbx.platform.typedef.uint8_t = uchar
|
40
|
+
rbx.platform.typedef.uint_fast16_t = ushort
|
71
41
|
rbx.platform.typedef.uint_fast32_t = uint
|
72
42
|
rbx.platform.typedef.uint_fast64_t = ulong_long
|
73
|
-
rbx.platform.typedef.
|
74
|
-
rbx.platform.typedef.
|
75
|
-
rbx.platform.typedef.
|
43
|
+
rbx.platform.typedef.uint_fast8_t = uchar
|
44
|
+
rbx.platform.typedef.uint_least16_t = ushort
|
45
|
+
rbx.platform.typedef.uint_least64_t = ulong_long
|
46
|
+
rbx.platform.typedef.uint_least8_t = uchar
|
76
47
|
rbx.platform.typedef.uintmax_t = ulong_long
|
77
|
-
rbx.platform.typedef.
|
78
|
-
rbx.platform.typedef.
|
79
|
-
rbx.platform.typedef.
|
80
|
-
rbx.platform.typedef.
|
81
|
-
rbx.platform.typedef.
|
82
|
-
rbx.platform.typedef.dev_t = uint
|
83
|
-
rbx.platform.typedef.blksize_t = long
|
84
|
-
rbx.platform.typedef.__blkcnt32_t = long
|
85
|
-
rbx.platform.typedef.__blkcnt64_t = long_long
|
86
|
-
rbx.platform.typedef.blkcnt_t = long_long
|
87
|
-
rbx.platform.typedef.fsblkcnt_t = ulong
|
88
|
-
rbx.platform.typedef.fsfilcnt_t = ulong
|
89
|
-
rbx.platform.typedef.__uid16_t = ushort
|
90
|
-
rbx.platform.typedef.__uid32_t = ulong
|
91
|
-
rbx.platform.typedef.uid_t = ulong
|
92
|
-
rbx.platform.typedef.__gid16_t = ushort
|
93
|
-
rbx.platform.typedef.__gid32_t = ulong
|
94
|
-
rbx.platform.typedef.gid_t = ulong
|
95
|
-
rbx.platform.typedef.__ino32_t = ulong
|
96
|
-
rbx.platform.typedef.__ino64_t = ulong_long
|
97
|
-
rbx.platform.typedef.ino_t = ushort
|
98
|
-
rbx.platform.typedef._ino_t = ushort
|
99
|
-
rbx.platform.typedef.id_t = ulong
|
100
|
-
rbx.platform.typedef.key_t = long_long
|
101
|
-
rbx.platform.typedef.vm_offset_t = ulong
|
102
|
-
rbx.platform.typedef.vm_size_t = ulong
|
103
|
-
rbx.platform.typedef.u_int8_t = uchar
|
104
|
-
rbx.platform.typedef.u_int16_t = ushort
|
105
|
-
rbx.platform.typedef.u_int32_t = uint
|
106
|
-
rbx.platform.typedef.u_int64_t = ulong_long
|
107
|
-
rbx.platform.typedef.register_t = int
|
108
|
-
rbx.platform.typedef.*addr_t = char
|
109
|
-
rbx.platform.typedef.socklen_t = int
|
110
|
-
rbx.platform.typedef.sa_family_t = ushort
|
111
|
-
rbx.platform.typedef.__ULong = ulong
|
112
|
-
rbx.platform.typedef.sigset_t = ulong
|
113
|
-
rbx.platform.typedef.sig_atomic_t = int
|
114
|
-
rbx.platform.typedef.rlim_t = ulong
|
115
|
-
rbx.platform.typedef._sigset_t = ulong_long
|
116
|
-
rbx.platform.typedef.__time32_t = long
|
117
|
-
rbx.platform.typedef.__time64_t = long_long
|
118
|
-
rbx.platform.typedef.errno_t = int
|
119
|
-
rbx.platform.typedef._mode_t = ushort
|
120
|
-
rbx.platform.typedef.mode_t = ushort
|
48
|
+
rbx.platform.typedef.uintptr_t = ulong_long
|
49
|
+
rbx.platform.typedef.useconds_t = uint
|
50
|
+
rbx.platform.typedef.wchar_t = ushort
|
51
|
+
rbx.platform.typedef.wctype_t = ushort
|
52
|
+
rbx.platform.typedef.wint_t = ushort
|
data/lib/ffi/platform.rb
CHANGED
@@ -29,13 +29,15 @@
|
|
29
29
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
|
30
30
|
|
31
31
|
require 'rbconfig'
|
32
|
+
require_relative 'compat'
|
33
|
+
|
32
34
|
module FFI
|
33
35
|
class PlatformError < LoadError; end
|
34
36
|
|
35
37
|
# This module defines different constants and class methods to play with
|
36
38
|
# various platforms.
|
37
39
|
module Platform
|
38
|
-
OS = case RbConfig::CONFIG['host_os'].downcase
|
40
|
+
OS = FFI.make_shareable(case RbConfig::CONFIG['host_os'].downcase
|
39
41
|
when /linux/
|
40
42
|
"linux"
|
41
43
|
when /darwin/
|
@@ -46,18 +48,24 @@ module FFI
|
|
46
48
|
"netbsd"
|
47
49
|
when /openbsd/
|
48
50
|
"openbsd"
|
51
|
+
when /dragonfly/
|
52
|
+
"dragonflybsd"
|
49
53
|
when /sunos|solaris/
|
50
54
|
"solaris"
|
51
55
|
when /mingw|mswin/
|
52
56
|
"windows"
|
53
57
|
else
|
54
58
|
RbConfig::CONFIG['host_os'].downcase
|
55
|
-
end
|
59
|
+
end)
|
60
|
+
|
61
|
+
OSVERSION = RbConfig::CONFIG['host_os'].gsub(/[^\d]/, '').to_i
|
62
|
+
|
63
|
+
CPU = FFI.make_shareable(RbConfig::CONFIG['host_cpu'])
|
56
64
|
|
57
|
-
ARCH = case CPU.downcase
|
58
|
-
when /amd64|x86_64/
|
65
|
+
ARCH = FFI.make_shareable(case CPU.downcase
|
66
|
+
when /amd64|x86_64|x64/
|
59
67
|
"x86_64"
|
60
|
-
when /i
|
68
|
+
when /i\d86|x86|i86pc/
|
61
69
|
"i386"
|
62
70
|
when /ppc64|powerpc64/
|
63
71
|
"powerpc64"
|
@@ -65,14 +73,17 @@ module FFI
|
|
65
73
|
"powerpc"
|
66
74
|
when /sparcv9|sparc64/
|
67
75
|
"sparcv9"
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
|
77
|
+
"aarch64"
|
78
|
+
when /^arm/
|
79
|
+
if OS == "darwin" # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
|
80
|
+
"aarch64"
|
72
81
|
else
|
73
|
-
|
82
|
+
"arm"
|
74
83
|
end
|
75
|
-
|
84
|
+
else
|
85
|
+
RbConfig::CONFIG['host_cpu']
|
86
|
+
end)
|
76
87
|
|
77
88
|
private
|
78
89
|
# @param [String) os
|
@@ -82,30 +93,35 @@ module FFI
|
|
82
93
|
OS == os
|
83
94
|
end
|
84
95
|
|
85
|
-
NAME = "#{ARCH}-#{OS}"
|
86
96
|
IS_GNU = defined?(GNU_LIBC)
|
87
97
|
IS_LINUX = is_os("linux")
|
88
98
|
IS_MAC = is_os("darwin")
|
89
99
|
IS_FREEBSD = is_os("freebsd")
|
90
100
|
IS_NETBSD = is_os("netbsd")
|
91
101
|
IS_OPENBSD = is_os("openbsd")
|
102
|
+
IS_DRAGONFLYBSD = is_os("dragonfly")
|
92
103
|
IS_SOLARIS = is_os("solaris")
|
93
104
|
IS_WINDOWS = is_os("windows")
|
94
|
-
IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD
|
95
|
-
|
105
|
+
IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD || IS_DRAGONFLYBSD
|
106
|
+
|
107
|
+
# Add the version for known ABI breaks
|
108
|
+
name_version = "12" if IS_FREEBSD && OSVERSION >= 12 # 64-bit inodes
|
109
|
+
|
110
|
+
NAME = FFI.make_shareable("#{ARCH}-#{OS}#{name_version}")
|
111
|
+
CONF_DIR = FFI.make_shareable(File.join(File.dirname(__FILE__), 'platform', NAME))
|
96
112
|
|
97
113
|
public
|
98
114
|
|
99
|
-
LIBPREFIX = case OS
|
115
|
+
LIBPREFIX = FFI.make_shareable(case OS
|
100
116
|
when /windows|msys/
|
101
117
|
''
|
102
118
|
when /cygwin/
|
103
119
|
'cyg'
|
104
120
|
else
|
105
121
|
'lib'
|
106
|
-
end
|
122
|
+
end)
|
107
123
|
|
108
|
-
LIBSUFFIX = case OS
|
124
|
+
LIBSUFFIX = FFI.make_shareable(case OS
|
109
125
|
when /darwin/
|
110
126
|
'dylib'
|
111
127
|
when /linux|bsd|solaris/
|
@@ -115,10 +131,11 @@ module FFI
|
|
115
131
|
else
|
116
132
|
# Punt and just assume a sane unix (i.e. anything but AIX)
|
117
133
|
'so'
|
118
|
-
end
|
134
|
+
end)
|
119
135
|
|
120
|
-
LIBC = if IS_WINDOWS
|
121
|
-
RbConfig::CONFIG[
|
136
|
+
LIBC = FFI.make_shareable(if IS_WINDOWS
|
137
|
+
crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
|
138
|
+
"#{crtname}.dll"
|
122
139
|
elsif IS_GNU
|
123
140
|
GNU_LIBC
|
124
141
|
elsif OS == 'cygwin'
|
@@ -128,6 +145,12 @@ module FFI
|
|
128
145
|
"msys-2.0.dll"
|
129
146
|
else
|
130
147
|
"#{LIBPREFIX}c.#{LIBSUFFIX}"
|
148
|
+
end)
|
149
|
+
|
150
|
+
LITTLE_ENDIAN = 1234 unless defined?(LITTLE_ENDIAN)
|
151
|
+
BIG_ENDIAN = 4321 unless defined?(BIG_ENDIAN)
|
152
|
+
unless defined?(BYTE_ORDER)
|
153
|
+
BYTE_ORDER = [0x12345678].pack("I") == [0x12345678].pack("N") ? BIG_ENDIAN : LITTLE_ENDIAN
|
131
154
|
end
|
132
155
|
|
133
156
|
# Test if current OS is a *BSD (include MAC)
|
data/lib/ffi/pointer.rb
CHANGED
@@ -31,30 +31,37 @@
|
|
31
31
|
#
|
32
32
|
|
33
33
|
require 'ffi/platform'
|
34
|
+
|
35
|
+
# NOTE: all method definitions in this file are conditional on
|
36
|
+
# whether they are not already defined. This is needed because
|
37
|
+
# some Ruby implementations (e.g., TruffleRuby) might already
|
38
|
+
# provide these methods due to using FFI internally, and we
|
39
|
+
# should not override them to avoid warnings.
|
40
|
+
|
34
41
|
module FFI
|
35
42
|
class Pointer
|
36
43
|
|
37
44
|
# Pointer size
|
38
|
-
SIZE = Platform::ADDRESS_SIZE / 8
|
45
|
+
SIZE = Platform::ADDRESS_SIZE / 8 unless const_defined?(:SIZE)
|
39
46
|
|
40
47
|
# Return the size of a pointer on the current platform, in bytes
|
41
48
|
# @return [Numeric]
|
42
49
|
def self.size
|
43
50
|
SIZE
|
44
|
-
end
|
51
|
+
end unless respond_to?(:size)
|
45
52
|
|
46
53
|
# @param [nil,Numeric] len length of string to return
|
47
54
|
# @return [String]
|
48
|
-
# Read pointer's contents as a string, or the first +len+ bytes of the
|
55
|
+
# Read pointer's contents as a string, or the first +len+ bytes of the
|
49
56
|
# equivalent string if +len+ is not +nil+.
|
50
57
|
def read_string(len=nil)
|
51
58
|
if len
|
52
|
-
return '' if len == 0
|
59
|
+
return ''.b if len == 0
|
53
60
|
get_bytes(0, len)
|
54
61
|
else
|
55
62
|
get_string(0)
|
56
63
|
end
|
57
|
-
end
|
64
|
+
end unless method_defined?(:read_string)
|
58
65
|
|
59
66
|
# @param [Numeric] len length of string to return
|
60
67
|
# @return [String]
|
@@ -64,7 +71,7 @@ module FFI
|
|
64
71
|
# ptr.read_string(len) # with len not nil
|
65
72
|
def read_string_length(len)
|
66
73
|
get_bytes(0, len)
|
67
|
-
end
|
74
|
+
end unless method_defined?(:read_string_length)
|
68
75
|
|
69
76
|
# @return [String]
|
70
77
|
# Read pointer's contents as a string.
|
@@ -73,7 +80,7 @@ module FFI
|
|
73
80
|
# ptr.read_string # with no len
|
74
81
|
def read_string_to_null
|
75
82
|
get_string(0)
|
76
|
-
end
|
83
|
+
end unless method_defined?(:read_string_to_null)
|
77
84
|
|
78
85
|
# @param [String] str string to write
|
79
86
|
# @param [Numeric] len length of string to return
|
@@ -84,18 +91,18 @@ module FFI
|
|
84
91
|
# ptr.write_string(str, len) # with len not nil
|
85
92
|
def write_string_length(str, len)
|
86
93
|
put_bytes(0, str, 0, len)
|
87
|
-
end
|
94
|
+
end unless method_defined?(:write_string_length)
|
88
95
|
|
89
96
|
# @param [String] str string to write
|
90
97
|
# @param [Numeric] len length of string to return
|
91
98
|
# @return [self]
|
92
|
-
# Write +str+ in pointer's contents, or first +len+ bytes if
|
99
|
+
# Write +str+ in pointer's contents, or first +len+ bytes if
|
93
100
|
# +len+ is not +nil+.
|
94
101
|
def write_string(str, len=nil)
|
95
102
|
len = str.bytesize unless len
|
96
103
|
# Write the string data without NUL termination
|
97
104
|
put_bytes(0, str, 0, len)
|
98
|
-
end
|
105
|
+
end unless method_defined?(:write_string)
|
99
106
|
|
100
107
|
# @param [Type] type type of data to read from pointer's contents
|
101
108
|
# @param [Symbol] reader method to send to +self+ to read +type+
|
@@ -103,7 +110,7 @@ module FFI
|
|
103
110
|
# @return [Array]
|
104
111
|
# Read an array of +type+ of length +length+.
|
105
112
|
# @example
|
106
|
-
# ptr.read_array_of_type(TYPE_UINT8, :
|
113
|
+
# ptr.read_array_of_type(TYPE_UINT8, :read_uint8, 4) # -> [1, 2, 3, 4]
|
107
114
|
def read_array_of_type(type, reader, length)
|
108
115
|
ary = []
|
109
116
|
size = FFI.type_size(type)
|
@@ -113,7 +120,7 @@ module FFI
|
|
113
120
|
tmp += size unless j == length-1 # avoid OOB
|
114
121
|
}
|
115
122
|
ary
|
116
|
-
end
|
123
|
+
end unless method_defined?(:read_array_of_type)
|
117
124
|
|
118
125
|
# @param [Type] type type of data to write to pointer's contents
|
119
126
|
# @param [Symbol] writer method to send to +self+ to write +type+
|
@@ -124,18 +131,17 @@ module FFI
|
|
124
131
|
# ptr.write_array_of_type(TYPE_UINT8, :put_uint8, [1, 2, 3 ,4])
|
125
132
|
def write_array_of_type(type, writer, ary)
|
126
133
|
size = FFI.type_size(type)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
tmp += size unless j == ary.length-1 # avoid OOB
|
134
|
+
ary.each_with_index { |val, i|
|
135
|
+
break unless i < self.size
|
136
|
+
self.send(writer, i * size, val)
|
131
137
|
}
|
132
138
|
self
|
133
|
-
end
|
139
|
+
end unless method_defined?(:write_array_of_type)
|
134
140
|
|
135
141
|
# @return [self]
|
136
142
|
def to_ptr
|
137
143
|
self
|
138
|
-
end
|
144
|
+
end unless method_defined?(:to_ptr)
|
139
145
|
|
140
146
|
# @param [Symbol,Type] type of data to read
|
141
147
|
# @return [Object]
|
@@ -145,7 +151,7 @@ module FFI
|
|
145
151
|
# ptr.get(type, 0)
|
146
152
|
def read(type)
|
147
153
|
get(type, 0)
|
148
|
-
end
|
154
|
+
end unless method_defined?(:read)
|
149
155
|
|
150
156
|
# @param [Symbol,Type] type of data to read
|
151
157
|
# @param [Object] value to write
|
@@ -156,6 +162,6 @@ module FFI
|
|
156
162
|
# ptr.put(type, 0)
|
157
163
|
def write(type, value)
|
158
164
|
put(type, 0, value)
|
159
|
-
end
|
165
|
+
end unless method_defined?(:write)
|
160
166
|
end
|
161
167
|
end
|
data/lib/ffi/struct.rb
CHANGED
@@ -32,72 +32,12 @@
|
|
32
32
|
#
|
33
33
|
|
34
34
|
require 'ffi/platform'
|
35
|
+
require 'ffi/struct_layout'
|
35
36
|
require 'ffi/struct_layout_builder'
|
37
|
+
require 'ffi/struct_by_reference'
|
36
38
|
|
37
39
|
module FFI
|
38
40
|
|
39
|
-
class StructLayout
|
40
|
-
|
41
|
-
# @return [Array<Array(Symbol, Numeric)>
|
42
|
-
# Get an array of tuples (field name, offset of the field).
|
43
|
-
def offsets
|
44
|
-
members.map { |m| [ m, self[m].offset ] }
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [Numeric]
|
48
|
-
# Get the offset of a field.
|
49
|
-
def offset_of(field_name)
|
50
|
-
self[field_name].offset
|
51
|
-
end
|
52
|
-
|
53
|
-
# An enum {Field} in a {StructLayout}.
|
54
|
-
class Enum < Field
|
55
|
-
|
56
|
-
# @param [AbstractMemory] ptr pointer on a {Struct}
|
57
|
-
# @return [Object]
|
58
|
-
# Get an object of type {#type} from memory pointed by +ptr+.
|
59
|
-
def get(ptr)
|
60
|
-
type.find(ptr.get_int(offset))
|
61
|
-
end
|
62
|
-
|
63
|
-
# @param [AbstractMemory] ptr pointer on a {Struct}
|
64
|
-
# @param value
|
65
|
-
# @return [nil]
|
66
|
-
# Set +value+ into memory pointed by +ptr+.
|
67
|
-
def put(ptr, value)
|
68
|
-
ptr.put_int(offset, type.find(value))
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
class InnerStruct < Field
|
74
|
-
def get(ptr)
|
75
|
-
type.struct_class.new(ptr.slice(self.offset, self.size))
|
76
|
-
end
|
77
|
-
|
78
|
-
def put(ptr, value)
|
79
|
-
raise TypeError, "wrong value type (expected #{type.struct_class})" unless value.is_a?(type.struct_class)
|
80
|
-
ptr.slice(self.offset, self.size).__copy_from__(value.pointer, self.size)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
class Mapped < Field
|
85
|
-
def initialize(name, offset, type, orig_field)
|
86
|
-
super(name, offset, type)
|
87
|
-
@orig_field = orig_field
|
88
|
-
end
|
89
|
-
|
90
|
-
def get(ptr)
|
91
|
-
type.from_native(@orig_field.get(ptr), nil)
|
92
|
-
end
|
93
|
-
|
94
|
-
def put(ptr, value)
|
95
|
-
@orig_field.put(ptr, type.to_native(value, nil))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
41
|
class Struct
|
102
42
|
|
103
43
|
# Get struct size
|
@@ -250,7 +190,7 @@ module FFI
|
|
250
190
|
# :field2, :pointer, 6, # set offset to 6 for this field
|
251
191
|
# :field3, :string
|
252
192
|
# end
|
253
|
-
# @example Creating a layout from a hash +spec+
|
193
|
+
# @example Creating a layout from a hash +spec+
|
254
194
|
# class MyStructFromHash < Struct
|
255
195
|
# layout :field1 => :int,
|
256
196
|
# :field2 => :pointer,
|
@@ -262,11 +202,11 @@ module FFI
|
|
262
202
|
# :function2, callback([:pointer], :void),
|
263
203
|
# :field3, :string
|
264
204
|
# end
|
265
|
-
# @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9.
|
266
205
|
def layout(*spec)
|
267
|
-
#raise RuntimeError, "struct layout already defined for #{self.inspect}" if defined?(@layout)
|
268
206
|
return @layout if spec.size == 0
|
269
207
|
|
208
|
+
warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout)
|
209
|
+
|
270
210
|
builder = StructLayoutBuilder.new
|
271
211
|
builder.union = self < Union
|
272
212
|
builder.packed = @packed if defined?(@packed)
|
@@ -289,14 +229,18 @@ module FFI
|
|
289
229
|
|
290
230
|
def callback(params, ret)
|
291
231
|
mod = enclosing_module
|
292
|
-
|
232
|
+
ret_type = find_type(ret, mod)
|
233
|
+
if ret_type == Type::STRING
|
234
|
+
raise TypeError, ":string is not allowed as return type of callbacks"
|
235
|
+
end
|
236
|
+
FFI::CallbackInfo.new(ret_type, params.map { |e| find_type(e, mod) })
|
293
237
|
end
|
294
238
|
|
295
239
|
def packed(packed = 1)
|
296
240
|
@packed = packed
|
297
241
|
end
|
298
242
|
alias :pack :packed
|
299
|
-
|
243
|
+
|
300
244
|
def aligned(alignment = 1)
|
301
245
|
@min_alignment = alignment
|
302
246
|
end
|
@@ -305,7 +249,9 @@ module FFI
|
|
305
249
|
def enclosing_module
|
306
250
|
begin
|
307
251
|
mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) }
|
308
|
-
(
|
252
|
+
if mod.respond_to?(:find_type) && (mod.is_a?(FFI::Library) || mod < FFI::Struct)
|
253
|
+
mod
|
254
|
+
end
|
309
255
|
rescue Exception
|
310
256
|
nil
|
311
257
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010 Wayne Meissner
|
3
|
+
#
|
4
|
+
# This file is part of ruby-ffi.
|
5
|
+
#
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
12
|
+
# list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
15
|
+
# and/or other materials provided with the distribution.
|
16
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
17
|
+
# may be used to endorse or promote products derived from this software
|
18
|
+
# without specific prior written permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
24
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
|
30
|
+
|
31
|
+
module FFI
|
32
|
+
# This class includes the {FFI::DataConverter} module.
|
33
|
+
class StructByReference
|
34
|
+
include DataConverter
|
35
|
+
|
36
|
+
attr_reader :struct_class
|
37
|
+
|
38
|
+
# @param [Struct] struct_class
|
39
|
+
def initialize(struct_class)
|
40
|
+
unless Class === struct_class and struct_class < FFI::Struct
|
41
|
+
raise TypeError, 'wrong type (expected subclass of FFI::Struct)'
|
42
|
+
end
|
43
|
+
@struct_class = struct_class
|
44
|
+
end
|
45
|
+
|
46
|
+
# Always get {FFI::Type}::POINTER.
|
47
|
+
def native_type
|
48
|
+
FFI::Type::POINTER
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param [nil, Struct] value
|
52
|
+
# @param [nil] ctx
|
53
|
+
# @return [AbstractMemory] Pointer on +value+.
|
54
|
+
def to_native(value, ctx)
|
55
|
+
return Pointer::NULL if value.nil?
|
56
|
+
|
57
|
+
unless @struct_class === value
|
58
|
+
raise TypeError, "wrong argument type #{value.class} (expected #{@struct_class})"
|
59
|
+
end
|
60
|
+
|
61
|
+
value.pointer
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param [AbstractMemory] value
|
65
|
+
# @param [nil] ctx
|
66
|
+
# @return [Struct]
|
67
|
+
# Create a struct from content of memory +value+.
|
68
|
+
def from_native(value, ctx)
|
69
|
+
@struct_class.new(value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|