aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/os/Platform.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/common/os/Platform.java')
-rw-r--r--src/java/com/jogamp/common/os/Platform.java148
1 files changed, 74 insertions, 74 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index a01a4b4..896ea56 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,12 +20,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-
+
package com.jogamp.common.os;
import java.net.URI;
@@ -48,7 +48,7 @@ import jogamp.common.os.PlatformPropsImpl;
* Utility class for querying platform specific properties.
* <p>
* Some field declarations and it's static initialization has been delegated
- * to it's super class {@link PlatformPropsImpl} to solve
+ * to it's super class {@link PlatformPropsImpl} to solve
* static initialization interdependencies w/ the GlueGen native library loading
* and it's derived information {@link #getMachineDescription()}, {@link #is32Bit()}, ..<br>
* This mechanism is preferred in this case to avoid synchronization and locking
@@ -56,20 +56,20 @@ import jogamp.common.os.PlatformPropsImpl;
* </p>
*/
public class Platform extends PlatformPropsImpl {
-
+
public enum OSType {
- LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7);
-
+ LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7);
+
public final int id;
OSType(int id){
this.id = id;
}
}
-
+
public enum CPUFamily {
/** AMD/Intel */
- X86( 0x00000000),
+ X86( 0x00000000),
/** ARM */
ARM( 0x00010000),
/** Power PC */
@@ -79,17 +79,17 @@ public class Platform extends PlatformPropsImpl {
/** PA RISC */
PA_RISC(0xFFFF0000),
/** Itanium */
- IA64( 0xFFFF1000);
-
+ IA64( 0xFFFF1000);
+
public final int id;
CPUFamily(int id){
this.id = id;
}
}
-
+
public enum CPUType {
- /** X86 32bit */
+ /** X86 32bit */
X86_32( CPUFamily.X86, 0x0001),
/** X86 64bit */
X86_64( CPUFamily.X86, 0x0002),
@@ -111,72 +111,72 @@ public class Platform extends PlatformPropsImpl {
IA64( CPUFamily.IA64, 0x0000),
/** PA_RISC2_0 */
PA_RISC2_0(CPUFamily.PA_RISC, 0x0001);
-
+
public final int id;
public final CPUFamily family;
-
+
CPUType(CPUFamily type, int id){
this.family = type;
this.id = id;
}
-
+
public CPUFamily getFamily() { return family; }
- }
-
+ }
+
public enum ABIType {
- GENERIC_ABI ( 0x0000 ),
- /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */
+ GENERIC_ABI ( 0x0000 ),
+ /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */
EABI_GNU_ARMEL ( 0x0001 ),
- /** ARM GNU-EABI ARMHF -mfloat-abi=hard */
+ /** ARM GNU-EABI ARMHF -mfloat-abi=hard */
EABI_GNU_ARMHF ( 0x0002 );
-
+
public final int id;
-
+
ABIType(int id){
this.id = id;
- }
+ }
}
-
+
private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache";
-
+
/** fixed basename of JAR file and native library */
- private static final String libBaseName = "gluegen-rt";
-
+ private static final String libBaseName = "gluegen-rt";
+
//
// static initialization order:
//
-
+
/**
- * System property: 'jogamp.gluegen.UseTempJarCache',
+ * System property: 'jogamp.gluegen.UseTempJarCache',
* defaults to true if {@link #OS_TYPE} is not {@link OSType#ANDROID}.
*/
public static final boolean USE_TEMP_JAR_CACHE;
-
+
//
// post loading native lib:
//
-
+
private static final MachineDescription machineDescription;
-
+
private static final boolean is32Bit;
-
+
/** <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */
public static final boolean AWT_AVAILABLE;
-
+
private static final boolean isRunningFromJarURL;
-
+
static {
final boolean[] _isRunningFromJarURL = new boolean[] { false };
final boolean[] _USE_TEMP_JAR_CACHE = new boolean[] { false };
final boolean[] _AWT_AVAILABLE = new boolean[] { false };
-
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
-
+
PlatformPropsImpl.initSingleton(); // documenting the order of static initialization
-
+
final ClassLoader cl = Platform.class.getClassLoader();
-
+
final URI platformClassJarURI;
{
URI _platformClassJarURI = null;
@@ -185,11 +185,11 @@ public class Platform extends PlatformPropsImpl {
} catch (Exception e) { }
platformClassJarURI = _platformClassJarURI;
}
- _isRunningFromJarURL[0] = null != platformClassJarURI;
-
+ _isRunningFromJarURL[0] = null != platformClassJarURI;
+
_USE_TEMP_JAR_CACHE[0] = ( OS_TYPE != OSType.ANDROID ) && ( null != platformClassJarURI ) &&
Debug.getBooleanProperty(useTempJarCachePropName, true, true);
-
+
// load GluegenRT native library
if(_USE_TEMP_JAR_CACHE[0] && TempJarCache.initSingleton()) {
try {
@@ -200,13 +200,13 @@ public class Platform extends PlatformPropsImpl {
}
}
DynamicLibraryBundle.GlueJNILibLoader.loadLibrary(libBaseName, false, cl);
-
+
// JVM bug workaround
JVMUtil.initSingleton(); // requires gluegen-rt, one-time init.
-
+
// AWT Headless determination
if( !Debug.getBooleanProperty("java.awt.headless", true) &&
- ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) &&
+ ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) &&
ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, cl) ) {
try {
_AWT_AVAILABLE[0] = false == ((Boolean)ReflectionUtil.callStaticMethod(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, ReflectionUtil.AWTNames.isHeadlessMethod, null, null, cl)).booleanValue();
@@ -217,7 +217,7 @@ public class Platform extends PlatformPropsImpl {
isRunningFromJarURL = _isRunningFromJarURL[0];
USE_TEMP_JAR_CACHE = _USE_TEMP_JAR_CACHE[0];
AWT_AVAILABLE = _AWT_AVAILABLE[0];
-
+
MachineDescription md = MachineDescriptionRuntime.getRuntime();
if(null == md) {
MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic();
@@ -232,7 +232,7 @@ public class Platform extends PlatformPropsImpl {
}
}
machineDescription = md;
- is32Bit = machineDescription.is32Bit();
+ is32Bit = machineDescription.is32Bit();
}
private Platform() {}
@@ -240,15 +240,15 @@ public class Platform extends PlatformPropsImpl {
/**
* @return true if we're running from a Jar URL, otherwise false
*/
- public static final boolean isRunningFromJarURL() {
+ public static final boolean isRunningFromJarURL() {
return isRunningFromJarURL;
}
-
+
/**
* kick off static initialization of <i>platform property information</i> and <i>native gluegen-rt lib loading</i>
*/
- public static void initSingleton() { }
-
+ public static void initSingleton() { }
+
/**
* Returns true only if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available.
*/
@@ -263,12 +263,12 @@ public class Platform extends PlatformPropsImpl {
* </p>
* <p>
* <i>Note</i>: We claim Android is compatible.
- * </p>
+ * </p>
*/
public static boolean isJava6() {
return JAVA_6;
}
-
+
/**
* Returns true if this machine is little endian, otherwise false.
*/
@@ -283,7 +283,7 @@ public class Platform extends PlatformPropsImpl {
public static String getOSName() {
return OS;
}
-
+
/**
* Returns the OS version.
*/
@@ -312,38 +312,38 @@ public class Platform extends PlatformPropsImpl {
public static OSType getOSType() {
return OS_TYPE;
}
-
+
/**
* Returns the CPU type.
*/
public static CPUFamily getCPUFamily() {
return CPU_ARCH.getFamily();
}
-
+
/**
* Returns the CPU architecture.
*/
public static CPUType getCPUType() {
return CPU_ARCH;
}
-
+
/**
* Returns the (guessed) ABI.
*/
public static ABIType getABIType() {
return ABI_TYPE;
}
-
+
/**
* Returns the GlueGen common name for the currently running OSType and CPUType
* as implemented in the build system in 'gluegen-cpptasks-base.xml'.<br>
- *
+ *
* @see #getOSAndArch(OSType, CPUType)
*/
public static String getOSAndArch() {
return os_and_arch;
}
-
+
/**
* Returns the JAVA vendor.
*/
@@ -357,14 +357,14 @@ public class Platform extends PlatformPropsImpl {
public static String getJavaVMName() {
return JAVA_VM_NAME;
}
-
+
/**
* Returns the JAVA runtime name.
*/
public static String getJavaRuntimeName() {
return JAVA_RUNTIME_NAME;
}
-
+
/**
* Returns the JAVA vendor url.
*/
@@ -417,7 +417,7 @@ public class Platform extends PlatformPropsImpl {
public static MachineDescription getMachineDescription() {
return machineDescription;
}
-
+
/** Returns <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */
public static boolean isAWTAvailable() {
return AWT_AVAILABLE;
@@ -426,23 +426,23 @@ public class Platform extends PlatformPropsImpl {
//
// time / jitter
//
-
- /**
+
+ /**
* Returns the unix based current time in milliseconds, based on <code>gettimeofday(..)</code>.
* <p>
* This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}.
- * While the named {@link System} methods do provide the required precision,
+ * While the named {@link System} methods do provide the required precision,
* <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval.
* </p>
* @see #currentTimeMicros()
*/
public static native long currentTimeMillis();
-
- /**
+
+ /**
* Returns the unix based current time in microseconds, based on <code>gettimeofday(..)</code>.
* <p>
* This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}.
- * While the named {@link System} methods do provide the required precision,
+ * While the named {@link System} methods do provide the required precision,
* <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval.
* </p>
* @see #currentTimeMillis()
@@ -458,7 +458,7 @@ public class Platform extends PlatformPropsImpl {
public static synchronized long getCurrentSleepJitter() {
getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10); // warm-up
return getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10);
- }
+ }
private static long getCurrentSleepJitterImpl(final long nsDuration, final int splitInLoops) {
final long nsPeriod = nsDuration / splitInLoops;
final long t0_ns = System.nanoTime();