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
data/ext/ffi_c/Pointer.c
CHANGED
@@ -27,27 +27,39 @@
|
|
27
27
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
28
|
*/
|
29
29
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# include <stdbool.h>
|
33
|
-
#else
|
34
|
-
# include "win32/stdint.h"
|
35
|
-
# include "win32/stdbool.h"
|
36
|
-
#endif
|
30
|
+
#include <stdint.h>
|
31
|
+
#include <stdbool.h>
|
37
32
|
#include <limits.h>
|
38
33
|
#include <ruby.h>
|
39
34
|
#include "rbffi.h"
|
40
35
|
#include "rbffi_endian.h"
|
36
|
+
#include "compat.h"
|
41
37
|
#include "AbstractMemory.h"
|
42
38
|
#include "Pointer.h"
|
43
39
|
|
44
|
-
#define POINTER(obj) rbffi_AbstractMemory_Cast((obj),
|
40
|
+
#define POINTER(obj) rbffi_AbstractMemory_Cast((obj), &rbffi_pointer_data_type)
|
45
41
|
|
46
42
|
VALUE rbffi_PointerClass = Qnil;
|
47
43
|
VALUE rbffi_NullPointerSingleton = Qnil;
|
48
44
|
|
49
|
-
static void ptr_release(
|
50
|
-
static void ptr_mark(
|
45
|
+
static void ptr_release(void *data);
|
46
|
+
static void ptr_mark(void *data);
|
47
|
+
static void ptr_compact(void *data);
|
48
|
+
static size_t ptr_memsize(const void *data);
|
49
|
+
|
50
|
+
const rb_data_type_t rbffi_pointer_data_type = { /* extern */
|
51
|
+
.wrap_struct_name = "FFI::Pointer",
|
52
|
+
.function = {
|
53
|
+
.dmark = ptr_mark,
|
54
|
+
.dfree = ptr_release,
|
55
|
+
.dsize = ptr_memsize,
|
56
|
+
ffi_compact_callback( ptr_compact )
|
57
|
+
},
|
58
|
+
.parent = &rbffi_abstract_memory_data_type,
|
59
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
60
|
+
// macro to update VALUE references, as to trigger write barriers.
|
61
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
62
|
+
};
|
51
63
|
|
52
64
|
VALUE
|
53
65
|
rbffi_Pointer_NewInstance(void* addr)
|
@@ -59,12 +71,12 @@ rbffi_Pointer_NewInstance(void* addr)
|
|
59
71
|
return rbffi_NullPointerSingleton;
|
60
72
|
}
|
61
73
|
|
62
|
-
obj =
|
74
|
+
obj = TypedData_Make_Struct(rbffi_PointerClass, Pointer, &rbffi_pointer_data_type, p);
|
63
75
|
p->memory.address = addr;
|
64
76
|
p->memory.size = LONG_MAX;
|
65
77
|
p->memory.flags = (addr == NULL) ? 0 : (MEM_RD | MEM_WR);
|
66
78
|
p->memory.typeSize = 1;
|
67
|
-
p->rbParent
|
79
|
+
RB_OBJ_WRITE(obj, &p->rbParent, Qnil);
|
68
80
|
|
69
81
|
return obj;
|
70
82
|
}
|
@@ -75,8 +87,8 @@ ptr_allocate(VALUE klass)
|
|
75
87
|
Pointer* p;
|
76
88
|
VALUE obj;
|
77
89
|
|
78
|
-
obj =
|
79
|
-
p->rbParent
|
90
|
+
obj = TypedData_Make_Struct(klass, Pointer, &rbffi_pointer_data_type, p);
|
91
|
+
RB_OBJ_WRITE(obj, &p->rbParent, Qnil);
|
80
92
|
p->memory.flags = MEM_RD | MEM_WR;
|
81
93
|
|
82
94
|
return obj;
|
@@ -100,7 +112,7 @@ ptr_initialize(int argc, VALUE* argv, VALUE self)
|
|
100
112
|
VALUE rbType = Qnil, rbAddress = Qnil;
|
101
113
|
int typeSize = 1;
|
102
114
|
|
103
|
-
|
115
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, p);
|
104
116
|
|
105
117
|
switch (rb_scan_args(argc, argv, "11", &rbType, &rbAddress)) {
|
106
118
|
case 1:
|
@@ -117,7 +129,7 @@ ptr_initialize(int argc, VALUE* argv, VALUE self)
|
|
117
129
|
switch (TYPE(rbAddress)) {
|
118
130
|
case T_FIXNUM:
|
119
131
|
case T_BIGNUM:
|
120
|
-
p->memory.address = (void*) (uintptr_t)
|
132
|
+
p->memory.address = (void*) (uintptr_t) NUM2ULL(rbAddress);
|
121
133
|
p->memory.size = LONG_MAX;
|
122
134
|
if (p->memory.address == NULL) {
|
123
135
|
p->memory.flags = 0;
|
@@ -128,8 +140,8 @@ ptr_initialize(int argc, VALUE* argv, VALUE self)
|
|
128
140
|
if (rb_obj_is_kind_of(rbAddress, rbffi_PointerClass)) {
|
129
141
|
Pointer* orig;
|
130
142
|
|
131
|
-
p->rbParent
|
132
|
-
|
143
|
+
RB_OBJ_WRITE(self, &p->rbParent, rbAddress);
|
144
|
+
TypedData_Get_Struct(rbAddress, Pointer, &rbffi_pointer_data_type, orig);
|
133
145
|
p->memory = orig->memory;
|
134
146
|
} else {
|
135
147
|
rb_raise(rb_eTypeError, "wrong argument type, expected Integer or FFI::Pointer");
|
@@ -157,14 +169,14 @@ ptr_initialize_copy(VALUE self, VALUE other)
|
|
157
169
|
{
|
158
170
|
AbstractMemory* src;
|
159
171
|
Pointer* dst;
|
160
|
-
|
161
|
-
|
172
|
+
|
173
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, dst);
|
162
174
|
src = POINTER(other);
|
163
175
|
if (src->size == LONG_MAX) {
|
164
176
|
rb_raise(rb_eRuntimeError, "cannot duplicate unbounded memory area");
|
165
177
|
return Qnil;
|
166
178
|
}
|
167
|
-
|
179
|
+
|
168
180
|
if ((dst->memory.flags & (MEM_RD | MEM_WR)) != (MEM_RD | MEM_WR)) {
|
169
181
|
rb_raise(rb_eRuntimeError, "cannot duplicate unreadable/unwritable memory area");
|
170
182
|
return Qnil;
|
@@ -180,13 +192,13 @@ ptr_initialize_copy(VALUE self, VALUE other)
|
|
180
192
|
rb_raise(rb_eNoMemError, "failed to allocate memory size=%lu bytes", src->size);
|
181
193
|
return Qnil;
|
182
194
|
}
|
183
|
-
|
195
|
+
|
184
196
|
dst->allocated = true;
|
185
197
|
dst->autorelease = true;
|
186
|
-
dst->memory.address = (void *) (((uintptr_t) dst->storage + 0x7) & (uintptr_t) ~
|
198
|
+
dst->memory.address = (void *) (((uintptr_t) dst->storage + 0x7) & (uintptr_t) ~0x7ULL);
|
187
199
|
dst->memory.size = src->size;
|
188
200
|
dst->memory.typeSize = src->typeSize;
|
189
|
-
|
201
|
+
|
190
202
|
/* finally, copy the actual memory contents */
|
191
203
|
memcpy(dst->memory.address, src->address, src->size);
|
192
204
|
|
@@ -199,22 +211,22 @@ slice(VALUE self, long offset, long size)
|
|
199
211
|
AbstractMemory* ptr;
|
200
212
|
Pointer* p;
|
201
213
|
VALUE retval;
|
202
|
-
|
203
|
-
|
214
|
+
|
215
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
204
216
|
checkBounds(ptr, offset, size == LONG_MAX ? 1 : size);
|
205
217
|
|
206
|
-
retval =
|
218
|
+
retval = TypedData_Make_Struct(rbffi_PointerClass, Pointer, &rbffi_pointer_data_type, p);
|
207
219
|
|
208
220
|
p->memory.address = ptr->address + offset;
|
209
221
|
p->memory.size = size;
|
210
222
|
p->memory.flags = ptr->flags;
|
211
223
|
p->memory.typeSize = ptr->typeSize;
|
212
|
-
p->rbParent
|
224
|
+
RB_OBJ_WRITE(retval, &p->rbParent, self);
|
213
225
|
|
214
226
|
return retval;
|
215
227
|
}
|
216
228
|
|
217
|
-
/*
|
229
|
+
/*
|
218
230
|
* Document-method: +
|
219
231
|
* call-seq: ptr + offset
|
220
232
|
* @param [Numeric] offset
|
@@ -227,7 +239,7 @@ ptr_plus(VALUE self, VALUE offset)
|
|
227
239
|
AbstractMemory* ptr;
|
228
240
|
long off = NUM2LONG(offset);
|
229
241
|
|
230
|
-
|
242
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
231
243
|
|
232
244
|
return slice(self, off, ptr->size == LONG_MAX ? LONG_MAX : ptr->size - off);
|
233
245
|
}
|
@@ -237,7 +249,7 @@ ptr_plus(VALUE self, VALUE offset)
|
|
237
249
|
* @param [Numeric] offset
|
238
250
|
* @param [Numeric] length
|
239
251
|
* @return [Pointer]
|
240
|
-
* Return a new {Pointer} from an existing one. This pointer points on same contents
|
252
|
+
* Return a new {Pointer} from an existing one. This pointer points on same contents
|
241
253
|
* from +offset+ for a length +length+.
|
242
254
|
*/
|
243
255
|
static VALUE
|
@@ -256,8 +268,8 @@ ptr_inspect(VALUE self)
|
|
256
268
|
{
|
257
269
|
char buf[100];
|
258
270
|
Pointer* ptr;
|
259
|
-
|
260
|
-
|
271
|
+
|
272
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
261
273
|
|
262
274
|
if (ptr->memory.size != LONG_MAX) {
|
263
275
|
snprintf(buf, sizeof(buf), "#<%s address=%p size=%lu>",
|
@@ -280,7 +292,7 @@ ptr_null_p(VALUE self)
|
|
280
292
|
{
|
281
293
|
Pointer* ptr;
|
282
294
|
|
283
|
-
|
295
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
284
296
|
|
285
297
|
return ptr->memory.address == NULL ? Qtrue : Qfalse;
|
286
298
|
}
|
@@ -295,8 +307,8 @@ static VALUE
|
|
295
307
|
ptr_equals(VALUE self, VALUE other)
|
296
308
|
{
|
297
309
|
Pointer* ptr;
|
298
|
-
|
299
|
-
|
310
|
+
|
311
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
300
312
|
|
301
313
|
if (NIL_P(other)) {
|
302
314
|
return ptr->memory.address == NULL ? Qtrue : Qfalse;
|
@@ -314,8 +326,8 @@ static VALUE
|
|
314
326
|
ptr_address(VALUE self)
|
315
327
|
{
|
316
328
|
Pointer* ptr;
|
317
|
-
|
318
|
-
|
329
|
+
|
330
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
319
331
|
|
320
332
|
return ULL2NUM((uintptr_t) ptr->memory.address);
|
321
333
|
}
|
@@ -331,16 +343,16 @@ ptr_address(VALUE self)
|
|
331
343
|
* @overload order
|
332
344
|
* @return [:big, :little] endianness of +self+
|
333
345
|
* @overload order(order)
|
334
|
-
* @param [Symbol] order endianness to set (+:little+, +:big+ or +:network+). +:big+ and +:network+
|
346
|
+
* @param [Symbol] order endianness to set (+:little+, +:big+ or +:network+). +:big+ and +:network+
|
335
347
|
* are synonymous.
|
336
|
-
* @return
|
348
|
+
* @return a new pointer with the new order
|
337
349
|
*/
|
338
350
|
static VALUE
|
339
351
|
ptr_order(int argc, VALUE* argv, VALUE self)
|
340
352
|
{
|
341
353
|
Pointer* ptr;
|
342
354
|
|
343
|
-
|
355
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
344
356
|
if (argc == 0) {
|
345
357
|
int order = (ptr->memory.flags & MEM_SWAP) == 0 ? BYTE_ORDER : SWAPPED_ORDER;
|
346
358
|
return order == BIG_ENDIAN ? ID2SYM(rb_intern("big")) : ID2SYM(rb_intern("little"));
|
@@ -358,13 +370,15 @@ ptr_order(int argc, VALUE* argv, VALUE self)
|
|
358
370
|
|
359
371
|
} else if (id == rb_intern("big") || id == rb_intern("network")) {
|
360
372
|
order = BIG_ENDIAN;
|
373
|
+
} else {
|
374
|
+
rb_raise(rb_eArgError, "unknown byte order");
|
361
375
|
}
|
362
376
|
}
|
363
377
|
if (order != BYTE_ORDER) {
|
364
378
|
Pointer* p2;
|
365
379
|
VALUE retval = slice(self, 0, ptr->memory.size);
|
366
380
|
|
367
|
-
|
381
|
+
TypedData_Get_Struct(retval, Pointer, &rbffi_pointer_data_type, p2);
|
368
382
|
p2->memory.flags |= MEM_SWAP;
|
369
383
|
return retval;
|
370
384
|
}
|
@@ -384,7 +398,8 @@ ptr_free(VALUE self)
|
|
384
398
|
{
|
385
399
|
Pointer* ptr;
|
386
400
|
|
387
|
-
|
401
|
+
rb_check_frozen(self);
|
402
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
388
403
|
|
389
404
|
if (ptr->allocated) {
|
390
405
|
if (ptr->storage != NULL) {
|
@@ -395,7 +410,7 @@ ptr_free(VALUE self)
|
|
395
410
|
|
396
411
|
} else {
|
397
412
|
VALUE caller = rb_funcall(rb_funcall(Qnil, rb_intern("caller"), 0), rb_intern("first"), 0);
|
398
|
-
|
413
|
+
|
399
414
|
rb_warn("calling free on non allocated pointer %s from %s", RSTRING_PTR(ptr_inspect(self)), RSTRING_PTR(rb_str_to_str(caller)));
|
400
415
|
}
|
401
416
|
|
@@ -407,8 +422,8 @@ ptr_type_size(VALUE self)
|
|
407
422
|
{
|
408
423
|
Pointer* ptr;
|
409
424
|
|
410
|
-
|
411
|
-
|
425
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
426
|
+
|
412
427
|
return INT2NUM(ptr->memory.typeSize);
|
413
428
|
}
|
414
429
|
|
@@ -423,7 +438,8 @@ ptr_autorelease(VALUE self, VALUE autorelease)
|
|
423
438
|
{
|
424
439
|
Pointer* ptr;
|
425
440
|
|
426
|
-
|
441
|
+
rb_check_frozen(self);
|
442
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
427
443
|
ptr->autorelease = autorelease == Qtrue;
|
428
444
|
|
429
445
|
return autorelease;
|
@@ -439,15 +455,16 @@ ptr_autorelease_p(VALUE self)
|
|
439
455
|
{
|
440
456
|
Pointer* ptr;
|
441
457
|
|
442
|
-
|
443
|
-
|
458
|
+
TypedData_Get_Struct(self, Pointer, &rbffi_pointer_data_type, ptr);
|
459
|
+
|
444
460
|
return ptr->autorelease ? Qtrue : Qfalse;
|
445
461
|
}
|
446
462
|
|
447
463
|
|
448
464
|
static void
|
449
|
-
ptr_release(
|
465
|
+
ptr_release(void *data)
|
450
466
|
{
|
467
|
+
Pointer *ptr = (Pointer *)data;
|
451
468
|
if (ptr->autorelease && ptr->allocated && ptr->storage != NULL) {
|
452
469
|
xfree(ptr->storage);
|
453
470
|
ptr->storage = NULL;
|
@@ -456,9 +473,28 @@ ptr_release(Pointer* ptr)
|
|
456
473
|
}
|
457
474
|
|
458
475
|
static void
|
459
|
-
ptr_mark(
|
476
|
+
ptr_mark(void *data)
|
477
|
+
{
|
478
|
+
Pointer *ptr = (Pointer *)data;
|
479
|
+
rb_gc_mark_movable(ptr->rbParent);
|
480
|
+
}
|
481
|
+
|
482
|
+
static void
|
483
|
+
ptr_compact(void *data)
|
484
|
+
{
|
485
|
+
Pointer *ptr = (Pointer *)data;
|
486
|
+
ffi_gc_location(ptr->rbParent);
|
487
|
+
}
|
488
|
+
|
489
|
+
static size_t
|
490
|
+
ptr_memsize(const void *data)
|
460
491
|
{
|
461
|
-
|
492
|
+
const Pointer *ptr = (const Pointer *)data;
|
493
|
+
size_t memsize = sizeof(Pointer);
|
494
|
+
if (ptr->allocated) {
|
495
|
+
memsize += ptr->memory.size;
|
496
|
+
}
|
497
|
+
return memsize;
|
462
498
|
}
|
463
499
|
|
464
500
|
void
|
@@ -472,9 +508,11 @@ rbffi_Pointer_Init(VALUE moduleFFI)
|
|
472
508
|
* Pointer class is used to manage C pointers with ease. A {Pointer} object is defined by his
|
473
509
|
* {#address} (as a C pointer). It permits additions with an integer for pointer arithmetic.
|
474
510
|
*
|
475
|
-
* ==Autorelease
|
476
|
-
*
|
477
|
-
*
|
511
|
+
* == Autorelease
|
512
|
+
* By default a pointer object frees its content when it's garbage collected.
|
513
|
+
* Therefore it's usually not necessary to call {#free} explicit.
|
514
|
+
* This behaviour may be changed with {#autorelease=} method.
|
515
|
+
* If it's set to +false+, the memory isn't freed by the garbage collector, but stays valid until +free()+ is called on C level or when the process terminates.
|
478
516
|
*/
|
479
517
|
rbffi_PointerClass = rb_define_class_under(moduleFFI, "Pointer", ffi_AbstractMemory);
|
480
518
|
/*
|
data/ext/ffi_c/Pointer.h
CHANGED
@@ -30,11 +30,7 @@
|
|
30
30
|
#ifndef RBFFI_POINTER_H
|
31
31
|
#define RBFFI_POINTER_H
|
32
32
|
|
33
|
-
#ifndef _MSC_VER
|
34
33
|
# include <stdbool.h>
|
35
|
-
#else
|
36
|
-
# include "win32/stdbool.h"
|
37
|
-
#endif
|
38
34
|
|
39
35
|
#ifdef __cplusplus
|
40
36
|
extern "C" {
|
@@ -44,6 +40,7 @@ extern "C" {
|
|
44
40
|
|
45
41
|
extern void rbffi_Pointer_Init(VALUE moduleFFI);
|
46
42
|
extern VALUE rbffi_Pointer_NewInstance(void* addr);
|
43
|
+
extern const rb_data_type_t rbffi_pointer_data_type;
|
47
44
|
extern VALUE rbffi_PointerClass;
|
48
45
|
extern VALUE rbffi_NullPointerSingleton;
|
49
46
|
|