ffi 1.9.3-x86-mingw32 → 1.9.5-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +13 -16
- data/ext/ffi_c/DynamicLibrary.c +9 -5
- data/ext/ffi_c/DynamicLibrary.h +49 -0
- data/ext/ffi_c/Function.c +4 -3
- data/ext/ffi_c/FunctionInfo.c +2 -2
- data/ext/ffi_c/Platform.c +2 -2
- data/ext/ffi_c/Struct.c +1 -0
- data/ext/ffi_c/Variadic.c +2 -2
- data/ffi.gemspec +5 -5
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/2.0/ffi_c.so +0 -0
- data/lib/ffi/library.rb +7 -7
- data/lib/ffi/platform.rb +4 -1
- data/lib/ffi/platform/x86_64-netbsd/types.conf +2 -0
- data/lib/ffi/struct.rb +2 -2
- data/lib/ffi/version.rb +1 -1
- data/libtest/ClosureTest.c +15 -0
- data/libtest/FunctionTest.c +12 -0
- data/spec/ffi/LICENSE.SPECS +22 -0
- data/spec/ffi/async_callback_spec.rb +1 -0
- data/spec/ffi/bool_spec.rb +2 -0
- data/spec/ffi/buffer_spec.rb +1 -0
- data/spec/ffi/callback_spec.rb +31 -4
- data/spec/ffi/custom_param_type.rb +1 -0
- data/spec/ffi/custom_type_spec.rb +1 -0
- data/spec/ffi/dup_spec.rb +1 -1
- data/spec/ffi/enum_spec.rb +1 -0
- data/spec/ffi/errno_spec.rb +2 -0
- data/spec/ffi/ffi_spec.rb +1 -0
- data/spec/ffi/fixtures/Benchmark.c +52 -0
- data/spec/ffi/fixtures/BoolTest.c +34 -0
- data/spec/ffi/fixtures/BufferTest.c +31 -0
- data/spec/ffi/fixtures/ClosureTest.c +190 -0
- data/spec/ffi/fixtures/EnumTest.c +34 -0
- data/spec/ffi/fixtures/FunctionTest.c +58 -0
- data/spec/ffi/fixtures/GNUmakefile +149 -0
- data/spec/ffi/fixtures/GlobalVariable.c +62 -0
- data/spec/ffi/fixtures/LastErrorTest.c +21 -0
- data/spec/ffi/fixtures/NumberTest.c +132 -0
- data/spec/ffi/fixtures/PointerTest.c +63 -0
- data/spec/ffi/fixtures/ReferenceTest.c +23 -0
- data/spec/ffi/fixtures/StringTest.c +34 -0
- data/spec/ffi/fixtures/StructTest.c +243 -0
- data/spec/ffi/fixtures/UnionTest.c +43 -0
- data/spec/ffi/fixtures/VariadicTest.c +99 -0
- data/spec/ffi/fixtures/classes.rb +438 -0
- data/spec/ffi/function_spec.rb +4 -2
- data/spec/ffi/io_spec.rb +17 -0
- data/spec/ffi/library_spec.rb +25 -0
- data/spec/ffi/long_double.rb +1 -0
- data/spec/ffi/managed_struct_spec.rb +1 -1
- data/spec/ffi/memorypointer_spec.rb +72 -0
- data/spec/ffi/number_spec.rb +2 -0
- data/spec/ffi/platform_spec.rb +97 -0
- data/spec/ffi/pointer_spec.rb +8 -2
- data/spec/ffi/rbx/attach_function_spec.rb +6 -0
- data/spec/ffi/rbx/memory_pointer_spec.rb +7 -2
- data/spec/ffi/rbx/spec_helper.rb +7 -1
- data/spec/ffi/rbx/struct_spec.rb +7 -1
- data/spec/ffi/spec_helper.rb +68 -9
- data/spec/ffi/string_spec.rb +3 -1
- data/spec/ffi/strptr_spec.rb +1 -0
- data/spec/ffi/struct_by_ref_spec.rb +4 -3
- data/spec/ffi/struct_callback_spec.rb +2 -1
- data/spec/ffi/struct_initialize_spec.rb +1 -0
- data/spec/ffi/struct_packed_spec.rb +1 -0
- data/spec/ffi/struct_spec.rb +99 -39
- data/spec/ffi/typedef_spec.rb +15 -3
- data/spec/ffi/union_spec.rb +1 -0
- data/spec/ffi/variadic_spec.rb +18 -0
- data/spec/spec.opts +1 -2
- metadata +418 -392
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
|
4
|
-
|
3
|
+
metadata.gz: 8388c8504e5777a39e69727d10ecf13670674e85
|
4
|
+
data.tar.gz: a3fbbcb12431244e647cb40f93b9366da87212ed
|
5
5
|
SHA512:
|
6
|
-
|
7
|
-
|
6
|
+
metadata.gz: 9b3ed3e25e37a153054936c60fcb63e700555477842c8be209c3ad6390151e1adb3ba97e6fb4c27b4644ba319160cccb332b1ea92957f103dbe3a394252420f2
|
7
|
+
data.tar.gz: 2415657adfd8815c3f478f40e8a531a6345a53b8b12487def0c8736f64bfe200aa20affd0a13500b767b37c517d177cbd12dce95c0cd5ef7cf54db8b4c6e8c06
|
data/Rakefile
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rubygems/package_task'
|
3
1
|
require 'rubygems/tasks'
|
4
2
|
require 'rbconfig'
|
5
3
|
require 'rake/clean'
|
6
4
|
|
7
5
|
USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true
|
8
6
|
if USE_RAKE_COMPILER
|
9
|
-
gem 'rake-compiler', '>=0.6.0'
|
10
7
|
require 'rake/extensiontask'
|
11
8
|
end
|
12
9
|
|
13
10
|
require 'date'
|
14
11
|
require 'fileutils'
|
15
12
|
require 'rbconfig'
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
require 'rubygems/package_task'
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:spec => :compile) do |config|
|
17
|
+
config.rspec_opts = YAML.load_file 'spec/spec.opts'
|
18
|
+
end
|
16
19
|
|
17
20
|
|
18
21
|
LIBEXT = case RbConfig::CONFIG['host_os'].downcase
|
@@ -103,13 +106,13 @@ end
|
|
103
106
|
desc "Build all packages"
|
104
107
|
task :package => 'gem:package'
|
105
108
|
|
106
|
-
|
107
109
|
CLOBBER.include 'build'
|
108
110
|
CLOBBER.include FileList['lib/**/ffi_c.so']
|
109
111
|
CLOBBER.include FileList["lib/**/ffi_c.#{RbConfig::CONFIG['DLEXT']}"]
|
110
112
|
CLOBBER.include 'lib/ffi/types.conf'
|
111
113
|
CLOBBER.include 'conftest.dSYM'
|
112
114
|
CLOBBER.include 'pkg'
|
115
|
+
CLOBBER.include 'spec/ffi/fixtures/libtest.dylib'
|
113
116
|
|
114
117
|
task :distclean => :clobber
|
115
118
|
|
@@ -123,7 +126,7 @@ desc "Build test helper lib"
|
|
123
126
|
task :libtest => "build/libtest.#{LIBEXT}"
|
124
127
|
|
125
128
|
desc "Test the extension"
|
126
|
-
task :test => [ :
|
129
|
+
task :test => [ :spec ]
|
127
130
|
|
128
131
|
|
129
132
|
namespace :bench do
|
@@ -148,7 +151,7 @@ task 'spec:specdoc' => TEST_DEPS
|
|
148
151
|
task :default => :specs
|
149
152
|
|
150
153
|
task 'gem:win32' do
|
151
|
-
sh("rake cross native gem RUBY_CC_VERSION='1.8.7:1.9.3:2.0.0'") || raise("win32 build failed!")
|
154
|
+
sh("rake cross native gem RUBY_CC_VERSION='1.8.7:1.9.3:2.0.0:2.1.3'") || raise("win32 build failed!")
|
152
155
|
end
|
153
156
|
|
154
157
|
|
@@ -162,7 +165,7 @@ namespace 'java' do
|
|
162
165
|
s.homepage = gem_spec.homepage
|
163
166
|
s.summary = gem_spec.summary
|
164
167
|
s.description = gem_spec.description
|
165
|
-
s.files = %w(
|
168
|
+
s.files = %w(LICENSE COPYING README.md Rakefile)
|
166
169
|
s.has_rdoc = false
|
167
170
|
s.license = gem_spec.license
|
168
171
|
s.platform = 'java'
|
@@ -184,22 +187,16 @@ if USE_RAKE_COMPILER
|
|
184
187
|
# ext.lib_dir = BUILD_DIR # put binaries into this folder.
|
185
188
|
ext.tmp_dir = BUILD_DIR # temporary folder used during compilation.
|
186
189
|
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
187
|
-
ext.cross_platform = %w[i386-mingw32 x64-mingw32]
|
190
|
+
ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
|
188
191
|
end
|
189
192
|
|
190
193
|
ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
|
191
194
|
task "copy:ffi_c:i386-mingw32:#{ruby_version}" do |t|
|
192
|
-
|
193
|
-
if File.exists?("#{dir}/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so")
|
194
|
-
sh "i686-w64-mingw32-strip -S #{dir}/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
195
|
-
end
|
196
|
-
end
|
195
|
+
sh "i686-w64-mingw32-strip -S #{BUILD_DIR}/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
197
196
|
end
|
198
197
|
|
199
198
|
task "copy:ffi_c:x64-mingw32:#{ruby_version}" do |t|
|
200
|
-
|
201
|
-
sh "x86_64-w64-mingw32-strip -S #{BUILD_DIR}/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
202
|
-
end
|
199
|
+
sh "x86_64-w64-mingw32-strip -S #{BUILD_DIR}/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
|
203
200
|
end
|
204
201
|
end
|
205
202
|
end
|
data/ext/ffi_c/DynamicLibrary.c
CHANGED
@@ -73,15 +73,11 @@ static void* dl_open(const char* name, int flags);
|
|
73
73
|
static void dl_error(char* buf, int size);
|
74
74
|
#define dl_sym(handle, name) GetProcAddress(handle, name)
|
75
75
|
#define dl_close(handle) FreeLibrary(handle)
|
76
|
-
enum { RTLD_LAZY=1, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL };
|
77
76
|
#else
|
78
77
|
# define dl_open(name, flags) dlopen(name, flags != 0 ? flags : RTLD_LAZY)
|
79
78
|
# define dl_error(buf, size) do { snprintf(buf, size, "%s", dlerror()); } while(0)
|
80
79
|
# define dl_sym(handle, name) dlsym(handle, name)
|
81
80
|
# define dl_close(handle) dlclose(handle)
|
82
|
-
#ifndef RTLD_LOCAL
|
83
|
-
# define RTLD_LOCAL 8
|
84
|
-
#endif
|
85
81
|
#endif
|
86
82
|
|
87
83
|
static VALUE
|
@@ -321,13 +317,21 @@ rbffi_DynamicLibrary_Init(VALUE moduleFFI)
|
|
321
317
|
rb_undef_method(SymbolClass, "new");
|
322
318
|
rb_define_method(SymbolClass, "inspect", symbol_inspect, 0);
|
323
319
|
rb_define_method(SymbolClass, "initialize_copy", symbol_initialize_copy, 1);
|
324
|
-
|
325
320
|
|
326
321
|
#define DEF(x) rb_define_const(LibraryClass, "RTLD_" #x, UINT2NUM(RTLD_##x))
|
327
322
|
DEF(LAZY);
|
328
323
|
DEF(NOW);
|
329
324
|
DEF(GLOBAL);
|
330
325
|
DEF(LOCAL);
|
326
|
+
DEF(NOLOAD);
|
327
|
+
DEF(NODELETE);
|
328
|
+
DEF(FIRST);
|
329
|
+
DEF(DEEPBIND);
|
330
|
+
DEF(MEMBER);
|
331
|
+
DEF(BINDING_MASK);
|
332
|
+
DEF(LOCATION_MASK);
|
333
|
+
DEF(ALL_MASK);
|
334
|
+
#undef DEF
|
331
335
|
|
332
336
|
}
|
333
337
|
|
data/ext/ffi_c/DynamicLibrary.h
CHANGED
@@ -33,7 +33,56 @@
|
|
33
33
|
extern "C" {
|
34
34
|
#endif
|
35
35
|
|
36
|
+
/* if these aren't defined (eg. windows), we need sensible defaults */
|
37
|
+
#ifndef RTLD_LAZY
|
38
|
+
#define RTLD_LAZY 1
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#ifndef RTLD_NOW
|
42
|
+
#define RTLD_NOW 2
|
43
|
+
#endif
|
44
|
+
|
45
|
+
#ifndef RTLD_LOCAL
|
46
|
+
#define RTLD_LOCAL 4
|
47
|
+
#endif
|
48
|
+
|
49
|
+
#ifndef RTLD_GLOBAL
|
50
|
+
#define RTLD_GLOBAL 8
|
51
|
+
#endif
|
52
|
+
|
53
|
+
/* If these aren't defined, they're not supported so define as 0 */
|
54
|
+
#ifndef RTLD_NOLOAD
|
55
|
+
#define RTLD_NOLOAD 0
|
56
|
+
#endif
|
57
|
+
|
58
|
+
#ifndef RTLD_NODELETE
|
59
|
+
#define RTLD_NODELETE 0
|
60
|
+
#endif
|
36
61
|
|
62
|
+
#ifndef RTLD_FIRST
|
63
|
+
#define RTLD_FIRST 0
|
64
|
+
#endif
|
65
|
+
|
66
|
+
#ifndef RTLD_DEEPBIND
|
67
|
+
#define RTLD_DEEPBIND 0
|
68
|
+
#endif
|
69
|
+
|
70
|
+
#ifndef RTLD_MEMBER
|
71
|
+
#define RTLD_MEMBER 0
|
72
|
+
#endif
|
73
|
+
|
74
|
+
/* convenience */
|
75
|
+
#ifndef RTLD_BINDING_MASK
|
76
|
+
#define RTLD_BINDING_MASK (RTLD_LAZY | RTLD_NOW)
|
77
|
+
#endif
|
78
|
+
|
79
|
+
#ifndef RTLD_LOCATION_MASK
|
80
|
+
#define RTLD_LOCATION_MASK (RTLD_LOCAL | RTLD_GLOBAL)
|
81
|
+
#endif
|
82
|
+
|
83
|
+
#ifndef RTLD_ALL_MASK
|
84
|
+
#define RTLD_ALL_MASK (RTLD_BINDING_MASK | RTLD_LOCATION_MASK | RTLD_NOLOAD | RTLD_NODELETE | RTLD_FIRST | RTLD_DEEPBIND | RTLD_MEMBER)
|
85
|
+
#endif
|
37
86
|
|
38
87
|
typedef struct Library {
|
39
88
|
void* handle;
|
data/ext/ffi_c/Function.c
CHANGED
@@ -86,7 +86,7 @@ static void function_free(Function *);
|
|
86
86
|
static VALUE function_init(VALUE self, VALUE rbFunctionInfo, VALUE rbProc);
|
87
87
|
static void callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data);
|
88
88
|
static bool callback_prep(void* ctx, void* code, Closure* closure, char* errmsg, size_t errmsgsize);
|
89
|
-
static
|
89
|
+
static void* callback_with_gvl(void* data);
|
90
90
|
static VALUE invoke_callback(void* data);
|
91
91
|
static VALUE save_callback_exception(void* data, VALUE exc);
|
92
92
|
|
@@ -731,10 +731,11 @@ async_cb_call(void *data)
|
|
731
731
|
|
732
732
|
#endif
|
733
733
|
|
734
|
-
static
|
734
|
+
static void *
|
735
735
|
callback_with_gvl(void* data)
|
736
736
|
{
|
737
737
|
rb_rescue2(invoke_callback, (VALUE) data, save_callback_exception, (VALUE) data, rb_eException, (VALUE) 0);
|
738
|
+
return NULL;
|
738
739
|
}
|
739
740
|
|
740
741
|
static VALUE
|
@@ -759,8 +760,8 @@ invoke_callback(void* data)
|
|
759
760
|
VALUE rbParamType = rb_ary_entry(cbInfo->rbParameterTypes, i);
|
760
761
|
|
761
762
|
if (unlikely(paramType->nativeType == NATIVE_MAPPED)) {
|
762
|
-
paramType = ((MappedType *) paramType)->type;
|
763
763
|
rbParamType = ((MappedType *) paramType)->rbType;
|
764
|
+
paramType = ((MappedType *) paramType)->type;
|
764
765
|
}
|
765
766
|
|
766
767
|
switch (paramType->nativeType) {
|
data/ext/ffi_c/FunctionInfo.c
CHANGED
@@ -119,7 +119,7 @@ fntype_initialize(int argc, VALUE* argv, VALUE self)
|
|
119
119
|
ffi_status status;
|
120
120
|
VALUE rbReturnType = Qnil, rbParamTypes = Qnil, rbOptions = Qnil;
|
121
121
|
VALUE rbEnums = Qnil, rbConvention = Qnil, rbBlocking = Qnil;
|
122
|
-
#if defined(
|
122
|
+
#if defined(X86_WIN32)
|
123
123
|
VALUE rbConventionStr;
|
124
124
|
#endif
|
125
125
|
int i, nargs;
|
@@ -181,7 +181,7 @@ fntype_initialize(int argc, VALUE* argv, VALUE self)
|
|
181
181
|
fnInfo->ffiReturnType = fnInfo->returnType->ffiType;
|
182
182
|
|
183
183
|
|
184
|
-
#if
|
184
|
+
#if defined(X86_WIN32)
|
185
185
|
rbConventionStr = (rbConvention != Qnil) ? rb_funcall2(rbConvention, rb_intern("to_s"), 0, NULL) : Qnil;
|
186
186
|
fnInfo->abi = (rbConventionStr != Qnil && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0)
|
187
187
|
? FFI_STDCALL : FFI_DEFAULT_ABI;
|
data/ext/ffi_c/Platform.c
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
#include "rbffi_endian.h"
|
44
44
|
#include "Platform.h"
|
45
45
|
|
46
|
-
#if defined(
|
46
|
+
#if defined(__GNU__) || defined(__GLIBC__)
|
47
47
|
# include <gnu/lib-names.h>
|
48
48
|
#endif
|
49
49
|
|
@@ -113,7 +113,7 @@ rbffi_Platform_Init(VALUE moduleFFI)
|
|
113
113
|
rb_define_const(PlatformModule, "LITTLE_ENDIAN", INT2FIX(LITTLE_ENDIAN));
|
114
114
|
rb_define_const(PlatformModule, "BIG_ENDIAN", INT2FIX(BIG_ENDIAN));
|
115
115
|
rb_define_const(PlatformModule, "CPU", rb_str_new2(CPU));
|
116
|
-
#if defined(
|
116
|
+
#if defined(__GNU__) || defined(__GLIBC__)
|
117
117
|
rb_define_const(PlatformModule, "GNU_LIBC", rb_str_new2(LIBC_SO));
|
118
118
|
#endif
|
119
119
|
export_primitive_types(PlatformModule);
|
data/ext/ffi_c/Struct.c
CHANGED
@@ -289,6 +289,7 @@ struct_field(Struct* s, VALUE fieldName)
|
|
289
289
|
return rbField;
|
290
290
|
}
|
291
291
|
|
292
|
+
// TODO does this ever return anything?
|
292
293
|
rbField = rb_hash_aref(layout->rbFieldMap, fieldName);
|
293
294
|
if (rbField == Qnil) {
|
294
295
|
VALUE str = rb_funcall2(fieldName, id_to_s, 0, NULL);
|
data/ext/ffi_c/Variadic.c
CHANGED
@@ -103,7 +103,7 @@ variadic_initialize(VALUE self, VALUE rbFunction, VALUE rbParameterTypes, VALUE
|
|
103
103
|
VALUE retval = Qnil;
|
104
104
|
VALUE convention = Qnil;
|
105
105
|
VALUE fixed = Qnil;
|
106
|
-
#if defined(
|
106
|
+
#if defined(X86_WIN32)
|
107
107
|
VALUE rbConventionStr;
|
108
108
|
#endif
|
109
109
|
int i;
|
@@ -116,7 +116,7 @@ variadic_initialize(VALUE self, VALUE rbFunction, VALUE rbParameterTypes, VALUE
|
|
116
116
|
invoker->rbAddress = rbFunction;
|
117
117
|
invoker->function = rbffi_AbstractMemory_Cast(rbFunction, rbffi_PointerClass)->address;
|
118
118
|
|
119
|
-
#if
|
119
|
+
#if defined(X86_WIN32)
|
120
120
|
rbConventionStr = rb_funcall2(convention, rb_intern("to_s"), 0, NULL);
|
121
121
|
invoker->abi = (RTEST(convention) && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0)
|
122
122
|
? FFI_STDCALL : FFI_DEFAULT_ABI;
|
data/ffi.gemspec
CHANGED
@@ -8,15 +8,15 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.homepage = 'http://wiki.github.com/ffi/ffi'
|
9
9
|
s.summary = 'Ruby FFI'
|
10
10
|
s.description = 'Ruby FFI library'
|
11
|
-
s.files = %w(ffi.gemspec LICENSE COPYING README.md Rakefile) + Dir.glob("{ext,gen,lib,spec,libtest}/**/*").reject { |f| f =~ /(lib\/[12]\.[089]|\.so$|\.bundle$)/ }
|
11
|
+
s.files = %w(ffi.gemspec LICENSE COPYING README.md Rakefile) + Dir.glob("{ext,gen,lib,spec,libtest}/**/*").reject { |f| f =~ /(lib\/[12]\.[089]|\.so$|\.bundle|\.dylib$)/ }
|
12
12
|
s.extensions << 'ext/ffi_c/extconf.rb'
|
13
13
|
s.has_rdoc = false
|
14
14
|
s.rdoc_options = %w[--exclude=ext/ffi_c/.*\.o$ --exclude=ffi_c\.(bundle|so)$]
|
15
15
|
s.license = 'BSD'
|
16
16
|
s.require_paths << 'ext/ffi_c'
|
17
17
|
s.required_ruby_version = '>= 1.8.7'
|
18
|
-
s.add_development_dependency 'rake'
|
19
|
-
s.add_development_dependency 'rake-compiler', '
|
20
|
-
s.add_development_dependency 'rspec'
|
21
|
-
s.add_development_dependency 'rubygems-tasks'
|
18
|
+
s.add_development_dependency 'rake', '~> 10.1'
|
19
|
+
s.add_development_dependency 'rake-compiler', '~> 0.9'
|
20
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
21
|
+
s.add_development_dependency 'rubygems-tasks', "~> 0.2.4"
|
22
22
|
end
|
data/lib/1.8/ffi_c.so
CHANGED
Binary file
|
data/lib/1.9/ffi_c.so
CHANGED
Binary file
|
data/lib/2.0/ffi_c.so
CHANGED
Binary file
|
data/lib/ffi/library.rb
CHANGED
@@ -114,8 +114,8 @@ module FFI
|
|
114
114
|
|
115
115
|
rescue Exception => ex
|
116
116
|
ldscript = false
|
117
|
-
if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*invalid ELF header/
|
118
|
-
if File.read($1) =~ /GROUP *\( *([^ \)]+)
|
117
|
+
if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/
|
118
|
+
if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/
|
119
119
|
libname = $1
|
120
120
|
ldscript = true
|
121
121
|
end
|
@@ -279,12 +279,12 @@ module FFI
|
|
279
279
|
if ffi_convention == :stdcall
|
280
280
|
# Get the size of each parameter
|
281
281
|
size = arg_types.inject(0) do |mem, arg|
|
282
|
-
|
282
|
+
size = arg.size
|
283
|
+
# The size must be a multiple of 4
|
284
|
+
size += (4 - size) % 4
|
285
|
+
mem + size
|
283
286
|
end
|
284
287
|
|
285
|
-
# Next, the size must be a multiple of 4
|
286
|
-
size += (4 - size) % 4
|
287
|
-
|
288
288
|
result << "_#{name.to_s}@#{size}" # win32
|
289
289
|
result << "#{name.to_s}@#{size}" # win64
|
290
290
|
end
|
@@ -334,7 +334,7 @@ module FFI
|
|
334
334
|
def self.#{mname}
|
335
335
|
@@ffi_gvar_#{mname}
|
336
336
|
end
|
337
|
-
code
|
337
|
+
code
|
338
338
|
|
339
339
|
else
|
340
340
|
sc = Class.new(FFI::Struct)
|
data/lib/ffi/platform.rb
CHANGED
@@ -42,6 +42,8 @@ module FFI
|
|
42
42
|
"darwin"
|
43
43
|
when /freebsd/
|
44
44
|
"freebsd"
|
45
|
+
when /netbsd/
|
46
|
+
"netbsd"
|
45
47
|
when /openbsd/
|
46
48
|
"openbsd"
|
47
49
|
when /sunos|solaris/
|
@@ -81,9 +83,10 @@ module FFI
|
|
81
83
|
IS_LINUX = is_os("linux")
|
82
84
|
IS_MAC = is_os("darwin")
|
83
85
|
IS_FREEBSD = is_os("freebsd")
|
86
|
+
IS_NETBSD = is_os("netbsd")
|
84
87
|
IS_OPENBSD = is_os("openbsd")
|
85
88
|
IS_WINDOWS = is_os("windows")
|
86
|
-
IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD
|
89
|
+
IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD
|
87
90
|
CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME)
|
88
91
|
public
|
89
92
|
|
@@ -82,6 +82,8 @@ rbx.platform.typedef.int32_t = int
|
|
82
82
|
rbx.platform.typedef.uint32_t = uint
|
83
83
|
rbx.platform.typedef.int64_t = long_long
|
84
84
|
rbx.platform.typedef.uint64_t = ulong_long
|
85
|
+
rbx.platform.typedef.intptr_t = long
|
86
|
+
rbx.platform.typedef.uintptr_t = ulong
|
85
87
|
rbx.platform.typedef.u_int8_t = uchar
|
86
88
|
rbx.platform.typedef.u_int16_t = ushort
|
87
89
|
rbx.platform.typedef.u_int32_t = uint
|
data/lib/ffi/struct.rb
CHANGED
@@ -76,7 +76,7 @@ module FFI
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def put(ptr, value)
|
79
|
-
raise TypeError, "wrong value type (expected #{type.struct_class}" unless value.is_a?(type.struct_class)
|
79
|
+
raise TypeError, "wrong value type (expected #{type.struct_class})" unless value.is_a?(type.struct_class)
|
80
80
|
ptr.slice(self.offset, self.size).__copy_from__(value.pointer, self.size)
|
81
81
|
end
|
82
82
|
end
|
@@ -258,7 +258,7 @@ module FFI
|
|
258
258
|
# end
|
259
259
|
# @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9.
|
260
260
|
def layout(*spec)
|
261
|
-
#
|
261
|
+
#raise RuntimeError, "struct layout already defined for #{self.inspect}" if defined?(@layout)
|
262
262
|
return @layout if spec.size == 0
|
263
263
|
|
264
264
|
builder = StructLayoutBuilder.new
|
data/lib/ffi/version.rb
CHANGED
data/libtest/ClosureTest.c
CHANGED
@@ -50,6 +50,21 @@ P(D, double);
|
|
50
50
|
P(P, const void*);
|
51
51
|
P(UL, unsigned long);
|
52
52
|
|
53
|
+
#if defined(_WIN32) && !defined(_WIN64)
|
54
|
+
bool __stdcall testClosureStdcall(long *a1, void __stdcall(*closure)(void *, long), long a2) { \
|
55
|
+
void* sp_pre;
|
56
|
+
void* sp_post;
|
57
|
+
|
58
|
+
asm volatile (" movl %%esp,%0" : "=g" (sp_pre));
|
59
|
+
(*closure)(a1, a2);
|
60
|
+
asm volatile (" movl %%esp,%0" : "=g" (sp_post));
|
61
|
+
|
62
|
+
/* %esp before pushing parameters on the stack and after the call returns
|
63
|
+
* should be equal, if both sides respects the stdcall convention */
|
64
|
+
return sp_pre == sp_post;
|
65
|
+
}
|
66
|
+
#endif
|
67
|
+
|
53
68
|
void testOptionalClosureBrV(void (*closure)(char), char a1)
|
54
69
|
{
|
55
70
|
if (closure) {
|
data/libtest/FunctionTest.c
CHANGED
@@ -56,3 +56,15 @@ void testAsyncCallback(void (*fn)(int), int value)
|
|
56
56
|
(*fn)(value);
|
57
57
|
#endif
|
58
58
|
}
|
59
|
+
|
60
|
+
#if defined(_WIN32) && !defined(_WIN64)
|
61
|
+
struct StructUCDP {
|
62
|
+
unsigned char a1;
|
63
|
+
double a2;
|
64
|
+
void *a3;
|
65
|
+
};
|
66
|
+
|
67
|
+
void __stdcall testStdcallManyParams(long *a1, char a2, short int a3, int a4, __int64 a5,
|
68
|
+
struct StructUCDP a6, struct StructUCDP *a7, float a8, double a9) {
|
69
|
+
}
|
70
|
+
#endif
|