ffi 1.15.5 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +54 -0
- data/Gemfile +1 -1
- data/README.md +3 -2
- data/Rakefile +10 -7
- data/ext/ffi_c/AbstractMemory.c +56 -34
- 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 +86 -29
- data/ext/ffi_c/Call.c +13 -5
- data/ext/ffi_c/DynamicLibrary.c +89 -26
- data/ext/ffi_c/Function.c +238 -98
- data/ext/ffi_c/Function.h +1 -0
- data/ext/ffi_c/FunctionInfo.c +78 -24
- data/ext/ffi_c/LastError.c +25 -7
- data/ext/ffi_c/MappedType.c +66 -23
- data/ext/ffi_c/MappedType.h +0 -2
- data/ext/ffi_c/MemoryPointer.c +34 -7
- data/ext/ffi_c/MethodHandle.c +3 -1
- data/ext/ffi_c/Pointer.c +68 -29
- data/ext/ffi_c/Pointer.h +1 -0
- data/ext/ffi_c/Struct.c +151 -80
- data/ext/ffi_c/Struct.h +7 -4
- data/ext/ffi_c/StructByValue.c +48 -16
- data/ext/ffi_c/StructLayout.c +117 -48
- data/ext/ffi_c/Type.c +104 -36
- data/ext/ffi_c/Type.h +3 -1
- data/ext/ffi_c/Types.c +1 -1
- data/ext/ffi_c/Variadic.c +65 -23
- data/ext/ffi_c/compat.h +22 -22
- data/ext/ffi_c/extconf.rb +19 -2
- data/ext/ffi_c/ffi.c +4 -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 +27 -9
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
- data/ext/ffi_c/libffi/.ci/build.sh +124 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
- data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
- data/ext/ffi_c/libffi/.circleci/config.yml +156 -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/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +12 -5
- data/ext/ffi_c/libffi/Makefile.in +118 -51
- data/ext/ffi_c/libffi/README.md +144 -104
- data/ext/ffi_c/libffi/acinclude.m4 +10 -112
- data/ext/ffi_c/libffi/config.guess +623 -556
- data/ext/ffi_c/libffi/config.sub +75 -34
- data/ext/ffi_c/libffi/configure +4571 -3830
- data/ext/ffi_c/libffi/configure.ac +64 -28
- data/ext/ffi_c/libffi/configure.host +25 -6
- data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
- data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +10 -9
- data/ext/ffi_c/libffi/include/ffi.h.in +54 -50
- data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +92 -69
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +512 -315
- 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_compiler_vendor.m4 +76 -45
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/man/Makefile.in +9 -6
- data/ext/ffi_c/libffi/missing +1 -1
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
- data/ext/ffi_c/libffi/msvcc.sh +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
- data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
- 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 +62 -17
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
- data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
- data/ext/ffi_c/libffi/src/closures.c +133 -47
- data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
- 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/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/mips/ffi.c +240 -65
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
- data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
- data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
- data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
- data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
- data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
- data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
- data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
- 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 +99 -37
- data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +43 -0
- 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 +172 -38
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
- data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
- data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
- 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 -114
- data/ext/ffi_c/libffi/testsuite/Makefile.in +137 -121
- 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 +43 -21
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
- 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/ffitest.h +28 -3
- 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_fn0.c +3 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
- data/ext/ffi_c/libffi/testsuite/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.closures/nested_struct2.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
- data/ext/ffi_c/libffi/testsuite/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.closures/stret_medium.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
- data/ext/ffi_c/libffi.bsd.mk +2 -2
- data/ext/ffi_c/libffi.gnu.mk +2 -2
- data/ext/ffi_c/rbffi.h +1 -1
- data/ffi.gemspec +2 -2
- data/lib/ffi/autopointer.rb +7 -22
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +2 -2
- data/lib/ffi/dynamic_library.rb +89 -0
- data/lib/ffi/enum.rb +18 -11
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/library.rb +55 -71
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +1 -1
- data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
- 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/loongarch64-linux/types.conf +141 -0
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- data/lib/ffi/platform.rb +15 -13
- data/lib/ffi/struct.rb +2 -1
- data/lib/ffi/struct_layout.rb +1 -1
- data/lib/ffi/struct_layout_builder.rb +1 -1
- data/lib/ffi/types.rb +30 -5
- data/lib/ffi/variadic.rb +19 -8
- data/lib/ffi/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +97 -25
- metadata.gz.sig +1 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
- data/ext/ffi_c/libffi/.travis/build.sh +0 -142
- data/ext/ffi_c/libffi/.travis.yml +0 -83
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
- /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
- /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
- /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee7a1ffc0f567cd7ef2162af6e49488a4a5164aabb3baa24c652a22917e4eadc
|
|
4
|
+
data.tar.gz: 59f023b4798897616ae96d407193138b428e172e934faa54450e6e66821f4769
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf3a43c4637d326b2adfa063132baf5d157311ef372087e4c1c74c80f9fe7e04090b01f58da2b8d6f5043d019d0ed84b55831a56fa3a1689bce9ec10b92a5c3e
|
|
7
|
+
data.tar.gz: 7d3a0ec5e19c2e27faf0e99a95991c37b2db5cbdc2ebea84f2c983b988349baecaf50494f3e662883a1ecfad3c6e91b35a17ea0e49960a3a8db193525d5194ff
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
1.16.0 / 2023-09-23
|
|
2
|
+
-------------------
|
|
3
|
+
|
|
4
|
+
Fixed:
|
|
5
|
+
* Fix an issue with signed bitmasks when using flags on the most significant bit. #949
|
|
6
|
+
* Fix FFI::Pointer#initialize using NUM2LL instead of NUM2ULL.
|
|
7
|
+
* Fix FFI::Type#inspect to properly display the constant name. #1002
|
|
8
|
+
* Use libffi closure allocations on hppa-Linux. #1017
|
|
9
|
+
Previously they would segfault.
|
|
10
|
+
* Fix class name of Symbol#inspect.
|
|
11
|
+
* Fix MSVC support of libtest. #1028
|
|
12
|
+
* Fix attach_function of functions ending in ? or ! #971
|
|
13
|
+
|
|
14
|
+
Added:
|
|
15
|
+
* Convert all C-based classes to TypedData and use write barriers. #994, #995, #996, #997, #998, #999, #1000, #1001, #1003, #1004, #1005, #1006, #1007, #1008, #1009, #1010, #1011, #1012
|
|
16
|
+
This results in less pressure on the garbage collector, since the objects can be promoted to the old generation, which means they only get marked on major GC.
|
|
17
|
+
* Implement `ObjectSpace.memsize_of()` of all C-based classes.
|
|
18
|
+
* Make FFI Ractor compatible. #1023
|
|
19
|
+
Modules extended per `extend FFI::Library` need to be frozen in order to be used by non-main Ractors.
|
|
20
|
+
This can be done by calling `freeze` below of all C interface definitions.
|
|
21
|
+
* In a Ractor it's possible to:
|
|
22
|
+
* load DLLs and call its functions, access its global variables
|
|
23
|
+
* use builtin typedefs
|
|
24
|
+
* use and modify ractor local typedefs
|
|
25
|
+
* define callbacks
|
|
26
|
+
* receive async callbacks from non-ruby threads
|
|
27
|
+
* use frozen FFI::Library based modules with all attributes (enums, structs, typedefs, functions, callbacks)
|
|
28
|
+
* invoke frozen functions and callbacks defined in the main Ractor
|
|
29
|
+
* use FFI::Struct definitions from the main Ractor
|
|
30
|
+
* In a Ractor it's impossible to:
|
|
31
|
+
* create new FFI::Library based modules
|
|
32
|
+
* create new FFI::Struct definitions
|
|
33
|
+
* use custom global typedefs
|
|
34
|
+
* use non-frozen FFI::Library based modules
|
|
35
|
+
* Allow type retrieval of attached functions+variables. #1023
|
|
36
|
+
* Make FFI classes `GC.compact` friendly. #1021
|
|
37
|
+
* Update libffi and disable custom trampoline when using libffi closure allocation. #1020
|
|
38
|
+
This is because libffi changed the way how closures are allocated to static trampolines.
|
|
39
|
+
* Add types.conf for loongarch64-linux. #943
|
|
40
|
+
* Add types.conf for sw_64-linux (Shen Wei 64-bit, based on Alpha). #1018
|
|
41
|
+
* Add support for aarch64-windows. #1035
|
|
42
|
+
* Windows: Update LoadLibrary error message to include error code. #1026
|
|
43
|
+
* Allow private release method for FFI::ManagedStruct and FFI::AutoPointer. #1029
|
|
44
|
+
* Add support for passing ABI version to FFI.map_library_name. #963
|
|
45
|
+
This adds the new class FFI::LibraryPath .
|
|
46
|
+
* Add support for ruby-3.2 to windows binary gem. #1047
|
|
47
|
+
* Enable debug symbols for `rake compile` builds to ease debugging. #1048
|
|
48
|
+
|
|
49
|
+
Removed:
|
|
50
|
+
* Remove allocator of AbstractMemory. #1013
|
|
51
|
+
This disables AbstractMemory.new, which has no practical use.
|
|
52
|
+
* Remove unused FFI::SizeTypes. #1022
|
|
53
|
+
|
|
54
|
+
|
|
1
55
|
1.15.5 / 2022-01-10
|
|
2
56
|
-------------------
|
|
3
57
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Ruby-FFI https://github.com/ffi/ffi/wiki
|
|
1
|
+
# Ruby-FFI https://github.com/ffi/ffi/wiki
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ using Ruby-FFI](https://github.com/ffi/ffi/wiki/why-use-ffi).
|
|
|
15
15
|
* C structs (also nested), enums and global variables
|
|
16
16
|
* Callbacks from C to Ruby
|
|
17
17
|
* Automatic garbage collection of native memory
|
|
18
|
+
* Usable in Ractor
|
|
18
19
|
|
|
19
20
|
## Synopsis
|
|
20
21
|
|
|
@@ -62,7 +63,7 @@ On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and
|
|
|
62
63
|
From rubygems:
|
|
63
64
|
|
|
64
65
|
[sudo] gem install ffi
|
|
65
|
-
|
|
66
|
+
|
|
66
67
|
From a Gemfile using git or GitHub
|
|
67
68
|
|
|
68
69
|
gem 'ffi', github: 'ffi/ffi', submodules: true
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'rbconfig'
|
|
2
2
|
require 'date'
|
|
3
3
|
require 'fileutils'
|
|
4
|
-
require '
|
|
4
|
+
require 'yaml'
|
|
5
5
|
require 'rspec/core/rake_task'
|
|
6
6
|
require 'rubygems/package_task'
|
|
7
7
|
require 'rake/extensiontask'
|
|
@@ -30,9 +30,8 @@ CLEAN.include 'spec/ffi/fixtures/libtest.{dylib,so,dll}'
|
|
|
30
30
|
CLEAN.include 'spec/ffi/fixtures/*.o'
|
|
31
31
|
CLEAN.include 'spec/ffi/embed-test/ext/*.{o,def}'
|
|
32
32
|
CLEAN.include 'spec/ffi/embed-test/ext/Makefile'
|
|
33
|
-
CLEAN.include "pkg/ffi
|
|
34
|
-
CLEAN.include 'lib/
|
|
35
|
-
CLEAN.include 'lib/2.*'
|
|
33
|
+
CLEAN.include "pkg/ffi-*-*/"
|
|
34
|
+
CLEAN.include 'lib/{2,3}.*'
|
|
36
35
|
|
|
37
36
|
# clean all shipped files, that are not in git
|
|
38
37
|
CLEAN.include(
|
|
@@ -87,6 +86,8 @@ task 'gem:java' => 'java:gem'
|
|
|
87
86
|
FfiGemHelper.install_tasks
|
|
88
87
|
# Register windows gems to be pushed to rubygems.org
|
|
89
88
|
Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32]
|
|
89
|
+
# These platforms are not yet enabled, since there are issues on musl-based distors (alpine-linux):
|
|
90
|
+
# + %w[x86-linux x86_64-linux arm-linux aarch64-linux x86_64-darwin arm64-darwin]
|
|
90
91
|
|
|
91
92
|
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
|
92
93
|
require 'rake/extensiontask'
|
|
@@ -99,6 +100,8 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
|
|
99
100
|
ext.cross_compiling do |spec|
|
|
100
101
|
spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
|
|
101
102
|
end
|
|
103
|
+
# Enable debug info for 'rake compile' but not for 'gem install'
|
|
104
|
+
ext.config_options << "--enable-debug"
|
|
102
105
|
|
|
103
106
|
end
|
|
104
107
|
else
|
|
@@ -121,9 +124,9 @@ namespace "gem" do
|
|
|
121
124
|
desc "Build the native gem for #{plat}"
|
|
122
125
|
task plat => ['prepare', 'build'] do
|
|
123
126
|
RakeCompilerDock.sh <<-EOT, platform: plat
|
|
124
|
-
sudo apt-get update &&
|
|
125
|
-
|
|
126
|
-
rake
|
|
127
|
+
#{ "sudo apt-get update && sudo apt-get install -y libltdl-dev &&" if plat !~ /linux/ }
|
|
128
|
+
bundle --local &&
|
|
129
|
+
rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.4.0/}
|
|
127
130
|
EOT
|
|
128
131
|
end
|
|
129
132
|
end
|
data/ext/ffi_c/AbstractMemory.c
CHANGED
|
@@ -55,21 +55,30 @@
|
|
|
55
55
|
# define RB_OBJ_STRING(obj) StringValueCStr(obj)
|
|
56
56
|
#endif
|
|
57
57
|
|
|
58
|
+
static size_t memsize(const void *data);
|
|
58
59
|
static inline char* memory_address(VALUE self);
|
|
59
60
|
VALUE rbffi_AbstractMemoryClass = Qnil;
|
|
60
61
|
static VALUE NullPointerErrorClass = Qnil;
|
|
61
62
|
static ID id_to_ptr = 0, id_plus = 0, id_call = 0;
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
const rb_data_type_t rbffi_abstract_memory_data_type = { /* extern */
|
|
65
|
+
.wrap_struct_name = "FFI::AbstractMemory",
|
|
66
|
+
.function = {
|
|
67
|
+
.dmark = NULL,
|
|
68
|
+
.dfree = RUBY_TYPED_DEFAULT_FREE,
|
|
69
|
+
.dsize = memsize,
|
|
70
|
+
},
|
|
71
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
|
72
|
+
// macro to update VALUE references, as to trigger write barriers.
|
|
73
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
|
74
|
+
};
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
static size_t
|
|
77
|
+
memsize(const void *data)
|
|
78
|
+
{
|
|
79
|
+
return sizeof(AbstractMemory);
|
|
72
80
|
}
|
|
81
|
+
|
|
73
82
|
#define VAL(x, swap) (unlikely(((memory->flags & MEM_SWAP) != 0)) ? swap((x)) : (x))
|
|
74
83
|
|
|
75
84
|
#define NUM_OP(name, type, toNative, fromNative, swap) \
|
|
@@ -87,7 +96,7 @@ static VALUE \
|
|
|
87
96
|
memory_put_##name(VALUE self, VALUE offset, VALUE value) \
|
|
88
97
|
{ \
|
|
89
98
|
AbstractMemory* memory; \
|
|
90
|
-
|
|
99
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, memory); \
|
|
91
100
|
memory_op_put_##name(memory, NUM2LONG(offset), value); \
|
|
92
101
|
return self; \
|
|
93
102
|
} \
|
|
@@ -96,7 +105,7 @@ static VALUE \
|
|
|
96
105
|
memory_write_##name(VALUE self, VALUE value) \
|
|
97
106
|
{ \
|
|
98
107
|
AbstractMemory* memory; \
|
|
99
|
-
|
|
108
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, memory); \
|
|
100
109
|
memory_op_put_##name(memory, 0, value); \
|
|
101
110
|
return self; \
|
|
102
111
|
} \
|
|
@@ -115,7 +124,7 @@ static VALUE \
|
|
|
115
124
|
memory_get_##name(VALUE self, VALUE offset) \
|
|
116
125
|
{ \
|
|
117
126
|
AbstractMemory* memory; \
|
|
118
|
-
|
|
127
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, memory); \
|
|
119
128
|
return memory_op_get_##name(memory, NUM2LONG(offset)); \
|
|
120
129
|
} \
|
|
121
130
|
static VALUE memory_read_##name(VALUE self); \
|
|
@@ -123,7 +132,7 @@ static VALUE \
|
|
|
123
132
|
memory_read_##name(VALUE self) \
|
|
124
133
|
{ \
|
|
125
134
|
AbstractMemory* memory; \
|
|
126
|
-
|
|
135
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, memory); \
|
|
127
136
|
return memory_op_get_##name(memory, 0); \
|
|
128
137
|
} \
|
|
129
138
|
static MemoryOp memory_op_##name = { memory_op_get_##name, memory_op_put_##name }; \
|
|
@@ -141,7 +150,7 @@ memory_put_array_of_##name(VALUE self, VALUE offset, VALUE ary) \
|
|
|
141
150
|
if (likely(count > 0)) checkWrite(memory); \
|
|
142
151
|
checkBounds(memory, off, count * sizeof(type)); \
|
|
143
152
|
for (i = 0; i < count; i++) { \
|
|
144
|
-
type tmp = (type) VAL(toNative(
|
|
153
|
+
type tmp = (type) VAL(toNative(RARRAY_AREF(ary, i)), swap); \
|
|
145
154
|
memcpy(memory->address + off + (i * sizeof(type)), &tmp, sizeof(tmp)); \
|
|
146
155
|
} \
|
|
147
156
|
return self; \
|
|
@@ -307,6 +316,7 @@ static VALUE
|
|
|
307
316
|
memory_clear(VALUE self)
|
|
308
317
|
{
|
|
309
318
|
AbstractMemory* ptr = MEMORY(self);
|
|
319
|
+
checkWrite(ptr);
|
|
310
320
|
memset(ptr->address, 0, ptr->size);
|
|
311
321
|
return self;
|
|
312
322
|
}
|
|
@@ -321,7 +331,7 @@ memory_size(VALUE self)
|
|
|
321
331
|
{
|
|
322
332
|
AbstractMemory* ptr;
|
|
323
333
|
|
|
324
|
-
|
|
334
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
325
335
|
|
|
326
336
|
return LONG2NUM(ptr->size);
|
|
327
337
|
}
|
|
@@ -344,8 +354,8 @@ memory_get(VALUE self, VALUE type_name, VALUE offset)
|
|
|
344
354
|
nType = rbffi_Type_Lookup(type_name);
|
|
345
355
|
if(NIL_P(nType)) goto undefined_type;
|
|
346
356
|
|
|
347
|
-
|
|
348
|
-
|
|
357
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
358
|
+
TypedData_Get_Struct(nType, Type, &rbffi_type_data_type, type);
|
|
349
359
|
|
|
350
360
|
MemoryOp *op = get_memory_op(type);
|
|
351
361
|
if(op == NULL) goto undefined_type;
|
|
@@ -376,8 +386,8 @@ memory_put(VALUE self, VALUE type_name, VALUE offset, VALUE value)
|
|
|
376
386
|
nType = rbffi_Type_Lookup(type_name);
|
|
377
387
|
if(NIL_P(nType)) goto undefined_type;
|
|
378
388
|
|
|
379
|
-
|
|
380
|
-
|
|
389
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
390
|
+
TypedData_Get_Struct(nType, Type, &rbffi_type_data_type, type);
|
|
381
391
|
|
|
382
392
|
MemoryOp *op = get_memory_op(type);
|
|
383
393
|
if(op == NULL) goto undefined_type;
|
|
@@ -442,7 +452,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
|
442
452
|
count = (countnum == Qnil ? 0 : NUM2INT(countnum));
|
|
443
453
|
retVal = rb_ary_new2(count);
|
|
444
454
|
|
|
445
|
-
|
|
455
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
446
456
|
checkRead(ptr);
|
|
447
457
|
|
|
448
458
|
if (countnum != Qnil) {
|
|
@@ -633,7 +643,7 @@ memory_type_size(VALUE self)
|
|
|
633
643
|
{
|
|
634
644
|
AbstractMemory* ptr;
|
|
635
645
|
|
|
636
|
-
|
|
646
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
637
647
|
|
|
638
648
|
return INT2NUM(ptr->typeSize);
|
|
639
649
|
}
|
|
@@ -651,7 +661,7 @@ memory_aref(VALUE self, VALUE idx)
|
|
|
651
661
|
AbstractMemory* ptr;
|
|
652
662
|
VALUE rbOffset = Qnil;
|
|
653
663
|
|
|
654
|
-
|
|
664
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr);
|
|
655
665
|
|
|
656
666
|
rbOffset = ULONG2NUM(NUM2ULONG(idx) * ptr->typeSize);
|
|
657
667
|
|
|
@@ -661,7 +671,9 @@ memory_aref(VALUE self, VALUE idx)
|
|
|
661
671
|
static inline char*
|
|
662
672
|
memory_address(VALUE obj)
|
|
663
673
|
{
|
|
664
|
-
|
|
674
|
+
AbstractMemory *mem;
|
|
675
|
+
TypedData_Get_Struct(obj, AbstractMemory, &rbffi_abstract_memory_data_type, mem);
|
|
676
|
+
return mem->address;
|
|
665
677
|
}
|
|
666
678
|
|
|
667
679
|
static VALUE
|
|
@@ -669,24 +681,33 @@ memory_copy_from(VALUE self, VALUE rbsrc, VALUE rblen)
|
|
|
669
681
|
{
|
|
670
682
|
AbstractMemory* dst;
|
|
671
683
|
|
|
672
|
-
|
|
684
|
+
TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, dst);
|
|
673
685
|
|
|
674
|
-
memcpy(dst->address, rbffi_AbstractMemory_Cast(rbsrc,
|
|
686
|
+
memcpy(dst->address, rbffi_AbstractMemory_Cast(rbsrc, &rbffi_abstract_memory_data_type)->address, NUM2INT(rblen));
|
|
675
687
|
|
|
676
688
|
return self;
|
|
677
689
|
}
|
|
678
690
|
|
|
679
|
-
|
|
680
|
-
|
|
691
|
+
/*
|
|
692
|
+
* call-seq:
|
|
693
|
+
* res.freeze
|
|
694
|
+
*
|
|
695
|
+
* Freeze the AbstractMemory object and unset the writable flag.
|
|
696
|
+
*/
|
|
697
|
+
static VALUE
|
|
698
|
+
memory_freeze(VALUE self)
|
|
681
699
|
{
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
}
|
|
700
|
+
AbstractMemory* ptr = MEMORY(self);
|
|
701
|
+
ptr->flags &= ~MEM_WR;
|
|
702
|
+
return rb_call_super(0, NULL);
|
|
703
|
+
}
|
|
687
704
|
|
|
688
|
-
|
|
689
|
-
|
|
705
|
+
AbstractMemory*
|
|
706
|
+
rbffi_AbstractMemory_Cast(VALUE obj, const rb_data_type_t *data_type)
|
|
707
|
+
{
|
|
708
|
+
AbstractMemory* memory;
|
|
709
|
+
TypedData_Get_Struct(obj, AbstractMemory, data_type, memory);
|
|
710
|
+
return memory;
|
|
690
711
|
}
|
|
691
712
|
|
|
692
713
|
void
|
|
@@ -781,7 +802,7 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
|
|
781
802
|
* Document-variable: FFI::AbstractMemory
|
|
782
803
|
*/
|
|
783
804
|
rb_global_variable(&rbffi_AbstractMemoryClass);
|
|
784
|
-
|
|
805
|
+
rb_undef_alloc_func(classMemory);
|
|
785
806
|
|
|
786
807
|
NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
|
|
787
808
|
/* Document-variable: NullPointerError */
|
|
@@ -1096,6 +1117,7 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
|
|
1096
1117
|
rb_define_method(classMemory, "type_size", memory_type_size, 0);
|
|
1097
1118
|
rb_define_method(classMemory, "[]", memory_aref, 1);
|
|
1098
1119
|
rb_define_method(classMemory, "__copy_from__", memory_copy_from, 2);
|
|
1120
|
+
rb_define_method(classMemory, "freeze", memory_freeze, 0 );
|
|
1099
1121
|
|
|
1100
1122
|
id_to_ptr = rb_intern("to_ptr");
|
|
1101
1123
|
id_call = rb_intern("call");
|
data/ext/ffi_c/AbstractMemory.h
CHANGED
|
@@ -86,12 +86,13 @@ struct AbstractMemory_ {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
extern const rb_data_type_t rbffi_abstract_memory_data_type;
|
|
89
90
|
extern VALUE rbffi_AbstractMemoryClass;
|
|
90
91
|
extern MemoryOps rbffi_AbstractMemoryOps;
|
|
91
92
|
|
|
92
93
|
extern void rbffi_AbstractMemory_Init(VALUE ffiModule);
|
|
93
94
|
|
|
94
|
-
extern AbstractMemory* rbffi_AbstractMemory_Cast(VALUE obj,
|
|
95
|
+
extern AbstractMemory* rbffi_AbstractMemory_Cast(VALUE obj, const rb_data_type_t *data_type);
|
|
95
96
|
|
|
96
97
|
extern void rbffi_AbstractMemory_Error(AbstractMemory *, int op);
|
|
97
98
|
|
|
@@ -161,7 +162,7 @@ get_memory_op(Type* type)
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
#define MEMORY(obj) rbffi_AbstractMemory_Cast((obj),
|
|
165
|
+
#define MEMORY(obj) rbffi_AbstractMemory_Cast((obj), &rbffi_abstract_memory_data_type)
|
|
165
166
|
#define MEMORY_PTR(obj) MEMORY((obj))->address
|
|
166
167
|
#define MEMORY_LEN(obj) MEMORY((obj))->size
|
|
167
168
|
|
data/ext/ffi_c/ArrayType.c
CHANGED
|
@@ -29,12 +29,30 @@
|
|
|
29
29
|
|
|
30
30
|
#include <ruby.h>
|
|
31
31
|
#include <ffi.h>
|
|
32
|
+
#include "compat.h"
|
|
32
33
|
#include "ArrayType.h"
|
|
33
34
|
|
|
34
35
|
static VALUE array_type_s_allocate(VALUE klass);
|
|
35
36
|
static VALUE array_type_initialize(VALUE self, VALUE rbComponentType, VALUE rbLength);
|
|
36
|
-
static void array_type_mark(
|
|
37
|
-
static void
|
|
37
|
+
static void array_type_mark(void *);
|
|
38
|
+
static void array_type_compact(void *);
|
|
39
|
+
static void array_type_free(void *);
|
|
40
|
+
static size_t array_type_memsize(const void *);
|
|
41
|
+
|
|
42
|
+
const rb_data_type_t rbffi_array_type_data_type = { /* extern */
|
|
43
|
+
.wrap_struct_name = "FFI::ArrayType",
|
|
44
|
+
.function = {
|
|
45
|
+
.dmark = array_type_mark,
|
|
46
|
+
.dfree = array_type_free,
|
|
47
|
+
.dsize = array_type_memsize,
|
|
48
|
+
ffi_compact_callback( array_type_compact )
|
|
49
|
+
},
|
|
50
|
+
.parent = &rbffi_type_data_type,
|
|
51
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
|
52
|
+
// macro to update VALUE references, as to trigger write barriers.
|
|
53
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | FFI_RUBY_TYPED_FROZEN_SHAREABLE
|
|
54
|
+
};
|
|
55
|
+
|
|
38
56
|
|
|
39
57
|
VALUE rbffi_ArrayTypeClass = Qnil;
|
|
40
58
|
|
|
@@ -44,32 +62,50 @@ array_type_s_allocate(VALUE klass)
|
|
|
44
62
|
ArrayType* array;
|
|
45
63
|
VALUE obj;
|
|
46
64
|
|
|
47
|
-
obj =
|
|
65
|
+
obj = TypedData_Make_Struct(klass, ArrayType, &rbffi_array_type_data_type, array);
|
|
48
66
|
|
|
49
67
|
array->base.nativeType = NATIVE_ARRAY;
|
|
50
68
|
array->base.ffiType = xcalloc(1, sizeof(*array->base.ffiType));
|
|
51
69
|
array->base.ffiType->type = FFI_TYPE_STRUCT;
|
|
52
70
|
array->base.ffiType->size = 0;
|
|
53
71
|
array->base.ffiType->alignment = 0;
|
|
54
|
-
array->rbComponentType
|
|
72
|
+
RB_OBJ_WRITE(obj, &array->rbComponentType, Qnil);
|
|
55
73
|
|
|
56
74
|
return obj;
|
|
57
75
|
}
|
|
58
76
|
|
|
59
77
|
static void
|
|
60
|
-
array_type_mark(
|
|
78
|
+
array_type_mark(void *data)
|
|
79
|
+
{
|
|
80
|
+
ArrayType *array = (ArrayType *)data;
|
|
81
|
+
rb_gc_mark_movable(array->rbComponentType);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static void
|
|
85
|
+
array_type_compact(void *data)
|
|
61
86
|
{
|
|
62
|
-
|
|
87
|
+
ArrayType *array = (ArrayType *)data;
|
|
88
|
+
ffi_gc_location(array->rbComponentType);
|
|
63
89
|
}
|
|
64
90
|
|
|
65
91
|
static void
|
|
66
|
-
array_type_free(
|
|
92
|
+
array_type_free(void *data)
|
|
67
93
|
{
|
|
94
|
+
ArrayType *array = (ArrayType *)data;
|
|
68
95
|
xfree(array->base.ffiType);
|
|
69
96
|
xfree(array->ffiTypes);
|
|
70
97
|
xfree(array);
|
|
71
98
|
}
|
|
72
99
|
|
|
100
|
+
static size_t
|
|
101
|
+
array_type_memsize(const void *data)
|
|
102
|
+
{
|
|
103
|
+
const ArrayType *array = (const ArrayType *)data;
|
|
104
|
+
size_t memsize = sizeof(ArrayType);
|
|
105
|
+
memsize += array->length * sizeof(*array->ffiTypes);
|
|
106
|
+
memsize += sizeof(*array->base.ffiType);
|
|
107
|
+
return memsize;
|
|
108
|
+
}
|
|
73
109
|
|
|
74
110
|
/*
|
|
75
111
|
* call-seq: initialize(component_type, length)
|
|
@@ -84,12 +120,12 @@ array_type_initialize(VALUE self, VALUE rbComponentType, VALUE rbLength)
|
|
|
84
120
|
ArrayType* array;
|
|
85
121
|
int i;
|
|
86
122
|
|
|
87
|
-
|
|
123
|
+
TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array);
|
|
88
124
|
|
|
89
125
|
array->length = NUM2UINT(rbLength);
|
|
90
|
-
array->rbComponentType
|
|
91
|
-
|
|
92
|
-
|
|
126
|
+
RB_OBJ_WRITE(self, &array->rbComponentType, rbComponentType);
|
|
127
|
+
TypedData_Get_Struct(rbComponentType, Type, &rbffi_type_data_type, array->componentType);
|
|
128
|
+
|
|
93
129
|
array->ffiTypes = xcalloc(array->length + 1, sizeof(*array->ffiTypes));
|
|
94
130
|
array->base.ffiType->elements = array->ffiTypes;
|
|
95
131
|
array->base.ffiType->size = array->componentType->ffiType->size * array->length;
|
|
@@ -112,7 +148,7 @@ array_type_length(VALUE self)
|
|
|
112
148
|
{
|
|
113
149
|
ArrayType* array;
|
|
114
150
|
|
|
115
|
-
|
|
151
|
+
TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array);
|
|
116
152
|
|
|
117
153
|
return UINT2NUM(array->length);
|
|
118
154
|
}
|
|
@@ -127,7 +163,7 @@ array_type_element_type(VALUE self)
|
|
|
127
163
|
{
|
|
128
164
|
ArrayType* array;
|
|
129
165
|
|
|
130
|
-
|
|
166
|
+
TypedData_Get_Struct(self, ArrayType, &rbffi_array_type_data_type, array);
|
|
131
167
|
|
|
132
168
|
return array->rbComponentType;
|
|
133
169
|
}
|