ffi 1.13.1-x86-mingw32 → 1.15.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd1e7e77d7ec065bfbd30a68a5e3269e80438772c79045350f0aa85e839fd5ef
4
- data.tar.gz: 73435ca8b7c0531a22de3435246ce8860dbaf64e8d4d82e06664cb088dcc3a23
3
+ metadata.gz: 14f34ae05b28ac23073be2490f64608bb427e697a63461403104debeb777e8c0
4
+ data.tar.gz: c432044f0799ad7066671899c1b54b6f4f4497c23c6f2abb2780de157357a327
5
5
  SHA512:
6
- metadata.gz: 6399008d474f358e45fcfe46f1dc8105265a632812c12001d635262552babf06a94c4ed0ca5fcc8fbbdc651c2b4e1579ff7664901831c98d64fc7f70173e5c50
7
- data.tar.gz: 34c6f5deadea47afe936dd291038230af20ff470bcd24b5bbb947be57fbfc0a25ed7759d41811b5985d2d583813bdecaebfedb2e987e9e8d67e8b738ddbd5296
6
+ metadata.gz: 79ad0fbaacd57d37a4e24a28a51ac6664c7b3489d1ace8ff5bbdc4563bc5d7e248a3b2ba99ea3fc6ba14e96f08f723a9bd5585b9d3328960f5934c0f7ba487f6
7
+ data.tar.gz: 94b7e3b289be5008825b62331fa566252afc00eb411f9a03a722965b15e86c6a4d1df21a842a4aab4a04537a269c8807499d345ece75b7b8b668906ee01da540
data/CHANGELOG.md CHANGED
@@ -1,3 +1,76 @@
1
+ 1.15.1 / 2021-05-22
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Append -pthread to linker options. #893
6
+ * Use arm or aarch64 to identify Apple ARM CPU arch. #899
7
+ * Allow overriding `gcc` with the `CC` env var in `const_generator.rb` and `struct_generator.rb`. #897
8
+
9
+
10
+ 1.15.0 / 2021-03-05
11
+ -------------------
12
+
13
+ Fixed:
14
+ * Fix MSVC build
15
+ * Fix async callbacks in conjunction with fork(). #884
16
+
17
+ Added:
18
+ * Allow to pass callbacks in varargs. #885
19
+ * Name the threads for FFI callback dispatcher and async thread calls for easier debugging. #883
20
+ The name can be retrieved by Thread.name and is shown by Thread.list.inspect etc.
21
+ Even gdb shows the thread name on supported operating systems.
22
+ * Add types.conf for powerpc64le-linux
23
+ * Add types.conf for riscv64-linux
24
+ * More release automation of ffi gems
25
+
26
+ Changed:
27
+ * Switch from rubygems-tasks to bundler/gem_helper
28
+
29
+ Removed:
30
+ * Remove unused VariadicInvoker#init
31
+
32
+
33
+ 1.14.2 / 2020-12-21
34
+ -------------------
35
+
36
+ Fixed:
37
+ * Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863
38
+
39
+
40
+ 1.14.1 / 2020-12-19
41
+ -------------------
42
+
43
+ Changed:
44
+ * Revert changes to FFI::Pointer#write_string made in ffi-1.14.0.
45
+ It breaks compatibilty in a way that can cause hard to find errors. #857
46
+
47
+
48
+ 1.14.0 / 2020-12-18
49
+ -------------------
50
+
51
+ Added:
52
+ * Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin)
53
+ * Add method AbstractMemory#size_limit? . #829
54
+ * Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin).
55
+
56
+ Changed:
57
+ * Do NULL pointer check only when array length > 0 . #305
58
+ * Raise an error on an unknown order argument. #830
59
+ * Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805
60
+ * Update bundled libffi to latest master.
61
+
62
+ Removed:
63
+ * Remove win32/stdint.h and stdbool.h because of copyright issue. #693
64
+
65
+ Fixed:
66
+ * Fix possible UTF-8 load error in loader script interpretation. #792
67
+ * Fix segfault on non-array argument to #write_array_of_*
68
+ * Fix memory leak in MethodHandle . #815
69
+ * Fix possible segfault in combination with fiddle or other libffi using gems . #835
70
+ * Fix possibility to use ffi ruby gem with JRuby-9.3 . #763
71
+ * Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820
72
+
73
+
1
74
  1.13.1 / 2020-06-09
2
75
  -------------------
3
76
 
data/Gemfile CHANGED
@@ -5,10 +5,7 @@ group :development do
5
5
  gem 'rake-compiler', '~> 1.0.3'
6
6
  gem 'rake-compiler-dock', '~> 1.0'
