ffi 1.13.0-x86-mingw32 → 1.15.0-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: 528831f939fb8aa38dff1df5a8e94848a8bebca16e42b3dacdb230167c2c773e
4
- data.tar.gz: 6eabe31b9debbbc85c1859042a67938b163374000a37295887f49ead8950b44f
3
+ metadata.gz: bca90b754dabdecb1981a46109e6f95a1951e57b9f337642aefcf080e16a9188
4
+ data.tar.gz: 5784310abafaad3ce60ba0ed8a1c25f6ec0f6ab775ef26fe0f9d5b516a971939
5
5
  SHA512:
6
- metadata.gz: fd8082e5b17e7549656b04770de7190aa5bc11766a2d14f8d2c665d1aa3a1c3e9dc12b190fe0ca4da62f5e6bd9ec5bf23258b6ce43dce9101a494ce4f7e21f5f
7
- data.tar.gz: 8874f723bebf884cdb30d4e43bf1a952ec5ca9b73ce3360e13f522be5a6f4f23e4fa3617fdf818cc06b81e7ade79d234aa5b3849581a158e0be3deef751db55d
6
+ metadata.gz: 1548a73bb78eb37e8bd1843833836e9d1fe2b0c2786259220586169053b2cecf767503038afebf24833263fe8b163c6232cfd1a132a8975a9a620002dc4e69ed
7
+ data.tar.gz: aa22278bdd9289372df04ef62d0f1c8cede44e9807bd4cd7e58985e9e3c61251f4bbee8cdb50dfad0f5ce4864ae9c29f9004b0c8fdab668b9fa8e5b82bc99170
data/CHANGELOG.md CHANGED
@@ -1,3 +1,78 @@
1
+ 1.15.0 / 2021-03-05
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Fix MSVC build
6
+ * Fix async callbacks in conjunction with fork(). #884
7
+
8
+ Added:
9
+ * Allow to pass callbacks in varargs. #885
10
+ * Name the threads for FFI callback dispatcher and async thread calls for easier debugging. #883
11
+ The name can be retrieved by Thread.name and is shown by Thread.list.inspect etc.
12
+ Even gdb shows the thread name on supported operating systems.
13
+ * Add types.conf for powerpc64le-linux
14
+ * Add types.conf for riscv64-linux
15
+ * More release automation of ffi gems
16
+
17
+ Changed:
18
+ * Switch from rubygems-tasks to bundler/gem_helper
19
+
20
+ Removed:
21
+ * Remove unused VariadicInvoker#init
22
+
23
+
24
+ 1.14.2 / 2020-12-21
25
+ -------------------
26
+
27
+ Fixed:
28
+ * Fix builtin libffi on newer Ubuntu caused by an outdated Makefile.in . #863
29
+
30
+
31
+ 1.14.1 / 2020-12-19
32
+ -------------------
33
+
34
+ Changed:
35
+ * Revert changes to FFI::Pointer#write_string made in ffi-1.14.0.
36
+ It breaks compatibilty in a way that can cause hard to find errors. #857
37
+
38
+
39
+ 1.14.0 / 2020-12-18
40
+ -------------------
41
+
42
+ Added:
43
+ * Add types.conf for x86_64-msys, x86_64-haiku, aarch64-openbsd and aarch64-darwin (alias arm64-darwin)
44
+ * Add method AbstractMemory#size_limit? . #829
45
+ * Add new extconf option --enable-libffi-alloc which is enabled per default on Apple M1 (arm64-darwin).
46
+
47
+ Changed:
48
+ * Do NULL pointer check only when array length > 0 . #305
49
+ * Raise an error on an unknown order argument. #830
50
+ * Change FFI::Pointer#write_string to terminate with a NUL byte like other string methods. #805
51
+ * Update bundled libffi to latest master.
52
+
53
+ Removed:
54
+ * Remove win32/stdint.h and stdbool.h because of copyright issue. #693
55
+
56
+ Fixed:
57
+ * Fix possible UTF-8 load error in loader script interpretation. #792
58
+ * Fix segfault on non-array argument to #write_array_of_*
59
+ * Fix memory leak in MethodHandle . #815
60
+ * Fix possible segfault in combination with fiddle or other libffi using gems . #835
61
+ * Fix possibility to use ffi ruby gem with JRuby-9.3 . #763
62
+ * Fix a GC issue, when a callback Proc is used on more than 2 callback signatures. #820
63
+
64
+
65
+ 1.13.1 / 2020-06-09
66
+ -------------------
67
+
68
+ Changed:
69
+ * Revert use of `ucrtbase.dll` as default C library on Windows-MINGW.
70
+ `ucrtbase.dll` is still used on MSWIN target. #790
71
+ * Test for `ffi_prep_closure_loc()` to make sure we can use this function.
72
+ This fixes incorrect use of system libffi on MacOS Mojave (10.14). #787
73
+ * Update types.conf on x86_64-dragonflybsd
74
+
75
+
1
76
  1.13.0 / 2020-06-01
2
77
  -------------------
3
78
 
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', '~> 2.0'
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
 
@@ -66,10 +66,18 @@ From rubygems:
66
66
  or from the git repository on github:
67
67
 
68
68
  git clone git://github.com/ffi/ffi.git
69
- git submodule update --init --recursive
70
69
  cd ffi
70
+ git submodule update --init --recursive
71
+ bundle install
71
72
  rake install
72
73
 
74
+ ### Install options:
75
+
76
+ * `--enable-system-libffi` : Force usage of system libffi
77
+ * `--disable-system-libffi` : Force usage of builtin libffi
78
+ * `--enable-libffi-alloc` : Force closure allocation by libffi
79
+ * `--disable-libffi-alloc` : Force closure allocation by builtin method
80
+
73
81
  ## License
74
82
 
75
83
  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[i386-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
@@ -8,11 +8,11 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
8
8
 
9
9
  require 'ffi/ffi'
10
10
 
11
- elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("9.3.pre")
11
+ elsif RUBY_ENGINE == 'jruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [9, 3]) >= 0
12
12
  JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService")
13
13
  require 'ffi/ffi'
14
14
 
15
- elsif RUBY_ENGINE == 'truffleruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("20.1.0-dev-a")
15
+ elsif RUBY_ENGINE == 'truffleruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [20, 1, 0]) >= 0
16
16
  require 'truffleruby/ffi_backend'
17
17
  require 'ffi/ffi'
18
18
 
@@ -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
@@ -129,7 +132,11 @@ module FFI
129
132
  end
130
133
 
131
134
  LIBC = if IS_WINDOWS
132
- "ucrtbase.dll"
135
+ if RbConfig::CONFIG['host_os'] =~ /mingw/i
136
+ RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll'
137
+ else
138
+ "ucrtbase.dll"
139
+ end
133
140
  elsif IS_GNU
134
141
  GNU_LIBC
135
142
  elsif OS == 'cygwin'
@@ -141,6 +148,12 @@ module FFI
141
148
  "#{LIBPREFIX}c.#{LIBSUFFIX}"
142
149
  end
143
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
+
144
157
  # Test if current OS is a *BSD (include MAC)
145
158
  # @return [Boolean]
146
159
  def self.bsd?