ffi 1.10.0 → 1.13.1
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
- data/{appveyor.yml → .appveyor.yml} +9 -1
- data/.github/workflows/ci.yml +64 -0
- data/.gitignore +3 -0
- data/.gitmodules +1 -0
- data/.travis.yml +35 -20
- data/CHANGELOG.md +124 -0
- data/Gemfile +6 -4
- data/README.md +29 -17
- data/Rakefile +29 -120
- data/ext/ffi_c/AbstractMemory.c +5 -9
- data/ext/ffi_c/Buffer.c +2 -2
- data/ext/ffi_c/Call.c +14 -41
- data/ext/ffi_c/Call.h +4 -7
- data/ext/ffi_c/ClosurePool.c +11 -14
- data/ext/ffi_c/DynamicLibrary.c +1 -1
- data/ext/ffi_c/Function.c +18 -117
- data/ext/ffi_c/FunctionInfo.c +1 -2
- data/ext/ffi_c/LongDouble.c +12 -10
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +1 -1
- data/ext/ffi_c/MethodHandle.c +18 -24
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +1 -47
- data/ext/ffi_c/Pointer.c +1 -1
- data/ext/ffi_c/Struct.c +47 -51
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructLayout.c +20 -14
- data/ext/ffi_c/Thread.c +4 -223
- data/ext/ffi_c/Thread.h +0 -14
- data/ext/ffi_c/Type.c +0 -18
- data/ext/ffi_c/Type.h +0 -1
- data/ext/ffi_c/Types.c +1 -1
- data/ext/ffi_c/Variadic.c +9 -15
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +36 -26
- data/ext/ffi_c/ffi.c +3 -8
- data/ext/ffi_c/libffi.darwin.mk +1 -1
- data/ext/ffi_c/libffi/.appveyor.yml +29 -13
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.travis.yml +51 -2
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
- data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
- data/ext/ffi_c/libffi/.travis/build.sh +116 -8
- data/ext/ffi_c/libffi/.travis/install.sh +65 -16
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/site.exp +10 -1
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
- 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 +35 -41
- data/ext/ffi_c/libffi/README.md +29 -8
- data/ext/ffi_c/libffi/configure.ac +31 -11
- data/ext/ffi_c/libffi/configure.host +26 -9
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -3
- data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
- data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
- 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 +1 -1
- 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_check_compile_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
- 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/make_sunver.pl +333 -0
- 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/msvcc.sh +27 -2
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +132 -58
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +13 -2
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +21 -8
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +40 -5
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/arm/sysv.S +2 -0
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/closures.c +51 -13
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
- data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
- 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 +83 -28
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +68 -4
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
- 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/x86/ffi.c +21 -10
- data/ext/ffi_c/libffi/src/x86/ffi64.c +15 -11
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +15 -10
- data/ext/ffi_c/libffi/src/x86/sysv.S +103 -8
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +99 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +9 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +26 -22
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
- 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 +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.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_double_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.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}/cls_multi_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.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.closures/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.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/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
- data/ext/ffi_c/rbffi.h +0 -2
- data/ffi.gemspec +12 -5
- data/lib/ffi.rb +10 -2
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/ffi.rb +2 -0
- data/lib/ffi/library.rb +10 -6
- data/lib/ffi/platform.rb +12 -3
- data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +89 -89
- data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
- data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
- data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
- data/lib/ffi/platform/arm-linux/types.conf +110 -82
- 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 +87 -87
- data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
- 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/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/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/sparc64-linux/types.conf +79 -79
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- 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 +89 -89
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
- data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
- 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/pointer.rb +20 -13
- data/lib/ffi/struct.rb +13 -68
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/tools/const_generator.rb +5 -4
- data/lib/ffi/tools/generator.rb +47 -2
- data/lib/ffi/tools/generator_task.rb +13 -17
- data/lib/ffi/tools/struct_generator.rb +4 -4
- data/lib/ffi/tools/types_generator.rb +7 -4
- data/lib/ffi/types.rb +1 -1
- data/lib/ffi/version.rb +1 -1
- 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/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +141 -116
- 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/ChangeLog.libffi +0 -584
- data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
- data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
- data/samples/sample_helper.rb +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c1ae7c590f7dd4d8d821c6faf31c66499a90c421ff25fe14ce4465cc058b83f
|
|
4
|
+
data.tar.gz: e4c16035d46e13e752e215fdc87511c214db31cec9084cca3c2141a9d83469c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4064371f99217b7b449c46915e4505b54a61785ec27a2b5cd51d798cc929ff58bef33ad9064ab93ca85ad2c5d5c07d515edb0ac5d673a468fb17abf18565627
|
|
7
|
+
data.tar.gz: a545c796f0b36fb7cac6ac06a73094274d077e0e0f54f55f67c129e6bff27b7679886a3adc87e9b3c173f975864dc78ac3d6277d8a8d1352f974b697ace0f8b4
|
|
@@ -10,13 +10,21 @@ install:
|
|
|
10
10
|
- gem --version
|
|
11
11
|
- gem install bundler --quiet --no-document
|
|
12
12
|
- bundle install
|
|
13
|
+
# Update to libffi-3.3 since Appveyor version fails on LongDouble specs
|
|
14
|
+
- ridk exec pacman --sync --refresh --needed --noconfirm mingw-w64-x86_64-libffi mingw-w64-i686-libffi
|
|
13
15
|
build: off
|
|
14
16
|
build_script:
|
|
15
|
-
- bundle exec rake compile || bundle exec rake compile
|
|
17
|
+
- bundle exec rake libffi compile -- %EXTCONFOPTS% || bundle exec rake compile -- %EXTCONFOPTS%
|
|
16
18
|
test_script:
|
|
17
19
|
- bundle exec rake test
|
|
20
|
+
- bundle exec rake types_conf && git --no-pager diff
|
|
18
21
|
environment:
|
|
19
22
|
matrix:
|
|
20
23
|
- RUBYVER: "head-x64"
|
|
24
|
+
EXTCONFOPTS: "--disable-system-libffi"
|
|
21
25
|
- RUBYVER: 24
|
|
26
|
+
EXTCONFOPTS: "--disable-system-libffi"
|
|
22
27
|
- RUBYVER: 25-x64
|
|
28
|
+
EXTCONFOPTS: "--enable-system-libffi"
|
|
29
|
+
- RUBYVER: 26
|
|
30
|
+
EXTCONFOPTS: "--enable-system-libffi"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
system-libffi:
|
|
5
|
+
# Run on latest MRI with explicit selection of system or builtin libffi
|
|
6
|
+
strategy:
|
|
7
|
+
fail-fast: false
|
|
8
|
+
matrix:
|
|
9
|
+
os: [ ubuntu, macos, windows ]
|
|
10
|
+
extconfopts: [ --disable-system-libffi, --enable-system-libffi ]
|
|
11
|
+
runs-on: ${{ matrix.os }}-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
- uses: ruby/setup-ruby@v1
|
|
15
|
+
with:
|
|
16
|
+
ruby-version: 2.7
|
|
17
|
+
|
|
18
|
+
- run: brew install automake libffi pkg-config
|
|
19
|
+
if: matrix.os == 'macos'
|
|
20
|
+
- run: ridk exec pacman --sync --refresh --needed --noconfirm mingw-w64-x86_64-libffi
|
|
21
|
+
if: matrix.os == 'windows' && matrix.extconfopts == '--enable-system-libffi'
|
|
22
|
+
|
|
23
|
+
- run: bundle install
|
|
24
|
+
- run: bundle exec rake libffi
|
|
25
|
+
- run: bundle exec rake compile -- ${{ matrix.extconfopts }}
|
|
26
|
+
env:
|
|
27
|
+
# work around misconfiguration of libffi on MacOS with homebrew
|
|
28
|
+
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:/usr/local/opt/libffi/lib/pkgconfig
|
|
29
|
+
- run: bundle exec rake test
|
|
30
|
+
- run: bundle exec rake types_conf && git --no-pager diff
|
|
31
|
+
|
|
32
|
+
specs:
|
|
33
|
+
# Run all specs on all ruby implementations
|
|
34
|
+
# Use automatic libffi selection on MRI
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
os: [ ubuntu, macos, windows ]
|
|
39
|
+
ruby: [ 2.3, 2.4, 2.5, 2.6, 2.7, ruby-head, truffleruby-head ]
|
|
40
|
+
exclude:
|
|
41
|
+
- os: windows
|
|
42
|
+
ruby: truffleruby-head
|
|
43
|
+
- os: windows
|
|
44
|
+
ruby: 2.3 # compilation fails
|
|
45
|
+
runs-on: ${{ matrix.os }}-latest
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v2
|
|
48
|
+
- uses: ruby/setup-ruby@v1
|
|
49
|
+
with:
|
|
50
|
+
ruby-version: ${{ matrix.ruby }}
|
|
51
|
+
|
|
52
|
+
- run: brew install automake
|
|
53
|
+
if: matrix.os == 'macos'
|
|
54
|
+
|
|
55
|
+
- run: bundle install
|
|
56
|
+
- run: bundle exec rake libffi
|
|
57
|
+
- run: bundle exec rake compile
|
|
58
|
+
|
|
59
|
+
- run: bundle exec rake test
|
|
60
|
+
|
|
61
|
+
- run: bundle exec rake bench:all
|
|
62
|
+
if: matrix.ruby != 'truffleruby-head'
|
|
63
|
+
env:
|
|
64
|
+
ITER: 10
|
data/.gitignore
CHANGED
data/.gitmodules
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,43 +1,58 @@
|
|
|
1
1
|
dist: trusty
|
|
2
|
-
sudo: false
|
|
3
2
|
group: beta
|
|
4
3
|
language: ruby
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
git:
|
|
5
|
+
submodules: false
|
|
6
|
+
|
|
7
7
|
script:
|
|
8
|
-
- bundle exec rake
|
|
8
|
+
- bundle exec rake libffi
|
|
9
|
+
- bundle exec rake compile
|
|
9
10
|
- bundle exec rake test
|
|
11
|
+
- |
|
|
12
|
+
if [[ $(ruby -v) != *truffleruby* ]]; then
|
|
13
|
+
ITER=10 bundle exec rake bench:all
|
|
14
|
+
fi
|
|
15
|
+
- bundle exec rake types_conf && git --no-pager diff
|
|
10
16
|
os:
|
|
11
17
|
- linux
|
|
12
18
|
- osx
|
|
13
19
|
rvm:
|
|
14
20
|
- 2.3.8
|
|
15
|
-
- 2.4.
|
|
16
|
-
- 2.5.
|
|
17
|
-
- 2.6.
|
|
21
|
+
- 2.4.6
|
|
22
|
+
- 2.5.5
|
|
23
|
+
- 2.6.5
|
|
24
|
+
- 2.7.0
|
|
18
25
|
- ruby-head
|
|
19
|
-
-
|
|
26
|
+
- truffleruby-head
|
|
27
|
+
|
|
20
28
|
env:
|
|
21
29
|
- CC=gcc
|
|
22
30
|
- CC=clang
|
|
23
31
|
matrix:
|
|
24
32
|
allow_failures:
|
|
25
|
-
- rvm: system
|
|
26
33
|
- os: osx
|
|
27
34
|
rvm: ruby-head
|
|
28
|
-
exclude: # ruby 2.4.2 needs build with xcode9 or later on osx
|
|
29
35
|
- os: osx
|
|
30
|
-
rvm: 2.
|
|
36
|
+
rvm: 2.3.8
|
|
37
|
+
- os: linux
|
|
38
|
+
rvm: ruby-head
|
|
31
39
|
include:
|
|
40
|
+
- name: powerpc
|
|
41
|
+
language: generic
|
|
42
|
+
before_install: |
|
|
43
|
+
docker run --rm --privileged multiarch/qemu-user-static:register --reset &&
|
|
44
|
+
docker build --rm -t ffi-powerpc -f spec/env/Dockerfile.powerpc .
|
|
45
|
+
script: |
|
|
46
|
+
docker run --rm -t -v `pwd`:/ffi ffi-powerpc
|
|
47
|
+
- name: armhf
|
|
48
|
+
language: generic
|
|
49
|
+
before_install: |
|
|
50
|
+
docker run --rm --privileged multiarch/qemu-user-static:register --reset &&
|
|
51
|
+
docker build --rm -t ffi-armhf -f spec/env/Dockerfile.armhf .
|
|
52
|
+
script: |
|
|
53
|
+
docker run --rm -t -v `pwd`:/ffi ffi-armhf
|
|
54
|
+
exclude:
|
|
32
55
|
- os: osx
|
|
33
|
-
|
|
34
|
-
rvm: 2.4.2
|
|
35
|
-
env:
|
|
36
|
-
- CC=gcc
|
|
37
|
-
- os: osx
|
|
38
|
-
osx_image: xcode9.1
|
|
39
|
-
rvm: 2.4.2
|
|
40
|
-
env:
|
|
41
|
-
- CC=clang
|
|
56
|
+
rvm: truffleruby-head
|
|
42
57
|
after_failure:
|
|
43
58
|
- "find build -name mkmf.log | xargs cat"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
+
1.13.1 / 2020-06-09
|
|
2
|
+
-------------------
|
|
3
|
+
|
|
4
|
+
Changed:
|
|
5
|
+
* Revert use of `ucrtbase.dll` as default C library on Windows-MINGW.
|
|
6
|
+
`ucrtbase.dll` is still used on MSWIN target. #790
|
|
7
|
+
* Test for `ffi_prep_closure_loc()` to make sure we can use this function.
|
|
8
|
+
This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787
|
|
9
|
+
* Update types.conf on x86_64-dragonflybsd
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
1.13.0 / 2020-06-01
|
|
13
|
+
-------------------
|
|
14
|
+
|
|
15
|
+
Added:
|
|
16
|
+
* Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768
|
|
17
|
+
* Add ruby source files to the java gem. This allows to ship the Ruby library code per platform java gem and add it as a default gem to JRuby. #763
|
|
18
|
+
* Add FFI::Platform::LONG_DOUBLE_SIZE
|
|
19
|
+
* Add bounds checks for writing to an inline char[] . #756
|
|
20
|
+
* Add long double as callback return value. #771
|
|
21
|
+
* Update type definitions and add types from stdint.h and stddef.h on i386-windows, x86_64-windows, x86_64-darwin, x86_64-linux, arm-linux, powerpc-linux. #749
|
|
22
|
+
* Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778
|
|
23
|
+
|
|
24
|
+
Changed:
|
|
25
|
+
* Raise required ruby version to >= 2.3.
|
|
26
|
+
* Lots of cleanups and improvements in library, specs and benchmarks.
|
|
27
|
+
* Fix a lot of compiler warnings at the C-extension
|
|
28
|
+
* Fix several install issues on MacOS:
|
|
29
|
+
* Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757
|
|
30
|
+
* Fix error `ld: library not found for -lgcc_s.10.4`
|
|
31
|
+
* Don't built for i386 architecture as it is deprecated
|
|
32
|
+
* Several fixes for MSVC build on Windows. #779
|
|
33
|
+
* Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779
|
|
34
|
+
* Update builtin libffi to fix a Powerpc issue with parameters of type long
|
|
35
|
+
* Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747
|
|
36
|
+
* Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776
|
|
37
|
+
|
|
38
|
+
Removed:
|
|
39
|
+
* Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
1.12.2 / 2020-02-01
|
|
43
|
+
-------------------
|
|
44
|
+
|
|
45
|
+
* Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
1.12.1 / 2020-01-14
|
|
49
|
+
-------------------
|
|
50
|
+
|
|
51
|
+
Added:
|
|
52
|
+
* Add binary gem support for ruby-2.7 on Windows
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
1.12.0 / 2020-01-14
|
|
56
|
+
-------------------
|
|
57
|
+
|
|
58
|
+
Added:
|
|
59
|
+
* FFI::VERSION is defined as part of `require 'ffi'` now.
|
|
60
|
+
It is no longer necessary to `require 'ffi/version'` .
|
|
61
|
+
|
|
62
|
+
Changed:
|
|
63
|
+
* Update libffi to latest master.
|
|
64
|
+
|
|
65
|
+
Deprecated:
|
|
66
|
+
* Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
1.11.3 / 2019-11-25
|
|
70
|
+
-------------------
|
|
71
|
+
|
|
72
|
+
Removed:
|
|
73
|
+
* Remove support for tainted objects which cause deprecation warnings in ruby-2.7. #730
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
1.11.2 / 2019-11-11
|
|
77
|
+
-------------------
|
|
78
|
+
|
|
79
|
+
Added:
|
|
80
|
+
* Add DragonFlyBSD as a platform. #724
|
|
81
|
+
|
|
82
|
+
Changed:
|
|
83
|
+
* Sort all types.conf files, so that files and changes are easier to compare.
|
|
84
|
+
* Regenerated type conf for freebsd12 and x86_64-linux targets. #722
|
|
85
|
+
* Remove MACOSX_DEPLOYMENT_TARGET that was targeting very old version 10.4. #647
|
|
86
|
+
* Fix library name mangling for non glibc Linux/UNIX. #727
|
|
87
|
+
* Fix compiler warnings raised by ruby-2.7
|
|
88
|
+
* Update libffi to latest master.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
1.11.1 / 2019-05-20
|
|
92
|
+
-------------------
|
|
93
|
+
|
|
94
|
+
Changed:
|
|
95
|
+
* Raise required ruby version to >=2.0. #699, #700
|
|
96
|
+
* Fix a possible linker error on ruby < 2.3 on Linux.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
1.11.0 / 2019-05-17
|
|
100
|
+
-------------------
|
|
101
|
+
This version was yanked on 2019-05-20 to fix an install issue on ruby-1.9.3. #700
|
|
102
|
+
|
|
103
|
+
Added:
|
|
104
|
+
* Add ability to disable or force use of system libffi. #669
|
|
105
|
+
Use like `gem inst ffi -- --enable-system-libffi` .
|
|
106
|
+
* Add ability to call FFI callbacks from outside of FFI call frame. #584
|
|
107
|
+
* Add proper documentation to FFI::Generator and ::Task
|
|
108
|
+
* Add gemspec metadata. #696, #698
|
|
109
|
+
|
|
110
|
+
Changed:
|
|
111
|
+
* Fix stdcall on Win32. #649, #669
|
|
112
|
+
* Fix load paths for FFI::Generator::Task
|
|
113
|
+
* Fix FFI::Pointer#read_string(0) to return a binary String. #692
|
|
114
|
+
* Fix benchmark suite so that it runs on ruby-2.x
|
|
115
|
+
* Move FFI::Platform::CPU from C to Ruby. #663
|
|
116
|
+
* Move FFI::StructByReference to Ruby. #681
|
|
117
|
+
* Move FFI::DataConverter to Ruby (#661)
|
|
118
|
+
* Various cleanups and improvements of specs and benchmarks
|
|
119
|
+
|
|
120
|
+
Removed:
|
|
121
|
+
* Remove ruby-1.8 and 1.9 compatibility code. #683
|
|
122
|
+
* Remove unused spec files. #684
|
|
123
|
+
|
|
124
|
+
|
|
1
125
|
1.10.0 / 2019-01-06
|
|
2
126
|
-------------------
|
|
3
127
|
|
data/Gemfile
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
group :development do
|
|
4
|
-
gem 'rake', '~>
|
|
4
|
+
gem 'rake', '~> 13.0'
|
|
5
5
|
gem 'rake-compiler', '~> 1.0.3'
|
|
6
|
-
gem 'rake-compiler-dock', '~>
|
|
6
|
+
gem 'rake-compiler-dock', '~> 1.0'
|
|
7
7
|
gem 'rspec', '~> 3.0'
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
# irb is a dependency of rubygems-tasks 0.2.5.
|
|
9
|
+
# irb versions > 1.1.1 depend on reline,
|
|
10
|
+
# which sometimes causes 'bundle install' to fail on Ruby <= 2.4: https://github.com/rubygems/rubygems/issues/3463
|
|
11
|
+
gem 'rubygems-tasks', '>= 0.2', '< 0.2.5', :require => 'rubygems/tasks'
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
group :doc do
|
data/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ruby-FFI https://github.com/ffi/ffi/wiki [](https://travis-ci.org/ffi/ffi) [](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
Ruby-FFI is a
|
|
5
|
+
Ruby-FFI is a gem for programmatically loading dynamically-linked native
|
|
6
6
|
libraries, binding functions within them, and calling those functions
|
|
7
7
|
from Ruby code. Moreover, a Ruby-FFI extension works without changes
|
|
8
|
-
on
|
|
9
|
-
using Ruby-FFI](https://
|
|
8
|
+
on CRuby (MRI), JRuby, Rubinius and TruffleRuby. [Discover why you should write your next extension
|
|
9
|
+
using Ruby-FFI](https://github.com/ffi/ffi/wiki/why-use-ffi).
|
|
10
10
|
|
|
11
|
-
## Features
|
|
11
|
+
## Features
|
|
12
12
|
|
|
13
13
|
* Intuitive DSL
|
|
14
14
|
* Supports all C native types
|
|
15
15
|
* C structs (also nested), enums and global variables
|
|
16
|
-
* Callbacks from C to
|
|
16
|
+
* Callbacks from C to Ruby
|
|
17
17
|
* Automatic garbage collection of native memory
|
|
18
18
|
|
|
19
19
|
## Synopsis
|
|
@@ -30,20 +30,32 @@ end
|
|
|
30
30
|
MyLib.puts 'Hello, World using libc!'
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
For less minimalistic and more
|
|
33
|
+
For less minimalistic and more examples you may look at:
|
|
34
34
|
|
|
35
|
-
* the samples
|
|
36
|
-
* the examples on the [wiki](https://
|
|
37
|
-
* the projects using FFI listed on
|
|
35
|
+
* the `samples/` folder
|
|
36
|
+
* the examples on the [wiki](https://github.com/ffi/ffi/wiki)
|
|
37
|
+
* the projects using FFI listed on the wiki: https://github.com/ffi/ffi/wiki/projects-using-ffi
|
|
38
38
|
|
|
39
39
|
## Requirements
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* libffi development
|
|
41
|
+
When installing the gem on CRuby (MRI), you will need:
|
|
42
|
+
* A C compiler (e.g., Xcode on macOS, `gcc` or `clang` on everything else)
|
|
43
|
+
Optionally (speeds up installation):
|
|
44
|
+
* The `libffi` library and development headers - this is commonly in the `libffi-dev` or `libffi-devel` packages
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
The ffi gem comes with a builtin libffi version, which is used, when the system libffi library is not available or too old.
|
|
47
|
+
Use of the system libffi can be enforced by:
|
|
48
|
+
```
|
|
49
|
+
gem install ffi -- --enable-system-libffi # to install the gem manually
|
|
50
|
+
bundle config build.ffi --enable-system-libffi # for bundle install
|
|
51
|
+
```
|
|
52
|
+
or prevented by `--disable-system-libffi`.
|
|
53
|
+
|
|
54
|
+
On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) (Gentoo, Alpine, etc.), FFI may trigger `mprotect` errors. You may need to disable [mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29) for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is found.
|
|
55
|
+
|
|
56
|
+
On FreeBSD systems pkgconf must be installed for the gem to be able to compile using clang. Install either via packages `pkg install pkgconf` or from ports via `devel/pkgconf`.
|
|
57
|
+
|
|
58
|
+
On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and `require 'ffi'` works even without installing the gem (i.e., the gem is preinstalled on these implementations).
|
|
47
59
|
|
|
48
60
|
## Installation
|
|
49
61
|
|
|
@@ -61,8 +73,7 @@ or from the git repository on github:
|
|
|
61
73
|
## License
|
|
62
74
|
|
|
63
75
|
The ffi library is covered by the BSD license, also see the LICENSE file.
|
|
64
|
-
The specs are
|
|
65
|
-
as Rubyspec, see the LICENSE.SPECS file.
|
|
76
|
+
The specs are covered by the same license as [ruby/spec](https://github.com/ruby/spec), the MIT license.
|
|
66
77
|
|
|
67
78
|
## Credits
|
|
68
79
|
|
|
@@ -74,6 +85,7 @@ The following people have submitted code, bug reports, or otherwise contributed
|
|
|
74
85
|
* Andreas Niederl <rico32@gmx.net>
|
|
75
86
|
* Andrew Cholakian <andrew@andrewvc.com>
|
|
76
87
|
* Antonio Terceiro <terceiro@softwarelivre.org>
|
|
88
|
+
* Benoit Daloze <eregontp@gmail.com>
|
|
77
89
|
* Brian Candler <B.Candler@pobox.com>
|
|
78
90
|
* Brian D. Burns <burns180@gmail.com>
|
|
79
91
|
* Bryan Kearney <bkearney@redhat.com>
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
require 'rubygems/tasks'
|
|
2
2
|
require 'rbconfig'
|
|
3
3
|
require 'rake/clean'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true
|
|
7
|
-
if USE_RAKE_COMPILER
|
|
8
|
-
require 'rake/extensiontask'
|
|
9
|
-
end
|
|
4
|
+
require_relative "lib/ffi/version"
|
|
10
5
|
|
|
11
6
|
require 'date'
|
|
12
7
|
require 'fileutils'
|
|
@@ -14,71 +9,6 @@ require 'rbconfig'
|
|
|
14
9
|
require 'rspec/core/rake_task'
|
|
15
10
|
require 'rubygems/package_task'
|
|
16
11
|
|
|
17
|
-
LIBEXT = case RbConfig::CONFIG['host_os'].downcase
|
|
18
|
-
when /darwin/
|
|
19
|
-
"dylib"
|
|
20
|
-
when /mswin|mingw/
|
|
21
|
-
"dll"
|
|
22
|
-
else
|
|
23
|
-
RbConfig::CONFIG['DLEXT']
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
CPU = case RbConfig::CONFIG['host_cpu'].downcase
|
|
27
|
-
when /i[3456]86/
|
|
28
|
-
# Darwin always reports i686, even when running in 64bit mode
|
|
29
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
|
|
30
|
-
"x86_64"
|
|
31
|
-
else
|
|
32
|
-
"i386"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
when /amd64|x86_64/
|
|
36
|
-
"x86_64"
|
|
37
|
-
|
|
38
|
-
when /ppc64|powerpc64/
|
|
39
|
-
"powerpc64"
|
|
40
|
-
|
|
41
|
-
when /ppc|powerpc/
|
|
42
|
-
"powerpc"
|
|
43
|
-
|
|
44
|
-
when /^arm/
|
|
45
|
-
"arm"
|
|
46
|
-
|
|
47
|
-
else
|
|
48
|
-
RbConfig::CONFIG['host_cpu']
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
OS = case RbConfig::CONFIG['host_os'].downcase
|
|
52
|
-
when /linux/
|
|
53
|
-
"linux"
|
|
54
|
-
when /darwin/
|
|
55
|
-
"darwin"
|
|
56
|
-
when /freebsd/
|
|
57
|
-
"freebsd"
|
|
58
|
-
when /openbsd/
|
|
59
|
-
"openbsd"
|
|
60
|
-
when /sunos|solaris/
|
|
61
|
-
"solaris"
|
|
62
|
-
when /mswin|mingw/
|
|
63
|
-
"win32"
|
|
64
|
-
else
|
|
65
|
-
RbConfig::CONFIG['host_os'].downcase
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def which(name)
|
|
69
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
|
70
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
|
71
|
-
exts.each do |ext|
|
|
72
|
-
app = File.join(path, name+ext)
|
|
73
|
-
return app if File.executable? app
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
nil
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
GMAKE = which('gmake').nil? ? 'make' : 'gmake'
|
|
80
|
-
|
|
81
|
-
LIBTEST = "build/libtest.#{LIBEXT}"
|
|
82
12
|
BUILD_DIR = "build"
|
|
83
13
|
BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
|
|
84
14
|
|
|
@@ -86,17 +16,8 @@ def gem_spec
|
|
|
86
16
|
@gem_spec ||= Gem::Specification.load('ffi.gemspec')
|
|
87
17
|
end
|
|
88
18
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
RSpec::Core::RakeTask.new(:spec) do |config|
|
|
92
|
-
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
|
93
|
-
end
|
|
94
|
-
else
|
|
95
|
-
RSpec::Core::RakeTask.new(:spec => :compile) do |config|
|
|
96
|
-
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
TEST_DEPS.unshift :compile
|
|
19
|
+
RSpec::Core::RakeTask.new(:spec => :compile) do |config|
|
|
20
|
+
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
|
100
21
|
end
|
|
101
22
|
|
|
102
23
|
desc "Build all packages"
|
|
@@ -110,59 +31,43 @@ CLEAN.include 'build'
|
|
|
110
31
|
CLEAN.include 'conftest.dSYM'
|
|
111
32
|
CLEAN.include 'spec/ffi/fixtures/libtest.{dylib,so,dll}'
|
|
112
33
|
CLEAN.include 'spec/ffi/fixtures/*.o'
|
|
34
|
+
CLEAN.include 'spec/ffi/embed-test/ext/*.{o,def}'
|
|
35
|
+
CLEAN.include 'spec/ffi/embed-test/ext/Makefile'
|
|
113
36
|
CLEAN.include "pkg/ffi-*-{mingw32,java}"
|
|
114
37
|
CLEAN.include 'lib/1.*'
|
|
115
38
|
CLEAN.include 'lib/2.*'
|
|
116
|
-
CLEAN.include 'bin'
|
|
117
39
|
|
|
118
40
|
task :distclean => :clobber
|
|
119
41
|
|
|
120
|
-
desc "Build the native test lib"
|
|
121
|
-
file "build/libtest.#{LIBEXT}" => FileList['libtest/**/*.[ch]'] do
|
|
122
|
-
sh %{#{GMAKE} -f libtest/GNUmakefile CPU=#{CPU} OS=#{OS} }
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
desc "Build test helper lib"
|
|
127
|
-
task :libtest => "build/libtest.#{LIBEXT}"
|
|
128
|
-
|
|
129
42
|
desc "Test the extension"
|
|
130
43
|
task :test => [ :spec ]
|
|
131
44
|
|
|
132
45
|
|
|
133
46
|
namespace :bench do
|
|
134
47
|
ITER = ENV['ITER'] ? ENV['ITER'].to_i : 100000
|
|
135
|
-
|
|
136
|
-
bench_files = Dir["bench/bench_*.rb"].reject { |f| f == "bench_helper.rb" }
|
|
48
|
+
bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" }
|
|
137
49
|
bench_files.each do |bench|
|
|
138
|
-
task File.basename(bench, ".rb")[6..-1] =>
|
|
139
|
-
sh %{#{Gem.ruby} #{
|
|
50
|
+
task File.basename(bench, ".rb")[6..-1] => :compile do
|
|
51
|
+
sh %{#{Gem.ruby} #{bench} #{ITER}}
|
|
140
52
|
end
|
|
141
53
|
end
|
|
142
|
-
task :all =>
|
|
54
|
+
task :all => :compile do
|
|
143
55
|
bench_files.each do |bench|
|
|
144
|
-
sh %{#{Gem.ruby} #{
|
|
56
|
+
sh %{#{Gem.ruby} #{bench}}
|
|
145
57
|
end
|
|
146
58
|
end
|
|
147
59
|
end
|
|
148
60
|
|
|
149
|
-
task 'spec:run' =>
|
|
150
|
-
task 'spec:specdoc' =>
|
|
61
|
+
task 'spec:run' => :compile
|
|
62
|
+
task 'spec:specdoc' => :compile
|
|
151
63
|
|
|
152
64
|
task :default => :spec
|
|
153
65
|
|
|
154
66
|
namespace 'java' do
|
|
155
67
|
|
|
156
|
-
java_gem_spec =
|
|
157
|
-
s.
|
|
158
|
-
s.
|
|
159
|
-
s.author = gem_spec.author
|
|
160
|
-
s.email = gem_spec.email
|
|
161
|
-
s.homepage = gem_spec.homepage
|
|
162
|
-
s.summary = gem_spec.summary
|
|
163
|
-
s.description = gem_spec.description
|
|
164
|
-
s.files = %w(LICENSE COPYING README.md CHANGELOG.md Rakefile)
|
|
165
|
-
s.license = gem_spec.license
|
|
68
|
+
java_gem_spec = gem_spec.dup.tap do |s|
|
|
69
|
+
s.files.reject! { |f| File.fnmatch?("ext/*", f) }
|
|
70
|
+
s.extensions = []
|
|
166
71
|
s.platform = 'java'
|
|
167
72
|
end
|
|
168
73
|
|
|
@@ -175,8 +80,8 @@ end
|
|
|
175
80
|
|
|
176
81
|
task 'gem:java' => 'java:gem'
|
|
177
82
|
|
|
178
|
-
|
|
179
|
-
|
|
83
|
+
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
|
84
|
+
require 'rake/extensiontask'
|
|
180
85
|
Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
|
|
181
86
|
ext.name = 'ffi_c' # indicate the name of the extension.
|
|
182
87
|
# ext.lib_dir = BUILD_DIR # put binaries into this folder.
|
|
@@ -198,13 +103,17 @@ if USE_RAKE_COMPILER
|
|
|
198
103
|
sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
|
199
104
|
end
|
|
200
105
|
end
|
|
106
|
+
else
|
|
107
|
+
task :compile do
|
|
108
|
+
STDERR.puts "Nothing to compile on #{RUBY_ENGINE}"
|
|
109
|
+
end
|
|
201
110
|
end
|
|
202
111
|
|
|
203
112
|
desc "build a windows gem without all the ceremony"
|
|
204
113
|
task "gem:windows" do
|
|
205
114
|
require "rake_compiler_dock"
|
|
206
115
|
sh "bundle package"
|
|
207
|
-
RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle --local && rake cross native gem MAKE='nice make -j`nproc`'"
|
|
116
|
+
RakeCompilerDock.sh "sudo apt-get update && sudo apt-get install -y libltdl-dev && bundle --local && rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.2.2/}"
|
|
208
117
|
end
|
|
209
118
|
|
|
210
119
|
directory "ext/ffi_c/libffi"
|
|
@@ -212,6 +121,7 @@ file "ext/ffi_c/libffi/autogen.sh" => "ext/ffi_c/libffi" do
|
|
|
212
121
|
warn "Downloading libffi ..."
|
|
213
122
|
sh "git submodule update --init --recursive"
|
|
214
123
|
end
|
|
124
|
+
task :libffi => "ext/ffi_c/libffi/autogen.sh"
|
|
215
125
|
|
|
216
126
|
LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
|
|
217
127
|
|
|
@@ -231,16 +141,15 @@ end.each do |f|
|
|
|
231
141
|
end
|
|
232
142
|
end
|
|
233
143
|
|
|
234
|
-
|
|
235
|
-
require 'ffi/platform'
|
|
144
|
+
require_relative "lib/ffi/platform"
|
|
236
145
|
types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
|
|
237
146
|
logfile = File.join(File.dirname(__FILE__), 'types_log')
|
|
238
147
|
|
|
239
|
-
|
|
148
|
+
task types_conf do |task|
|
|
240
149
|
require 'fileutils'
|
|
241
|
-
|
|
150
|
+
require_relative "lib/ffi/tools/types_generator"
|
|
242
151
|
options = {}
|
|
243
|
-
FileUtils.mkdir_p(File.dirname(task.name),
|
|
152
|
+
FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
|
|
244
153
|
File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
|
|
245
154
|
f.puts FFI::TypesGenerator.generate(options)
|
|
246
155
|
end
|
|
@@ -249,8 +158,8 @@ file types_conf => File.join("lib", "ffi", "version.rb") do |task|
|
|
|
249
158
|
end
|
|
250
159
|
end
|
|
251
160
|
|
|
252
|
-
|
|
253
|
-
|
|
161
|
+
desc "Create or update type information for platform #{FFI::Platform::NAME}"
|
|
162
|
+
task :types_conf => types_conf
|
|
254
163
|
|
|
255
164
|
Gem::Tasks.new do |t|
|
|
256
165
|
t.scm.tag.format = '%s'
|