7
7
  gem 'rspec', '~> 3.0'
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'
8
+ gem 'bundler', '>= 1.16', '< 3'
12
9
  end
13
10
 
14
11
  group :doc do
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby-FFI https://github.com/ffi/ffi/wiki [![Build Status](https://travis-ci.org/ffi/ffi.svg?branch=master)](https://travis-ci.org/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
1
+ # Ruby-FFI https://github.com/ffi/ffi/wiki [![Build Status](https://travis-ci.com/ffi/ffi.svg?branch=master)](https://travis-ci.com/ffi/ffi) [![Build status Windows](https://ci.appveyor.com/api/projects/status/r8wxn1sd4s794gg1/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/ffi-aofqa/branch/master)
2
2
 
3
3
  ## Description
4
4
 
@@ -62,14 +62,26 @@ On JRuby and TruffleRuby, there are no requirements to install the FFI gem, and
62
62
  From rubygems:
63
63
 
64
64
  [sudo] gem install ffi
65
+
66
+ From a Gemfile using git or GitHub
67
+
68
+ gem 'ffi', github: 'ffi/ffi', submodules: true
65
69
 
66
70
  or from the git repository on github:
67
71
 
68
72
  git clone git://github.com/ffi/ffi.git
69
- git submodule update --init --recursive
70
73
  cd ffi
74
+ git submodule update --init --recursive
75
+ bundle install
71
76
  rake install
72
77
 
78
+ ### Install options:
79
+
80
+ * `--enable-system-libffi` : Force usage of system libffi
81
+ * `--disable-system-libffi` : Force usage of builtin libffi
82
+ * `--enable-libffi-alloc` : Force closure allocation by libffi
83
+ * `--disable-libffi-alloc` : Force closure allocation by builtin method
84
+
73
85
  ## License
74
86
 
75
87
  The ffi library is covered by the BSD license, also see the LICENSE file.
data/Rakefile CHANGED
@@ -1,20 +1,17 @@
1
- require 'rubygems/tasks'
2
1
  require 'rbconfig'
3
- require 'rake/clean'
4
- require_relative "lib/ffi/version"
5
-
6
2
  require 'date'
7
3
  require 'fileutils'
8
4
  require 'rbconfig'
9
5
  require 'rspec/core/rake_task'
10
6
  require 'rubygems/package_task'
7
+ require 'rake/extensiontask'
8
+ require_relative "lib/ffi/version"
9
+ require_relative "rakelib/ffi_gem_helper"
11
10
 
12
11
  BUILD_DIR = "build"
13
12
  BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
14
13
 
15
- def gem_spec
16
- @gem_spec ||= Gem::Specification.load('ffi.gemspec')
17
- end
14
+ gem_spec = Bundler.load_gemspec('ffi.gemspec')
18
15
 
19
16
  RSpec::Core::RakeTask.new(:spec => :compile) do |config|
20
17
  config.rspec_opts = YAML.load_file 'spec/spec.opts'
@@ -37,6 +34,13 @@ CLEAN.include "pkg/ffi-*-{mingw32,java}"
37
34
  CLEAN.include 'lib/1.*'
38
35
  CLEAN.include 'lib/2.*'
39
36
 
