ffi 0.5.1 → 0.5.3

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.

data/Rakefile CHANGED
@@ -40,10 +40,16 @@ CPU = case Config::CONFIG['host_cpu'].downcase
40
40
  else
41
41
  "i386"
42
42
  end
43
+
43
44
  when /amd64|x86_64/
44
45
  "x86_64"
46
+
47
+ when /ppc64|powerpc64/
48
+ "powerpc64"
49
+
45
50
  when /ppc|powerpc/
46
51
  "powerpc"
52
+
47
53
  else
48
54
  Config::CONFIG['host_cpu']
49
55
  end
@@ -78,7 +84,7 @@ PROJ.name = 'ffi'
78
84
  PROJ.authors = 'Wayne Meissner'
79
85
  PROJ.email = 'wmeissner@gmail.com'
80
86
  PROJ.url = 'http://wiki.github.com/ffi/ffi'
81
- PROJ.version = '0.5.1'
87
+ PROJ.version = '0.5.3'
82
88
  PROJ.rubyforge.name = 'ffi'
83
89
  PROJ.readme_file = 'README.rdoc'
84
90
 
@@ -28,14 +28,14 @@
28
28
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
  */
30
30
 
31
- #ifndef _INVOKE_H
32
- #define _INVOKE_H
31
+ #ifndef RBFFI_INVOKE_H
32
+ #define RBFFI_INVOKE_H
33
33
 
34
34
  #ifdef __cplusplus
