/**
* Copyright 2010 JogAmp Community. All rights reserved.
*
* 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
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.TimeUnit;
import com.jogamp.common.jvm.JNILibLoaderBase;
import com.jogamp.common.util.JarUtil;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.common.util.cache.TempJarCache;
import jogamp.common.Debug;
import jogamp.common.jvm.JVMUtil;
import jogamp.common.os.MachineDescriptionRuntime;
import jogamp.common.os.PlatformPropsImpl;
/**
* Utility class for querying platform specific properties.
*
* Some field declarations and it's static initialization has been delegated
* 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()}, ..
* This mechanism is preferred in this case to avoid synchronization and locking
* and allow better performance accessing the mentioned fields/methods.
*
*/
public class Platform extends PlatformPropsImpl {
public enum OSType {
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),
/** ARM */
ARM( 0x00010000),
/** Power PC */
PPC( 0x00020000),
/** SPARC */
SPARC( 0x00030000),
/** PA RISC */
PA_RISC(0xFFFF0000),
/** Itanium */
IA64( 0xFFFF1000);
public final int id;
CPUFamily(int id){
this.id = id;
}
}
public enum CPUType {
/** X86 32bit */
X86_32( CPUFamily.X86, 0x0001),
/** X86 64bit */
X86_64( CPUFamily.X86, 0x0002),
/** ARM default */
ARM( CPUFamily.ARM, 0x0000),
/** ARM7EJ, ARM9E, ARM10E, XScale */
ARMv5( CPUFamily.ARM, 0x0001),
/** ARM11 */
ARMv6( CPUFamily.ARM, 0x0002),
/** ARM Cortex */
ARMv7( CPUFamily.ARM, 0x0004),
/** PPC default */
PPC( CPUFamily.PPC, 0x0000),
/** SPARC 32bit */
SPARC_32( CPUFamily.SPARC, 0x0001),
/** SPARC 64bit */
SPARCV9_64(CPUFamily.SPARC, 0x0002),
/** Itanium default */
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 */
EABI_GNU_ARMEL ( 0x0001 ),
/** 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";
//
// static initialization order:
//
/**
* 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;
/** true if AWT is available and not in headless mode, otherwise false. */
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