37
+ # clean all shipped files, that are not in git
38
+ CLEAN.include(
39
+ gem_spec.files -
40
+ `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0").map { |f| File.join("ext/ffi_c/libffi", f) } -
41
+ `git ls-files -z`.split("\x0")
42
+ )
43
+
40
44
  task :distclean => :clobber
41
45
 
42
46
  desc "Test the extension"
@@ -80,6 +84,10 @@ end
80
84
 
81
85
  task 'gem:java' => 'java:gem'
82
86
 
87
+ FfiGemHelper.install_tasks
88
+ # Register windows gems to be pushed to rubygems.org
89
+ Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw32]
90
+
83
91
  if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
84
92
  require 'rake/extensiontask'
85
93
  Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
@@ -87,21 +95,11 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
87
95
  # ext.lib_dir = BUILD_DIR # put binaries into this folder.
88
96
  ext.tmp_dir = BUILD_DIR # temporary folder used during compilation.
89
97
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
90
- ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
98
+ ext.cross_platform = Bundler::GemHelper.instance.cross_platforms
91
99
  ext.cross_compiling do |spec|
92
100
  spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
93
101
  end
94
- end
95
102
 
96
- # To reduce the gem file size strip mingw32 dlls before packaging
97
- ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
98
- task "build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
99
- sh "i686-w64-mingw32-strip -S build/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
100
- end
101
-
102
- task "build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so" do |t|
103
- sh "x86_64-w64-mingw32-strip -S build/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
104
- end
105
103
  end
106
104
  else
107
105
  task :compile do
@@ -109,6 +107,7 @@ else
109
107
  end
110
108
  end
111
109
 
110
+
112
111
  desc "build a windows gem without all the ceremony"
113
112
  task "gem:windows" do
114
113
  require "rake_compiler_dock"
@@ -125,7 +124,7 @@ task :libffi => "ext/ffi_c/libffi/autogen.sh"
125
124
 
126
125
  LIBFFI_GIT_FILES = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
127
126
 
128
- # Generate files in gemspec but not in libffi's git repo by running autogen.sh
127
+ # Generate files which are in the gemspec but not in libffi's git repo by running autogen.sh
129
128
  gem_spec.files.select do |f|
130
129
  f =~ /ext\/ffi_c\/libffi\/(.*)/ && !LIBFFI_GIT_FILES.include?($1)
131
130
  end.each do |f|
@@ -141,6 +140,11 @@ end.each do |f|
141
140
  end
142
141
  end
143
142
 
143
+ # Make sure we have all gemspec files before packaging
144
+ task :build => gem_spec.files
145
+ task :gem => :build
146
+
147
+
144
148
  require_relative "lib/ffi/platform"
145
149
  types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
146
150
  logfile = File.join(File.dirname(__FILE__), 'types_log')
@@ -161,10 +165,6 @@ end
161
165
  desc "Create or update type information for platform #{FFI::Platform::NAME}"
162
166
  task :types_conf => types_conf
163
167
 
164
- Gem::Tasks.new do |t|
165
- t.scm.tag.format = '%s'
166
- end
167
-
168
168
  begin
169
169
  require 'yard'
170
170
 
data/ffi.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.metadata['mailing_list_uri'] = 'http://groups.google.com/group/ruby-ffi'
18
18
  end
19
19
  s.files = `git ls-files -z`.split("\x0").reject do |f|
20
- f =~ /^(bench|gen|libtest|nbproject|spec)/
20
+ f =~ /^(\.|bench|gen|libtest|nbproject|spec)/
21
21
  end
22
22
 
23
23
  # Add libffi git files
data/lib/2.3/ffi_c.so ADDED
Binary file
data/lib/2.4/ffi_c.so ADDED
Binary file
data/lib/2.5/ffi_c.so ADDED
Binary file
data/lib/2.6/ffi_c.so ADDED
Binary file
data/lib/2.7/ffi_c.so ADDED
Binary file
data/lib/3.0/ffi_c.so ADDED
Binary file
data/lib/ffi.rb CHANGED
@@ -1,5 +1,4 @@
1
- if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
2
- Object.send(:remove_const, :FFI) if defined?(::FFI)
1
+ if RUBY_ENGINE == 'ruby'
3
2
  begin
4
3
  require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c'
5
4
  rescue Exception
@@ -8,11 +7,11 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
8
7
 
9
8
  require 'ffi/ffi'
10
9
 
11
- elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("9.3.pre")
10
+ elsif RUBY_ENGINE == 'jruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [9, 3]) >= 0
12
11
  JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService")
13
12
  require 'ffi/ffi'
14
13
 
15
- elsif RUBY_ENGINE == 'truffleruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("20.1.0-dev-a")
14
+ elsif RUBY_ENGINE == 'truffleruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [20, 1, 0]) >= 0
16
15
  require 'truffleruby/ffi_backend'
17
16
  require 'ffi/ffi'
18
17
 
@@ -0,0 +1,44 @@
1
+ #
2
+ # Copyright (C) 2020 Lars Kanis
3
+ #
4
+ # This file is part of ruby-ffi.
5
+ #
6
+ # All rights reserved.
7
+ #
8
+ # Redistribution and use in source and binary forms, with or without
9
+ # modification, are permitted provided that the following conditions are met:
10
+ #
11
+ # * Redistributions of source code must retain the above copyright notice, this
12
+ # list of conditions and the following disclaimer.
13
+ # * Redistributions in binary form must reproduce the above copyright notice
14
+ # this list of conditions and the following disclaimer in the documentation
15
+ # and/or other materials provided with the distribution.
16
+ # * Neither the name of the Ruby FFI project nor the names of its contributors
17
+ # may be used to endorse or promote products derived from this software
18
+ # without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
30
+
31
+
32
+ module FFI
33
+ class AbstractMemory
34
+ LONG_MAX = FFI::Pointer.new(1).size
35
+ private_constant :LONG_MAX
36
+
37
+ # Return +true+ if +self+ has a size limit.
38
+ #
39
+ # @return [Boolean]
40
+ def size_limit?
41
+ size != LONG_MAX
42
+ end
43
+ end
44
+ end
@@ -117,7 +117,7 @@ module FFI
117
117
  end
118
118
 
119
119
  # @abstract Base class for {AutoPointer}'s releasers.
120
- #
120
+ #
121
121
  # All subclasses of Releaser should define a +#release(ptr)+ method.
122
122
  # A releaser is an object in charge of release an {AutoPointer}.
123
123
  class Releaser
data/lib/ffi/ffi.rb CHANGED
@@ -33,6 +33,7 @@ require 'ffi/data_converter'
33
33
  require 'ffi/types'
34
34
  require 'ffi/library'
35
35
  require 'ffi/errno'
36
+ require 'ffi/abstract_memory'
36
37
  require 'ffi/pointer'
37
38
  require 'ffi/memorypointer'
38
39
  require 'ffi/struct'
data/lib/ffi/io.rb CHANGED
@@ -29,7 +29,7 @@
29
29
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
30
30
 
31
31
  module FFI
32
-
32
+
33
33
  # This module implements a couple of class methods to play with IO.
34
34
  module IO
35
35
  # @param [Integer] fd file decriptor
@@ -42,12 +42,12 @@ module FFI
42
42
 
43
43
  # @param [#read] io io to read from
44
44
  # @param [AbstractMemory] buf destination for data read from +io+
45
- # @param [nil, Numeric] len maximul number of bytes to read from +io+. If +nil+,
45
+ # @param [nil, Numeric] len maximul number of bytes to read from +io+. If +nil+,
46
46
  # read until end of file.
47
47
  # @return [Numeric] length really read, in bytes
48
48
  #
49
49
  # A version of IO#read that reads data from an IO and put then into a native buffer.
50
- #
50
+ #
51
51
  # This will be optimized at some future time to eliminate the double copy.
52
52
  #
53
53
  def self.native_read(io, buf, len)
data/lib/ffi/library.rb CHANGED
@@ -115,7 +115,7 @@ module FFI
115
115
  rescue Exception => ex
116
116
  ldscript = false
117
117
  if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/
118
- if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/
118
+ if File.binread($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/
119
119
  libname = $1
120
120
  ldscript = true
121
121
  end
@@ -44,7 +44,7 @@ module FFI
44
44
  # attach_function :new_dlist, [], :pointer
45
45
  # attach_function :destroy_dlist, [:pointer], :void
46
46
  # end
47
- #
47
+ #
48
48
  # class DoublyLinkedList < FFI::ManagedStruct
49
49
  # @@@
50
50
  # struct do |s|
@@ -71,7 +71,7 @@ module FFI
71
71
 
72
72
  # @overload initialize(pointer)
73
73
  # @param [Pointer] pointer
74
- # Create a new ManagedStruct which will invoke the class method #release on
74
+ # Create a new ManagedStruct which will invoke the class method #release on
75
75
  # @overload initialize
76
76
  # A new instance of FFI::ManagedStruct.
77
77
  def initialize(pointer=nil)
data/lib/ffi/platform.rb CHANGED
@@ -63,7 +63,7 @@ module FFI
63
63
  ARCH = case CPU.downcase
64
64
  when /amd64|x86_64|x64/
65
65
  "x86_64"
66
- when /i?86|x86|i86pc/
66
+ when /i\d86|x86|i86pc/
67
67
  "i386"
68
68
  when /ppc64|powerpc64/
69
69
  "powerpc64"
@@ -71,13 +71,16 @@ module FFI
71
71
  "powerpc"
72
72
  when /sparcv9|sparc64/
73
73
  "sparcv9"
74
- else
75
- case RbConfig::CONFIG['host_cpu']
76
- when /^arm/
77
- "arm"
74
+ when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
75
+ "aarch64"
76
+ when /^arm/
77
+ if OS == "darwin" # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
78
+ "aarch64"
78
79
  else
79
- RbConfig::CONFIG['host_cpu']
80
+ "arm"
80
81
  end
82
+ else
83
+ RbConfig::CONFIG['host_cpu']
81
84
  end
82
85
 
83
86
  private
@@ -145,6 +148,12 @@ module FFI
145
148
  "#{LIBPREFIX}c.#{LIBSUFFIX}"
146
149
  end
147
150
 
151
+ LITTLE_ENDIAN = 1234 unless defined?(LITTLE_ENDIAN)
152
+ BIG_ENDIAN = 4321 unless defined?(BIG_ENDIAN)
153
+ unless defined?(BYTE_ORDER)
154
+ BYTE_ORDER = [0x12345678].pack("I") == [0x12345678].pack("N") ? BIG_ENDIAN : LITTLE_ENDIAN
155
+ end
156
+
148
157
  # Test if current OS is a *BSD (include MAC)
149
158
  # @return [Boolean]
150
159
  def self.bsd?