35
35
  extern "C" {
36
36
  #endif
37
37
 
38
- #if defined(__i386__) && !defined(_WIN32) && !defined(__WIN32__)
38
+ #if defined(__i386__) && defined(HAVE_RAW_API) && !defined(_WIN32) && !defined(__WIN32__)
39
39
  # define USE_RAW
40
40
  #endif
41
41
 
@@ -82,5 +82,5 @@ extern int rbffi_GetSignedIntValue(VALUE value, int type, int minValue, int maxV
82
82
  }
83
83
  #endif
84
84
 
85
- #endif /* _INVOKE_H */
85
+ #endif /* RBFFI_INVOKE_H */
86
86
 
@@ -35,6 +35,8 @@
35
35
  #include <stdbool.h>
36
36
  #ifndef _WIN32
37
37
  # include <unistd.h>
38
+ #else
39
+ # include <windows.h>
38
40
  #endif
39
41
  #include <errno.h>
40
42
  #include <ruby.h>
@@ -111,7 +113,7 @@ rbffi_ClosurePool_New(int closureSize,
111
113
  pool->prep = prep;
112
114
  pool->refcnt = 1;
113
115
 
114
- #if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) && !defined(__WIN32__)
116
+ #if defined(HAVE_NATIVETHREAD) && !defined(_WIN32)
115
117
  pthread_mutex_init(&pool->mutex, NULL);
116
118
  #endif
117
119
 
@@ -253,7 +255,7 @@ rbffi_Closure_CodeAddress(Closure* handle)
253
255
  static int
254
256
  getPageSize()
255
257
  {
256
- #ifdef _WIN32
258
+ #if defined(_WIN32) || defined(__WIN32__)
257
259
  SYSTEM_INFO si;
258
260
  GetSystemInfo(&si);
259
261
  return si.dwPageSize;
@@ -265,7 +267,7 @@ getPageSize()
265
267
  static void*
266
268
  allocatePage(void)
267
269
  {
268
- #ifdef _WIN32
270
+ #if defined(_WIN32) || defined(__WIN32__)
269
271
  return VirtualAlloc(NULL, pageSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
270
272
  #else
271
273
  caddr_t page = mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
@@ -276,7 +278,7 @@ allocatePage(void)
276
278
  static bool
277
279
  freePage(void *addr)
278
280
  {
279
- #ifdef _WIN32
281
+ #if defined(_WIN32) || defined(__WIN32__)
280
282
  return VirtualFree(addr, 0, MEM_RELEASE);
281
283
  #else
282
284
  return munmap(addr, pageSize) == 0;
@@ -286,7 +288,7 @@ freePage(void *addr)
286
288
  static bool
287
289
  protectPage(void* page)
288
290
  {
289
- #ifdef _WIN32
291
+ #if defined(_WIN32) || defined(__WIN32__)
290
292
  DWORD oldProtect;
291
293
  return VirtualProtect(page, pageSize, PAGE_EXECUTE_READ, &oldProtect);
292
294
  #else
@@ -175,7 +175,7 @@ attached_method_invoke(ffi_cif* cif, void* mretval, METHOD_PARAMS parameters, vo
175
175
  int argc = parameters[0].sint;
176
176
  VALUE* argv = *(VALUE **) &parameters[1];
177
177
  #else
178
- int argc = *(ffi_sarg *) parameters[0];
178
+ int argc = *(int *) parameters[0];
179
179
  VALUE* argv = *(VALUE **) parameters[1];
180
180
  #endif
181
181
 
@@ -4,7 +4,7 @@
4
4
  #include <sys/param.h>
5
5
  #include <sys/types.h>
6
6
 
7
- #ifdef __linux__
7
+ #if defined(__linux__) || defined(__CYGWIN__)
8
8
  # include_next <endian.h>
9
9
  #endif
10
10
 
@@ -3,22 +3,27 @@ require 'mkmf'
3
3
  require 'rbconfig'
4
4
  dir_config("ffi_c")
5
5
 
6
- IS_MAC = Config::CONFIG['host_os'] =~ /^darwin/
7
- have_closure_alloc = have_library("ffi", "ffi_closure_alloc", [ "ffi.h" ])
8
- $defs.push("-DHAVE_FFI_CLOSURE_ALLOC") if have_closure_alloc
9
- libffi_ok = have_closure_alloc && !IS_MAC
10
- $defs << "-DHAVE_LIBFFI" if libffi_ok
6
+ unless Config::CONFIG['host_os'] =~ /mswin32|mingw32/
7
+ pkg_config("libffi") || find_header("ffi.h", "/usr/local/include", "/opt/local/include")
8
+ have_ffi_call = have_library("ffi", "ffi_call", [ "ffi.h" ])
9
+ have_prep_closure = have_func("ffi_prep_closure")
10
+ libffi_ok = have_ffi_call && have_prep_closure
11
+ $defs << "-DHAVE_LIBFFI" if libffi_ok
12
+ $defs << "-DHAVE_RAW_API" if have_func("ffi_raw_call") && have_func("ffi_prep_raw_closure")
13
+ end
14
+ have_func('rb_thread_blocking_region')
15
+
11
16
  $defs << "-DHAVE_EXTCONF_H" if $defs.empty? # needed so create_header works
12
17
 
13
- have_func('rb_thread_blocking_region')
18
+ create_header
19
+
20
+ $CFLAGS << "-mwin32 " if Config::CONFIG['host_os'] =~ /cygwin/
21
+ $CFLAGS << "-Werror -Wunused -Wformat -Wimplicit -Wreturn-type "
14
22
 
15
23
  create_makefile("ffi_c")
16
- create_header("extconf.h")
17
- File.open("Makefile", "a") do |mf|
18
- mf.puts "CPPFLAGS += -Werror -Wunused -Wformat -Wimplicit -Wreturn-type"
19
- unless libffi_ok
24
+ unless libffi_ok
25
+ File.open("Makefile", "a") do |mf|
20
26
  mf.puts "LIBFFI_HOST=--host=#{Config::CONFIG['host_alias']}" if Config::CONFIG.has_key?("host_alias")
21
- mf.puts "FFI_MMAP_EXEC=-DFFI_MMAP_EXEC_WRIT=#{Config::CONFIG['host_os'] =~ /(win32|mingw)/ ? 0 : 1}"
22
27
  if Config::CONFIG['host_os'].downcase =~ /darwin/
23
28
  mf.puts "include ${srcdir}/libffi.darwin.mk"
24
29
  elsif Config::CONFIG['host_os'].downcase =~ /bsd/
@@ -9,7 +9,7 @@ LOCAL_LIBS += ${LIBFFI} -lpthread
9
9
  LIBFFI_CFLAGS = ${FFI_MMAP_EXEC} -pthread
10
10
  LIBFFI_BUILD_DIR = ${.CURDIR}/libffi
11
11
 
12
- .if "${srcdir}" == "."
12
+ .if ${srcdir} == "."
13
13
  LIBFFI_SRC_DIR := ${.CURDIR}/libffi
14
14
  .else
15
15
  LIBFFI_SRC_DIR := ${srcdir}/libffi
@@ -1,6 +1,6 @@
1
- This is /Users/wayne/src/ruby-ffi.git/ext/ffi_c/libffi/doc/libffi.info,
1
+ This is /Users/wayne/src/ffi-0.5/ext/ffi_c/libffi/doc/libffi.info,
2
2
  produced by makeinfo version 4.7 from
3
- /Users/wayne/src/ruby-ffi.git/ext/ffi_c/libffi/doc/libffi.texi.
3
+ /Users/wayne/src/ffi-0.5/ext/ffi_c/libffi/doc/libffi.texi.
4
4
 
5
5
  This manual is for Libffi, a portable foreign-function interface
6
6
  library.
@@ -517,18 +517,18 @@ Index
517
517
 
518
518
  
519
519
  Tag Table:
520
- Node: Top764
521
- Node: Introduction1500
522
- Node: Using libffi3136
523
- Node: The Basics3571
524
- Node: Simple Example6178
525
- Node: Types7205
526
- Node: Primitive Types7488
527
- Node: Structures9308
528
- Node: Type Example10168
529
- Node: Multiple ABIs11391
530
- Node: The Closure API11762
531
- Node: Missing Features14682
532
- Node: Index15175
520
+ Node: Top754
521
+ Node: Introduction1490
522
+ Node: Using libffi3126
523
+ Node: The Basics3561
524
+ Node: Simple Example6168
525
+ Node: Types7195
526
+ Node: Primitive Types7478
527
+ Node: Structures9298
528
+ Node: Type Example10158
529
+ Node: Multiple ABIs11381
530
+ Node: The Closure API11752
531
+ Node: Missing Features14672
532
+ Node: Index15165
533
533
  
534
534
  End Tag Table
@@ -0,0 +1,4 @@
1
+ #
2
+ # All the code from this file is now implemented in C. This file remains
3
+ # to satisfy any leftover require 'ffi/buffer' in user code
4
+ #
@@ -44,7 +44,6 @@ require 'ffi/types'
44
44
  require 'ffi/library'
45
45
  require 'ffi/errno'
46
46
  require 'ffi/memorypointer'
47
- require 'ffi/buffer'
48
47
  require 'ffi/struct'
49
48
  require 'ffi/union'
50
49
  require 'ffi/managedstruct'
@@ -135,7 +135,7 @@ module FFI::Library
135
135
  end
136
136
 
137
137
  def callback(*args)
138
- raise ArgError, "wrong number of arguments" if args.length < 2 || args.length > 3
138
+ raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3
139
139
  name, params, ret = if args.length == 3
140
140
  args
141
141
  else
@@ -45,7 +45,7 @@ describe "Managed Struct" do
45
45
  end
46
46
 
47
47
  loop_count = 30
48
- wiggle_room = 2
48
+ wiggle_room = 5
49
49
 
50
50
  PleaseReleaseMe.should_receive(:release).at_least(loop_count-wiggle_room).times
51
51
  loop_count.times do
@@ -107,7 +107,7 @@ end
107
107
 
108
108
  describe "AutoPointer" do
109
109
  loop_count = 30
110
- wiggle_room = 2 # GC rarely cleans up all objects. we can get most of them, and that's enough to determine if the basic functionality is working.
110
+ wiggle_room = 5 # GC rarely cleans up all objects. we can get most of them, and that's enough to determine if the basic functionality is working.
111
111
  magic = 0x12345678
112
112
 
113
113
  class AutoPointerTestHelper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Meissner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-19 00:00:00 +10:00
12
+ date: 2009-11-20 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -390,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
390
  requirements: []
391
391
 
392
392
  rubyforge_project: ffi
393
- rubygems_version: 1.3.4
393
+ rubygems_version: 1.3.5
394
394
  signing_key:
395
395
  specification_version: 3
396
396
  summary: Ruby-FFI is a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code