ffi 1.11.2 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +3 -0
- data/.github/workflows/ci.yml +64 -0
- data/.travis.yml +21 -5
- data/CHANGELOG.md +64 -0
- data/Gemfile +6 -4
- data/README.md +10 -1
- data/Rakefile +24 -43
- data/ext/ffi_c/AbstractMemory.c +5 -9
- data/ext/ffi_c/Buffer.c +2 -2
- data/ext/ffi_c/Call.c +1 -11
- data/ext/ffi_c/ClosurePool.c +11 -14
- data/ext/ffi_c/DynamicLibrary.c +1 -1
- data/ext/ffi_c/Function.c +9 -24
- data/ext/ffi_c/FunctionInfo.c +1 -2
- data/ext/ffi_c/LongDouble.c +5 -3
- 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 -0
- 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 +0 -3
- data/ext/ffi_c/Thread.h +0 -3
- data/ext/ffi_c/Types.c +1 -1
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +13 -16
- data/ext/ffi_c/libffi/.travis.yml +32 -12
- 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 +2 -12
- data/ext/ffi_c/libffi/.travis/build.sh +62 -30
- data/ext/ffi_c/libffi/.travis/install.sh +65 -37
- 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/Makefile.am +6 -4
- data/ext/ffi_c/libffi/README.md +18 -6
- data/ext/ffi_c/libffi/configure.ac +26 -10
- data/ext/ffi_c/libffi/configure.host +5 -2
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -3
- data/ext/ffi_c/libffi/include/ffi.h.in +15 -7
- 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/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/src/aarch64/ffi.c +6 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
- data/ext/ffi_c/libffi/src/closures.c +20 -6
- data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
- 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 +4 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +154 -8
- 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 +67 -3
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.am +78 -75
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +1 -18
- 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.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/ffi.gemspec +3 -3
- data/lib/ffi.rb +10 -2
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/library.rb +5 -1
- data/lib/ffi/platform.rb +2 -2
- data/lib/ffi/platform/arm-linux/types.conf +32 -4
- data/lib/ffi/platform/i386-windows/types.conf +26 -79
- data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
- data/lib/ffi/pointer.rb +19 -12
- data/lib/ffi/struct.rb +10 -5
- data/lib/ffi/tools/types_generator.rb +2 -0
- 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 +116 -110
- 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: e96bb396dbe6fdc7c8a68b4328bb9142e50a9c934a94aa79837fb26bfb195a97
|
4
|
+
data.tar.gz: efb9edb9a7e79911a1860d7ceb60b842840c2f469f248b7795c38cede57fddbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f23d12fdea63b629ca8a09fd39b6b60aae31a5b25b54e15c8519a9b1e71bf8ca93d01c34b4a424d68fae8d9a6b22e171c45eb2e357ccdd6df9eaf7e7dd60cd
|
7
|
+
data.tar.gz: 0c47701aec04d869c1c62e71b88dbf5b33fbef3e1cf49819301e94e124817783db47e8e4427f3782b44f0516009e0e2def336423d594283f1d9b870bc4941765
|
data/.appveyor.yml
CHANGED
@@ -10,11 +10,14 @@ 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
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"
|
@@ -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/.travis.yml
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
dist: trusty
|
2
2
|
group: beta
|
3
3
|
language: ruby
|
4
|
+
git:
|
5
|
+
submodules: false
|
4
6
|
|
5
7
|
script:
|
6
|
-
- bundle exec rake
|
8
|
+
- bundle exec rake libffi
|
9
|
+
- bundle exec rake compile
|
7
10
|
- bundle exec rake test
|
8
|
-
-
|
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
|
9
16
|
os:
|
10
17
|
- linux
|
11
18
|
- osx
|
12
19
|
rvm:
|
13
20
|
- 2.3.8
|
14
|
-
- 2.4.
|
15
|
-
- 2.5.
|
16
|
-
- 2.6.
|
21
|
+
- 2.4.6
|
22
|
+
- 2.5.5
|
23
|
+
- 2.6.5
|
24
|
+
- 2.7.0
|
17
25
|
- ruby-head
|
26
|
+
- truffleruby-head
|
18
27
|
|
19
28
|
env:
|
20
29
|
- CC=gcc
|
@@ -23,6 +32,10 @@ matrix:
|
|
23
32
|
allow_failures:
|
24
33
|
- os: osx
|
25
34
|
rvm: ruby-head
|
35
|
+
- os: osx
|
36
|
+
rvm: 2.3.8
|
37
|
+
- os: linux
|
38
|
+
rvm: ruby-head
|
26
39
|
include:
|
27
40
|
- name: powerpc
|
28
41
|
language: generic
|
@@ -38,5 +51,8 @@ matrix:
|
|
38
51
|
docker build --rm -t ffi-armhf -f spec/env/Dockerfile.armhf .
|
39
52
|
script: |
|
40
53
|
docker run --rm -t -v `pwd`:/ffi ffi-armhf
|
54
|
+
exclude:
|
55
|
+
- os: osx
|
56
|
+
rvm: truffleruby-head
|
41
57
|
after_failure:
|
42
58
|
- "find build -name mkmf.log | xargs cat"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,67 @@
|
|
1
|
+
1.13.0 / 2020-06-01
|
2
|
+
-------------------
|
3
|
+
|
4
|
+
Added:
|
5
|
+
* Add TruffleRuby support. Almost all specs are running on TruffleRuby and succeed. #768
|
6
|
+
* 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
|
7
|
+
* Add FFI::Platform::LONG_DOUBLE_SIZE
|
8
|
+
* Add bounds checks for writing to an inline char[] . #756
|
9
|
+
* Add long double as callback return value. #771
|
10
|
+
* 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
|
11
|
+
* Add new type definitions for powerpc-openbsd and sparcv9-openbsd. #775, #778
|
12
|
+
|
13
|
+
Changed:
|
14
|
+
* Raise required ruby version to >= 2.3.
|
15
|
+
* Lots of cleanups and improvements in library, specs and benchmarks.
|
16
|
+
* Fix a lot of compiler warnings at the C-extension
|
17
|
+
* Fix several install issues on MacOS:
|
18
|
+
* Look for libffi in SDK paths, since recent versions of macOS removed it from `/usr/include` . #757
|
19
|
+
* Fix error `ld: library not found for -lgcc_s.10.4`
|
20
|
+
* Don't built for i386 architecture as it is deprecated
|
21
|
+
* Several fixes for MSVC build on Windows. #779
|
22
|
+
* Use `ucrtbase.dll` as default C library on Windows instead of old `msvcrt.dll`. #779
|
23
|
+
* Update builtin libffi to fix a Powerpc issue with parameters of type long
|
24
|
+
* Allow unmodified sourcing of (the ruby code of) this gem in JRuby and TruffleRuby as a default gem. #747
|
25
|
+
* Improve check to detect if a module has a #find_type method suitable for FFI. This fixes compatibility with stdlib `mkmf` . #776
|
26
|
+
|
27
|
+
Removed:
|
28
|
+
* Reject callback with `:string` return type at definition, because it didn't work so far and is not save to use. #751, #782
|
29
|
+
|
30
|
+
|
31
|
+
1.12.2 / 2020-02-01
|
32
|
+
-------------------
|
33
|
+
|
34
|
+
* Fix possible segfault at FFI::Struct#[] and []= after GC.compact . #742
|
35
|
+
|
36
|
+
|
37
|
+
1.12.1 / 2020-01-14
|
38
|
+
-------------------
|
39
|
+
|
40
|
+
Added:
|
41
|
+
* Add binary gem support for ruby-2.7 on Windows
|
42
|
+
|
43
|
+
|
44
|
+
1.12.0 / 2020-01-14
|
45
|
+
-------------------
|
46
|
+
|
47
|
+
Added:
|
48
|
+
* FFI::VERSION is defined as part of `require 'ffi'` now.
|
49
|
+
It is no longer necessary to `require 'ffi/version'` .
|
50
|
+
|
51
|
+
Changed:
|
52
|
+
* Update libffi to latest master.
|
53
|
+
|
54
|
+
Deprecated:
|
55
|
+
* Overwriting struct layouts is now warned and will be disallowed in ffi-2.0. #734, #735
|
56
|
+
|
57
|
+
|
58
|
+
1.11.3 / 2019-11-25
|
59
|
+
-------------------
|
60
|
+
|
61
|
+
Removed:
|
62
|
+
* Remove support for tainted objects which cause deprecation warnings in ruby-2.7. #730
|
63
|
+
|
64
|
+
|
1
65
|
1.11.2 / 2019-11-11
|
2
66
|
-------------------
|
3
67
|
|
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
@@ -38,10 +38,19 @@ For less minimalistic and more examples you may look at:
|
|
38
38
|
|
39
39
|
## Requirements
|
40
40
|
|
41
|
-
When installing the gem on CRuby (MRI)
|
41
|
+
When installing the gem on CRuby (MRI), you will need:
|
42
42
|
* A C compiler (e.g., Xcode on macOS, `gcc` or `clang` on everything else)
|
43
|
+
Optionally (speeds up installation):
|
43
44
|
* The `libffi` library and development headers - this is commonly in the `libffi-dev` or `libffi-devel` packages
|
44
45
|
|
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
|
+
|
45
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.
|
46
55
|
|
47
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`.
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems/tasks'
|
2
2
|
require 'rbconfig'
|
3
3
|
require 'rake/clean'
|
4
|
-
|
4
|
+
require_relative "lib/ffi/version"
|
5
5
|
|
6
6
|
require 'date'
|
7
7
|
require 'fileutils'
|
@@ -9,10 +9,6 @@ require 'rbconfig'
|
|
9
9
|
require 'rspec/core/rake_task'
|
10
10
|
require 'rubygems/package_task'
|
11
11
|
|
12
|
-
def java?
|
13
|
-
/java/ === RUBY_PLATFORM
|
14
|
-
end
|
15
|
-
|
16
12
|
BUILD_DIR = "build"
|
17
13
|
BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
|
18
14
|
|
@@ -20,17 +16,8 @@ def gem_spec
|
|
20
16
|
@gem_spec ||= Gem::Specification.load('ffi.gemspec')
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
RSpec::Core::RakeTask.new(:spec) do |config|
|
26
|
-
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
27
|
-
end
|
28
|
-
else
|
29
|
-
RSpec::Core::RakeTask.new(:spec => :compile) do |config|
|
30
|
-
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
31
|
-
end
|
32
|
-
|
33
|
-
TEST_DEPS.unshift :compile
|
19
|
+
RSpec::Core::RakeTask.new(:spec => :compile) do |config|
|
20
|
+
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
34
21
|
end
|
35
22
|
|
36
23
|
desc "Build all packages"
|
@@ -58,37 +45,29 @@ task :test => [ :spec ]
|
|
58
45
|
|
59
46
|
namespace :bench do
|
60
47
|
ITER = ENV['ITER'] ? ENV['ITER'].to_i : 100000
|
61
|
-
|
62
|
-
bench_files = Dir["bench/bench_*.rb"].reject { |f| f == "bench/bench_helper.rb" }
|
48
|
+
bench_files = Dir["bench/bench_*.rb"].sort.reject { |f| f == "bench/bench_helper.rb" }
|
63
49
|
bench_files.each do |bench|
|
64
|
-
task File.basename(bench, ".rb")[6..-1] =>
|
65
|
-
sh %{#{Gem.ruby} #{
|
50
|
+
task File.basename(bench, ".rb")[6..-1] => :compile do
|
51
|
+
sh %{#{Gem.ruby} #{bench} #{ITER}}
|
66
52
|
end
|
67
53
|
end
|
68
|
-
task :all =>
|
54
|
+
task :all => :compile do
|
69
55
|
bench_files.each do |bench|
|
70
|
-
sh %{#{Gem.ruby} #{
|
56
|
+
sh %{#{Gem.ruby} #{bench}}
|
71
57
|
end
|
72
58
|
end
|
73
59
|
end
|
74
60
|
|
75
|
-
task 'spec:run' =>
|
76
|
-
task 'spec:specdoc' =>
|
61
|
+
task 'spec:run' => :compile
|
62
|
+
task 'spec:specdoc' => :compile
|
77
63
|
|
78
64
|
task :default => :spec
|
79
65
|
|
80
66
|
namespace 'java' do
|
81
67
|
|
82
|
-
java_gem_spec =
|
83
|
-
s.
|
84
|
-
s.
|
85
|
-
s.author = gem_spec.author
|
86
|
-
s.email = gem_spec.email
|
87
|
-
s.homepage = gem_spec.homepage
|
88
|
-
s.summary = gem_spec.summary
|
89
|
-
s.description = gem_spec.description
|
90
|
-
s.files = %w(LICENSE COPYING README.md CHANGELOG.md Rakefile)
|
91
|
-
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 = []
|
92
71
|
s.platform = 'java'
|
93
72
|
end
|
94
73
|
|
@@ -101,7 +80,7 @@ end
|
|
101
80
|
|
102
81
|
task 'gem:java' => 'java:gem'
|
103
82
|
|
104
|
-
|
83
|
+
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
105
84
|
require 'rake/extensiontask'
|
106
85
|
Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
|
107
86
|
ext.name = 'ffi_c' # indicate the name of the extension.
|
@@ -124,13 +103,17 @@ unless java?
|
|
124
103
|
sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
125
104
|
end
|
126
105
|
end
|
106
|
+
else
|
107
|
+
task :compile do
|
108
|
+
STDERR.puts "Nothing to compile on #{RUBY_ENGINE}"
|
109
|
+
end
|
127
110
|
end
|
128
111
|
|
129
112
|
desc "build a windows gem without all the ceremony"
|
130
113
|
task "gem:windows" do
|
131
114
|
require "rake_compiler_dock"
|
132
115
|
sh "bundle package"
|
133
|
-
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/}"
|
134
117
|
end
|
135
118
|
|
136
119
|
directory "ext/ffi_c/libffi"
|
@@ -158,16 +141,15 @@ end.each do |f|
|
|
158
141
|
end
|
159
142
|
end
|
160
143
|
|
161
|
-
|
162
|
-
require 'ffi/platform'
|
144
|
+
require_relative "lib/ffi/platform"
|
163
145
|
types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
|
164
146
|
logfile = File.join(File.dirname(__FILE__), 'types_log')
|
165
147
|
|
166
|
-
|
148
|
+
task types_conf do |task|
|
167
149
|
require 'fileutils'
|
168
|
-
|
150
|
+
require_relative "lib/ffi/tools/types_generator"
|
169
151
|
options = {}
|
170
|
-
FileUtils.mkdir_p(File.dirname(task.name),
|
152
|
+
FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
|
171
153
|
File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
|
172
154
|
f.puts FFI::TypesGenerator.generate(options)
|
173
155
|
end
|
@@ -177,8 +159,7 @@ file types_conf => File.join("lib", "ffi", "version.rb") do |task|
|
|
177
159
|
end
|
178
160
|
|
179
161
|
desc "Create or update type information for platform #{FFI::Platform::NAME}"
|
180
|
-
task :types_conf => types_conf
|
181
|
-
end
|
162
|
+
task :types_conf => types_conf
|
182
163
|
|
183
164
|
Gem::Tasks.new do |t|
|
184
165
|
t.scm.tag.format = '%s'
|
data/ext/ffi_c/AbstractMemory.c
CHANGED
@@ -417,7 +417,7 @@ memory_get_string(int argc, VALUE* argv, VALUE self)
|
|
417
417
|
checkBounds(ptr, off, len);
|
418
418
|
|
419
419
|
end = memchr(ptr->address + off, 0, len);
|
420
|
-
return
|
420
|
+
return rb_str_new((char *) ptr->address + off,
|
421
421
|
(end != NULL ? end - ptr->address - off : len));
|
422
422
|
}
|
423
423
|
|
@@ -453,7 +453,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
453
453
|
|
454
454
|
for (i = 0; i < count; ++i) {
|
455
455
|
const char* strptr = *((const char**) (ptr->address + off) + i);
|
456
|
-
rb_ary_push(retVal, (strptr == NULL ? Qnil :
|
456
|
+
rb_ary_push(retVal, (strptr == NULL ? Qnil : rb_str_new2(strptr)));
|
457
457
|
}
|
458
458
|
|
459
459
|
} else {
|
@@ -463,7 +463,7 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
463
463
|
if (strptr == NULL) {
|
464
464
|
break;
|
465
465
|
}
|
466
|
-
rb_ary_push(retVal,
|
466
|
+
rb_ary_push(retVal, rb_str_new2(strptr));
|
467
467
|
}
|
468
468
|
}
|
469
469
|
|
@@ -542,7 +542,7 @@ memory_get_bytes(VALUE self, VALUE offset, VALUE length)
|
|
542
542
|
checkRead(ptr);
|
543
543
|
checkBounds(ptr, off, len);
|
544
544
|
|
545
|
-
return
|
545
|
+
return rb_str_new((char *) ptr->address + off, len);
|
546
546
|
}
|
547
547
|
|
548
548
|
/*
|
@@ -583,10 +583,6 @@ memory_put_bytes(int argc, VALUE* argv, VALUE self)
|
|
583
583
|
checkWrite(ptr);
|
584
584
|
checkBounds(ptr, off, len);
|
585
585
|
|
586
|
-
if (rb_safe_level() >= 1 && OBJ_TAINTED(str)) {
|
587
|
-
rb_raise(rb_eSecurityError, "Writing unsafe string to memory");
|
588
|
-
return Qnil;
|
589
|
-
}
|
590
586
|
memcpy(ptr->address + off, RSTRING_PTR(str) + idx, len);
|
591
587
|
|
592
588
|
return self;
|
@@ -718,7 +714,7 @@ memory_op_get_strptr(AbstractMemory* ptr, long offset)
|
|
718
714
|
memcpy(&tmp, ptr->address + offset, sizeof(tmp));
|
719
715
|
}
|
720
716
|
|
721
|
-
return tmp != NULL ?
|
717
|
+
return tmp != NULL ? rb_str_new2(tmp) : Qnil;
|
722
718
|
}
|
723
719
|
|
724
720
|
static void
|