Package org.jruby.ext.ffi
Class Platform
java.lang.Object
org.jruby.ext.ffi.Platform
- Direct Known Subclasses:
Platform.Default,Platform.Supported,Platform.Unsupported
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classAPlatformsubclass representing the Linux operating system.static enumprivate static final classAPlatformsubclass representing the MacOS system.private static final classprivate static final classAPlatformsubclass representing the Linux operating system.static enumprivate static final classprivate static classprivate static classprivate static classAPlatformsubclass representing the Windows system. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final longprotected final intprivate static final intstatic final intstatic final intstatic final Platform.CPU_TYPEprivate intstatic final Stringprotected final Patternstatic final Stringstatic final Stringstatic final intprivate static final Localeprotected final intstatic final Stringstatic final Platform.OS_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal longGets the 32/64bit mask of a C address/pointer on the native platform.final intGets the size of a C address/pointer on the native platform.static IRubyObjectbsd_p(ThreadContext context, IRubyObject recv) static voidcreatePlatformModule(Ruby runtime, RubyModule ffi) private static intprivate static final Platform.CPU_TYPEprivate static final Stringprivate static final Stringprivate static final Platform.OS_TYPEprivate static final Platformfinal Platform.CPU_TYPEgetCPU()Gets the current processor architecture the JVM is running on.final intGets the version of the Java Virtual Machine (JVM) jffi is running on.getName()Gets the name of this Platform.final Platform.OS_TYPEgetOS()Gets the current Operating System.static final PlatformGets the current Platformstatic StringgetProperty(String property, String defValue) An extension overSystem.getPropertymethod.final booleanisBSD()final booleanfinal booleanisUnix()static IRubyObjectlinux_p(ThreadContext context, IRubyObject recv) final intlongSize()Gets the size of a C 'long' on the native platform.static IRubyObjectmac_p(ThreadContext context, IRubyObject recv) mapLibraryName(String libName) static IRubyObjectsolaris_p(ThreadContext context, IRubyObject recv) private static booleanstartsWithIgnoreCase(String s1, String s2) static IRubyObjectunix_p(ThreadContext context, IRubyObject recv) static IRubyObjectwindows_p(ThreadContext context, IRubyObject recv)
-
Field Details
-
LOCALE
-
CPU
-
OS
-
ARCH_DATA_MODEL
private static final int ARCH_DATA_MODEL -
NAME
-
LIBPREFIX
-
LIBSUFFIX
-
LIBC
-
BIG_ENDIAN
public static final int BIG_ENDIAN- See Also:
-
LITTLE_ENDIAN
public static final int LITTLE_ENDIAN- See Also:
-
BYTE_ORDER
public static final int BYTE_ORDER -
addressSize
protected final int addressSize -
longSize
protected final int longSize -
addressMask
private final long addressMask -
libPattern
-
javaVersionMajor
private int javaVersionMajor
-
-
Constructor Details
-
Platform
-
-
Method Details
-
determineOS
-
determinePlatform
-
determineCPU
-
determineLibC
-
determineLibExt
-
determineArchDataModel
private static int determineArchDataModel() -
getPlatform
Gets the current Platform- Returns:
- The current platform.
-
getOS
Gets the current Operating System.- Returns:
- A OS value representing the current Operating System.
-
getCPU
Gets the current processor architecture the JVM is running on.- Returns:
- A CPU value representing the current processor architecture.
-
getJavaMajorVersion
public final int getJavaMajorVersion()Gets the version of the Java Virtual Machine (JVM) jffi is running on.- Returns:
- A number representing the java version. e.g. 8 for java 1.8, 9 for java 9
-
isBSD
public final boolean isBSD() -
isUnix
public final boolean isUnix() -
isSupported
public final boolean isSupported() -
createPlatformModule
-
windows_p
-
mac_p
-
unix_p
-
bsd_p
-
linux_p
-
solaris_p
-
getProperty
An extension overSystem.getPropertymethod. Handles security restrictions, and returns the default value if the access to the property is restricted.- Parameters:
property- The system property name.defValue- The default value.- Returns:
- The value of the system property, or the default value.
-
longSize
public final int longSize()Gets the size of a C 'long' on the native platform.- Returns:
- the size of a long in bits
-
addressSize
public final int addressSize()Gets the size of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
addressMask
public final long addressMask()Gets the 32/64bit mask of a C address/pointer on the native platform.- Returns:
- the size of a pointer in bits
-
getName
Gets the name of this Platform.- Returns:
- The name of this platform.
-
mapLibraryName
-
startsWithIgnoreCase
-