Skip to content

Commit

Permalink
Merge pull request #159 from hobophobe/master
Browse files Browse the repository at this point in the history
Use consistent name for OS on GNU/Linux.
  • Loading branch information
vp-of-awesome committed Oct 2, 2011
2 parents bec9575 + d37d58d commit f30661a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/ffi/library.rb
Expand Up @@ -38,7 +38,7 @@ def self.map_library_name(lib)

if lib && File.basename(lib) == lib
lib = Platform::LIBPREFIX + lib unless lib =~ /^#{Platform::LIBPREFIX}/
r = Platform::IS_LINUX ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$"
r = Platform::IS_GNU ? "\\.so($|\\.[1234567890]+)" : "\\.#{Platform::LIBSUFFIX}$"
lib += ".#{Platform::LIBSUFFIX}" unless lib =~ /#{r}/
end

Expand Down
10 changes: 5 additions & 5 deletions lib/ffi/platform.rb
Expand Up @@ -27,8 +27,8 @@ class PlatformError < LoadError; end
# various platforms.
module Platform
OS = case RbConfig::CONFIG['host_os'].downcase
when /gnu/
"gnu"
when /linux/
"linux"
when /darwin/
"darwin"
when /freebsd/
Expand Down Expand Up @@ -63,14 +63,14 @@ def self.is_os(os)
end

NAME = "#{ARCH}-#{OS}"
IS_GNU = is_os("gnu")
IS_LINUX = IS_GNU
IS_GNU = defined?(GNU_LIBC)
IS_LINUX = is_os("linux")
IS_MAC = is_os("darwin")
IS_FREEBSD = is_os("freebsd")
IS_OPENBSD = is_os("openbsd")
IS_WINDOWS = is_os("windows")
IS_BSD = IS_MAC || IS_FREEBSD || IS_OPENBSD
CONF_DIR = File.join(File.dirname(__FILE__), 'platform', ARCH.to_s + "-" + OS.to_s)
CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME)
public


Expand Down
11 changes: 11 additions & 0 deletions spec/ffi/typedef_spec.rb
Expand Up @@ -75,4 +75,15 @@ class S < FFI::Struct
end
end.should_not raise_error
end

it "detects the correct type for size_t" do
lambda do
Module.new do
extend FFI::Library
ffi_lib "c"
# read(2) is a standard UNIX function
attach_function :read, [:int, :pointer, :size_t], :ssize_t
end
end.should_not raise_error
end
end

0 comments on commit f30661a

Please sign in to comment.