summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortduehr <td@matasano.com>2014-07-01 12:40:54 -0500
committertduehr <td@matasano.com>2014-07-01 12:40:54 -0500
commit85accd34a4310bf53eaa477291d9c9618c6c1fc9 (patch)
treead9afc074ee3b83b087e1e2dc66a80bc568f732a
parentdf496d6726ef4ef78b6d03bb0d7324663dfd6a2a (diff)
parent39febea8d7ed13e1ebc8747fd6fae09f475e6c17 (diff)
downloadffi-85accd34a4310bf53eaa477291d9c9618c6c1fc9.tar.gz
Merge pull request #351 from tduehr/netbsd
Netbsd
-rw-r--r--bench/bench_buffer.rb21
-rw-r--r--bench/bench_struct.rb21
-rw-r--r--lib/ffi/platform.rb5
-rw-r--r--lib/ffi/platform/x86_64-netbsd/types.conf2
-rw-r--r--spec/ffi/pointer_spec.rb7
-rw-r--r--spec/ffi/struct_spec.rb14
-rw-r--r--spec/ffi/typedef_spec.rb7
7 files changed, 66 insertions, 11 deletions
diff --git a/bench/bench_buffer.rb b/bench/bench_buffer.rb
index e5f48ff..947fe10 100644
--- a/bench/bench_buffer.rb
+++ b/bench/bench_buffer.rb
@@ -9,9 +9,24 @@ module BufferBench
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s32_v, [ :int ], :void
- attach_function :bench_buffer_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
- attach_function :bench_buffer_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
- attach_function :bench_buffer_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ begin
+ attach_function :bench_buffer_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_in, :ptr_ret___int32_t, [ :buffer_in, :int ], :void
+ end
+ begin
+ attach_function :bench_buffer_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_inout, :ptr_ret___int32_t, [ :buffer_inout, :int ], :void
+ end
+ begin
+ attach_function :bench_buffer_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_out, :ptr_ret___int32_t, [ :buffer_out, :int ], :void
+ end
end
class IntStruct < FFI::Struct
layout :i, :int
diff --git a/bench/bench_struct.rb b/bench/bench_struct.rb
index 4506afe..47aac76 100644
--- a/bench/bench_struct.rb
+++ b/bench/bench_struct.rb
@@ -8,9 +8,24 @@ module StructBench
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s32_v, [ :int ], :void
- attach_function :bench_struct_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
- attach_function :bench_struct_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
- attach_function :bench_struct_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ begin
+ attach_function :bench_struct_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_in, :ptr_ret___int32_t, [ :buffer_in, :int ], :void
+ end
+ begin
+ attach_function :bench_struct_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_out, :ptr_ret___int32_t, [ :buffer_out, :int ], :void
+ end
+ begin
+ attach_function :bench_struct_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_inout, :ptr_ret___int32_t, [ :buffer_inout, :int ], :void
+ end
end
class TestStruct < FFI::Struct
layout :i, :int, :p, :pointer
diff --git a/lib/ffi/platform.rb b/lib/ffi/platform.rb
index ea8571b..bba160a 100644
--- a/lib/ffi/platform.rb
+++ b/lib/ffi/platform.rb
@@ -42,6 +42,8 @@ module FFI
"darwin"
when /freebsd/
"freebsd"
+ when /netbsd/
+ "netbsd"
when /openbsd/
"openbsd"
when /sunos|solaris/
@@ -81,9 +83,10 @@ module FFI
IS_LINUX = is_os("linux")
IS_MAC = is_os("darwin")
IS_FREEBSD = is_os("freebsd")
+ IS_NETBSD = is_os("netbsd")
IS_OPENBSD = is_os("openbsd")
IS_WINDOWS = is_os("windows")
- IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD
+ IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD
CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME)
public
diff --git a/lib/ffi/platform/x86_64-netbsd/types.conf b/lib/ffi/platform/x86_64-netbsd/types.conf
index 33bd12b..c4df68a 100644
--- a/lib/ffi/platform/x86_64-netbsd/types.conf
+++ b/lib/ffi/platform/x86_64-netbsd/types.conf
@@ -82,6 +82,8 @@ rbx.platform.typedef.int32_t = int
rbx.platform.typedef.uint32_t = uint
rbx.platform.typedef.int64_t = long_long
rbx.platform.typedef.uint64_t = ulong_long
+rbx.platform.typedef.intptr_t = long
+rbx.platform.typedef.uintptr_t = ulong
rbx.platform.typedef.u_int8_t = uchar
rbx.platform.typedef.u_int16_t = ushort
rbx.platform.typedef.u_int32_t = uint
diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb
index 10f7e2e..49968a5 100644
--- a/spec/ffi/pointer_spec.rb
+++ b/spec/ffi/pointer_spec.rb
@@ -10,7 +10,12 @@ require 'delegate'
module PointerTestLib
extend FFI::Library
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
attach_function :ptr_set_pointer, [ :pointer, :int, :pointer ], :void
attach_function :ptr_ret_pointer, [ :pointer, :int ], :pointer
diff --git a/spec/ffi/struct_spec.rb b/spec/ffi/struct_spec.rb
index 233cf09..aa4fa40 100644
--- a/spec/ffi/struct_spec.rb
+++ b/spec/ffi/struct_spec.rb
@@ -20,7 +20,12 @@ describe "Struct tests" do
extend FFI::Library
ffi_lib TestLibrary::PATH
attach_function :ptr_ret_pointer, [ :pointer, :int], :string
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
attach_function :ptr_from_address, [ :ulong ], :pointer
attach_function :string_equals, [ :string, :string ], :int
[ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t|
@@ -401,7 +406,12 @@ describe FFI::Struct, ".layout" do
module LibTest
extend FFI::Library
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
end
end
diff --git a/spec/ffi/typedef_spec.rb b/spec/ffi/typedef_spec.rb
index f1bcc69..6595d90 100644
--- a/spec/ffi/typedef_spec.rb
+++ b/spec/ffi/typedef_spec.rb
@@ -62,7 +62,12 @@ describe "Custom type definitions" do
typedef :int, :bar
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :string, :foo ], :bar
+ begin
+ attach_function :ptr_ret_int32_t, [ :string, :foo ], :bar
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :string, :foo ], :bar
+ end
end
end.should_not raise_error
end