Module: FFI::Platform
- Defined in:
- lib/ffi/platform.rb,
ext/ffi_c/Platform.c
Overview
This module defines different constants and class methods to play with various platforms.
Constant Summary
- OS =
case RbConfig::CONFIG['host_os'].downcase when /linux/ "linux" when /darwin/ "darwin" when /freebsd/ "freebsd" when /openbsd/ "openbsd" when /sunos|solaris/ "solaris" when /mingw|mswin/ "windows" else RbConfig::CONFIG['host_os'].downcase end
- ARCH =
case CPU.downcase when /amd64|x86_64/ "x86_64" when /i?86|x86|i86pc/ "i386" when /ppc|powerpc/ "powerpc" else case RbConfig::CONFIG['host_cpu'] when /^arm/ "arm" else RbConfig::CONFIG['host_cpu'] end end
- NAME =
"#{ARCH}-#{OS}"- 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', NAME)
- LIBPREFIX =
IS_WINDOWS ? '' : 'lib'
- LIBSUFFIX =
case OS when /darwin/ 'dylib' when /linux|bsd|solaris/ 'so' when /windows/ 'dll' else # Punt and just assume a sane unix (i.e. anything but AIX) 'so' end
- LIBC =
if IS_WINDOWS RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll' elsif IS_GNU GNU_LIBC else "#{LIBPREFIX}c.#{LIBSUFFIX}" end
- BYTE_ORDER =
INT2FIX(BYTE_ORDER)
- LITTLE_ENDIAN =
INT2FIX(LITTLE_ENDIAN)
- BIG_ENDIAN =
INT2FIX(BIG_ENDIAN)
- CPU =
rb_str_new2(CPU)
- GNU_LIBC =
rb_str_new2(LIBC_SO)
Class Method Summary (collapse)
-
+ (Boolean) bsd?
Test if current OS is a *BSD (include MAC).
-
+ (Boolean) is_os(os)
private
Test if current OS is os.
-
+ (Boolean) mac?
Test if current OS is Mac OS.
-
+ (Boolean) unix?
Test if current OS is a unix OS.
-
+ (Boolean) windows?
Test if current OS is Windows.
Class Method Details
+ (Boolean) bsd?
Test if current OS is a *BSD (include MAC)
107 108 109 |
# File 'lib/ffi/platform.rb', line 107 def self.bsd? IS_BSD end |
+ (Boolean) is_os(os) (private)
Test if current OS is os.
66 67 68 |
# File 'lib/ffi/platform.rb', line 66 def self.is_os(os) OS == os end |
+ (Boolean) mac?
Test if current OS is Mac OS
119 120 121 |
# File 'lib/ffi/platform.rb', line 119 def self.mac? IS_MAC end |
+ (Boolean) unix?
Test if current OS is a unix OS
125 126 127 |
# File 'lib/ffi/platform.rb', line 125 def self.unix? !IS_WINDOWS end |
+ (Boolean) windows?
Test if current OS is Windows
113 114 115 |
# File 'lib/ffi/platform.rb', line 113 def self.windows? IS_WINDOWS end |