diff options
Diffstat (limited to 'src/java/com/jogamp/common')
-rw-r--r-- | src/java/com/jogamp/common/os/AndroidVersion.java | 97 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/MachineDescription.java | 6 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 197 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/VersionUtil.java | 8 |
4 files changed, 175 insertions, 133 deletions
diff --git a/src/java/com/jogamp/common/os/AndroidVersion.java b/src/java/com/jogamp/common/os/AndroidVersion.java index f727a47..840933f 100644 --- a/src/java/com/jogamp/common/os/AndroidVersion.java +++ b/src/java/com/jogamp/common/os/AndroidVersion.java @@ -30,7 +30,6 @@ package com.jogamp.common.os; import java.lang.reflect.Field; import com.jogamp.common.os.Platform.ABIType; -import com.jogamp.common.os.Platform.CPUFamily; import com.jogamp.common.os.Platform.CPUType; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.ReflectionUtil; @@ -67,61 +66,6 @@ public class AndroidVersion { private static final String androidBuildVersion = "android.os.Build$VERSION"; private static final String androidBuildVersionCodes = "android.os.Build$VERSION_CODES"; - /** - * Returns {@link CPUType} for matching <code>cpuABI<code>, - * i.e. {@link #CPU_ABI} or {@link #CPU_ABI2}, - * or <code>null</code> for no match. - * <p> - * FIXME: Where is a comprehensive list of known 'android.os.Build.CPU_ABI' and 'android.os.Build.CPU_ABI2' strings ?<br/> - * Fount this one: <code>http://www.kandroid.org/ndk/docs/CPU-ARCH-ABIS.html</code> - * <pre> - * lib/armeabi/libfoo.so - * lib/armeabi-v7a/libfoo.so - * lib/x86/libfoo.so - * lib/mips/libfoo.so - * </pre> - * </p> - */ - private static final CPUType getCPUTypeImpl(final String cpuABI) { - if( null == cpuABI ) { - return null; - } else if( cpuABI.equals("armv8-a") || - cpuABI.equals("arm64-v8a") ) { - return CPUType.ARMv8_A; - } else if( cpuABI.equals("aarch64") || - cpuABI.startsWith("arm64") ) { - return CPUType.ARM64; - } else if( cpuABI.equals("armeabi-v7a") || - cpuABI.equals("armeabi-v7a-hard") ) { - return CPUType.ARMv7; - } else if( cpuABI.equals("armeabi") || - cpuABI.startsWith("arm") ) { // last 32bit chance .. - return CPUType.ARM; - } else if( cpuABI.equals("x86") ) { - return CPUType.X86_32; - } else if( cpuABI.equals("mips") ) { // no 32bit vs 64bit identifier ? - return CPUType.MIPS_32; - } else { - return null; - } - } - private static final ABIType getABITypeImpl(final CPUType cpuType, final String cpuABI) { - if( null == cpuType || null == cpuABI ) { - return null; - } else if( CPUFamily.ARM == cpuType.family ) { - if( CPUType.ARM64 == cpuType || - CPUType.ARMv8_A == cpuType ) { - return ABIType.EABI_AARCH64; - } else if( cpuABI.equals("armeabi-v7a-hard") ) { - return ABIType.EABI_GNU_ARMHF; - } else { - return ABIType.EABI_GNU_ARMEL; - } - } else { - return ABIType.GENERIC_ABI; - } - } - static { final ClassLoader cl = AndroidVersion.class.getClassLoader(); Class<?> abClass = null; @@ -138,7 +82,7 @@ public class AndroidVersion { abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); abvcObject = abvcClass.newInstance(); } catch (final Exception e) { /* n/a */ } - isAvailable = null != abObject && null != abvObject && null != abvcObject; + isAvailable = null != abObject && null != abvObject; if(isAvailable) { CPU_ABI = getString(abClass, abObject, "CPU_ABI", true); CPU_ABI2 = getString(abClass, abObject, "CPU_ABI2", true); @@ -146,9 +90,36 @@ public class AndroidVersion { INCREMENTAL = getString(abvClass, abvObject, "INCREMENTAL", false); RELEASE = getString(abvClass, abvObject, "RELEASE", false); SDK_INT = getInt(abvClass, abvObject, "SDK_INT"); - final IntObjectHashMap version_codes = getVersionCodes(abvcClass, abvcObject); - final String sdk_name = (String) version_codes.get(SDK_INT); + final String sdk_name; + if( null != abvcObject ) { + final IntObjectHashMap version_codes = getVersionCodes(abvcClass, abvcObject); + sdk_name = (String) version_codes.get(SDK_INT); + } else { + sdk_name = null; + } SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; + + /** + * <p> + * FIXME: Where is a comprehensive list of known 'android.os.Build.CPU_ABI' and 'android.os.Build.CPU_ABI2' strings ?<br/> + * Fount this one: <code>http://www.kandroid.org/ndk/docs/CPU-ARCH-ABIS.html</code> + * <pre> + * lib/armeabi/libfoo.so + * lib/armeabi-v7a/libfoo.so + * lib/x86/libfoo.so + * lib/mips/libfoo.so + * </pre> + * </p> + */ + CPU_TYPE = Platform.CPUType.query(CPU_ABI); + ABI_TYPE = Platform.ABIType.query(CPU_TYPE, CPU_ABI); + if( null != CPU_ABI2 && CPU_ABI2.length() > 0 ) { + CPU_TYPE2 = Platform.CPUType.query(CPU_ABI2); + ABI_TYPE2 = Platform.ABIType.query(CPU_TYPE2, CPU_ABI2); + } else { + CPU_TYPE2 = null; + ABI_TYPE2 = null; + } } else { CPU_ABI = null; CPU_ABI2 = null; @@ -157,11 +128,11 @@ public class AndroidVersion { RELEASE = null; SDK_INT = -1; SDK_NAME = null; + CPU_TYPE = null; + ABI_TYPE = null; + CPU_TYPE2 = null; + ABI_TYPE2 = null; } - CPU_TYPE = getCPUTypeImpl(CPU_ABI); - ABI_TYPE = getABITypeImpl(CPU_TYPE, CPU_ABI); - CPU_TYPE2 = getCPUTypeImpl(CPU_ABI2); - ABI_TYPE2 = getABITypeImpl(CPU_TYPE2, CPU_ABI2); } private static final IntObjectHashMap getVersionCodes(final Class<?> cls, final Object obj) { diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java index 98093d0..2a4627e 100644 --- a/src/java/com/jogamp/common/os/MachineDescription.java +++ b/src/java/com/jogamp/common/os/MachineDescription.java @@ -104,7 +104,7 @@ public class MachineDescription { alignments[j++]); } - public StringBuilder toString(StringBuilder sb) { + public final StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); } @@ -112,7 +112,9 @@ public class MachineDescription { md.toString(sb); return sb; } - + public final String toShortString() { + return this.name()+"("+this.ordinal()+")"; + } @Override public String toString() { return toString(null).toString(); diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 0d00a9a..6f6c99d 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -58,97 +58,186 @@ import jogamp.common.os.PlatformPropsImpl; 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(final int id){ - this.id = id; - } + LINUX, FREEBSD, ANDROID, MACOS, SUNOS, HPUX, WINDOWS, OPENKODE; } public enum CPUFamily { /** AMD/Intel */ - X86( 0x00000000), + X86, /** ARM */ - ARM( 0x00010000), + ARM, /** Power PC */ - PPC( 0x00020000), + PPC, /** SPARC */ - SPARC( 0x00030000), + SPARC, /** Mips */ - MIPS( 0x00040000), + MIPS, /** PA RISC */ - PA_RISC(0xFFFF0000), + PA_RISC, /** Itanium */ - IA64( 0xFFFF1000); - - public final int id; - - CPUFamily(final int id){ - this.id = id; - } + IA64; } public enum CPUType { /** X86 32bit */ - X86_32( CPUFamily.X86, 0x0001, true), + X86_32( CPUFamily.X86, true), /** X86 64bit */ - X86_64( CPUFamily.X86, 0x0002, false), + X86_64( CPUFamily.X86, false), /** ARM 32bit default */ - ARM( CPUFamily.ARM, 0x0000, true), + ARM( CPUFamily.ARM, true), /** ARM7EJ, ARM9E, ARM10E, XScale */ - ARMv5( CPUFamily.ARM, 0x0001, true), + ARMv5( CPUFamily.ARM, true), /** ARM11 */ - ARMv6( CPUFamily.ARM, 0x0002, true), + ARMv6( CPUFamily.ARM, true), /** ARM Cortex */ - ARMv7( CPUFamily.ARM, 0x0004, true), + ARMv7( CPUFamily.ARM, true), /** ARM64 default (64bit) */ - ARM64( CPUFamily.ARM, 0x0008, false), + ARM64( CPUFamily.ARM, false), /** ARM AArch64 (64bit) */ - ARMv8_A( CPUFamily.ARM, 0x0010, false), + ARMv8_A( CPUFamily.ARM, false), /** PPC 32bit default */ - PPC( CPUFamily.PPC, 0x0000, true), + PPC( CPUFamily.PPC, true), + /** PPC 64bit default */ + PPC64( CPUFamily.PPC, false), /** SPARC 32bit */ - SPARC_32( CPUFamily.SPARC, 0x0001, true), + SPARC_32( CPUFamily.SPARC, true), /** SPARC 64bit */ - SPARCV9_64(CPUFamily.SPARC, 0x0002, false), + SPARCV9_64(CPUFamily.SPARC, false), /** MIPS 32bit */ - MIPS_32( CPUFamily.MIPS, 0x0001, true), + MIPS_32( CPUFamily.MIPS, true), /** MIPS 64bit */ - MIPS_64( CPUFamily.MIPS, 0x0002, false), + MIPS_64( CPUFamily.MIPS, false), /** Itanium 64bit default */ - IA64( CPUFamily.IA64, 0x0000, false), + IA64( CPUFamily.IA64, false), /** PA_RISC2_0 64bit */ - PA_RISC2_0(CPUFamily.PA_RISC, 0x0001, false); + PA_RISC2_0(CPUFamily.PA_RISC, false); - public final int id; public final CPUFamily family; public final boolean is32Bit; - CPUType(final CPUFamily type, final int id, final boolean is32Bit){ + CPUType(final CPUFamily type, final boolean is32Bit){ this.family = type; - this.id = id; this.is32Bit = is32Bit; } - public CPUFamily getFamily() { return family; } + /** + * Returns {@code true} if the given {@link CPUType} is compatible + * w/ this one, i.e. at least {@link #family} and {@link #is32Bit} is equal. + */ + public final boolean isCompatible(final CPUType other) { + if( null == other ) { + return false; + } else if( other == this ) { + return true; + } else { + return this.family == other.family && + this.is32Bit == other.is32Bit; + } + } + + public static final CPUType query(final String cpuABILower) { + if( null == cpuABILower ) { + throw new IllegalArgumentException("Null cpuABILower arg"); + } + if( cpuABILower.equals("x86") || + cpuABILower.equals("i386") || + cpuABILower.equals("i486") || + cpuABILower.equals("i586") || + cpuABILower.equals("i686") ) { + return X86_32; + } else if( cpuABILower.equals("x86_64") || + cpuABILower.equals("amd64") ) { + return X86_64; + } else if( cpuABILower.equals("ia64") ) { + return IA64; + } else if( cpuABILower.equals("aarch64") ) { + return ARM64; + } else if( cpuABILower.startsWith("arm") ) { + if( cpuABILower.equals("armv8-a") || + cpuABILower.equals("arm-v8-a") || + cpuABILower.equals("arm-8-a") || + cpuABILower.equals("arm64-v8a") ) { + return ARMv8_A; + } else if( cpuABILower.startsWith("arm64") ) { + return ARM64; + } else if( cpuABILower.startsWith("armv7") || + cpuABILower.startsWith("arm-v7") || + cpuABILower.startsWith("arm-7") || + cpuABILower.startsWith("armeabi-v7") ) { + return ARMv7; + } else if( cpuABILower.startsWith("armv5") || + cpuABILower.startsWith("arm-v5") || + cpuABILower.startsWith("arm-5") ) { + return ARMv5; + } else if( cpuABILower.startsWith("armv6") || + cpuABILower.startsWith("arm-v6") || + cpuABILower.startsWith("arm-6") ) { + return ARMv6; + } else { + return ARM; + } + } else if( cpuABILower.equals("sparcv9") ) { + return SPARCV9_64; + } else if( cpuABILower.equals("sparc") ) { + return SPARC_32; + } else if( cpuABILower.equals("pa_risc2.0") ) { + return PA_RISC2_0; + } else if( cpuABILower.startsWith("ppc64") ) { + return PPC64; + } else if( cpuABILower.startsWith("ppc") ) { + return PPC; + } else if( cpuABILower.startsWith("mips") ) { + return MIPS_32; + } else { + throw new RuntimeException("Please port CPUType detection to your platform (CPU_ABI string '" + cpuABILower + "')"); + } + } } public enum ABIType { - GENERIC_ABI ( 0x0000 ), + GENERIC_ABI ( 0x00 ), /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ - EABI_GNU_ARMEL ( 0x0001 ), + EABI_GNU_ARMEL ( 0x01 ), /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ - EABI_GNU_ARMHF ( 0x0002 ), + EABI_GNU_ARMHF ( 0x02 ), /** ARM EABI AARCH64 (64bit) */ - EABI_AARCH64 ( 0x0003 ); + EABI_AARCH64 ( 0x03 ); public final int id; ABIType(final int id){ this.id = id; } + + /** + * Returns {@code true} if the given {@link ABIType} is compatible + * w/ this one, i.e. they are equal. + */ + public final boolean isCompatible(final ABIType other) { + if( null == other ) { + return false; + } else { + return other == this; + } + } + + public static final ABIType query(final CPUType cpuType, final String cpuABILower) { + if( null == cpuType ) { + throw new IllegalArgumentException("Null cpuType"); + } else if( null == cpuABILower ) { + throw new IllegalArgumentException("Null cpuABILower"); + } else if( CPUFamily.ARM == cpuType.family ) { + if( !cpuType.is32Bit ) { + return EABI_AARCH64; + } else if( cpuABILower.equals("armeabi-v7a-hard") ) { + return EABI_GNU_ARMHF; + } else { + return EABI_GNU_ARMEL; + } + } else { + return GENERIC_ABI; + } + } } private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache"; @@ -261,26 +350,6 @@ public class Platform extends PlatformPropsImpl { public static void initSingleton() { } /** - * Returns true only if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available. - */ - public static boolean isJavaSE() { - return JAVA_SE; - } - - /** - * Returns true only if being compatible w/ language level 6, e.g. JRE 1.6. - * <p> - * Implies {@link #isJavaSE()}. - * </p> - * <p> - * <i>Note</i>: We claim Android is compatible. - * </p> - */ - public static boolean isJava6() { - return JAVA_6; - } - - /** * Returns true if this machine is little endian, otherwise false. */ public static boolean isLittleEndian() { @@ -328,7 +397,7 @@ public class Platform extends PlatformPropsImpl { * Returns the CPU family. */ public static CPUFamily getCPUFamily() { - return CPU_ARCH.getFamily(); + return CPU_ARCH.family; } /** diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 6949d62..aef3fc2 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -58,10 +58,10 @@ public class VersionUtil { // environment sb.append("Platform: ").append(Platform.getOSType()).append(" / ").append(Platform.getOSName()).append(' ').append(Platform.getOSVersion()).append(" (").append(Platform.getOSVersionNumber()).append("), "); - sb.append(Platform.getArchName()).append(" (arch), ").append(Platform.getABIType()).append(", "); + sb.append(Platform.getArchName()).append(" (").append(Platform.getCPUType()).append(", ").append(Platform.getABIType()).append("), "); sb.append(Runtime.getRuntime().availableProcessors()).append(" cores"); sb.append(Platform.getNewline()); - if( AndroidVersion.isAvailable) { + if( Platform.OSType.ANDROID == PlatformPropsImpl.OS_TYPE ) { sb.append("Platform: Android Version: ").append(AndroidVersion.CODENAME).append(", "); sb.append(AndroidVersion.RELEASE).append(" [").append(AndroidVersion.RELEASE).append("], SDK: ").append(AndroidVersion.SDK_INT).append(", ").append(AndroidVersion.SDK_NAME); sb.append(Platform.getNewline()); @@ -73,8 +73,8 @@ public class VersionUtil { sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(" (").append(Platform.getJavaVersionNumber()).append("u").append(PlatformPropsImpl.JAVA_VERSION_UPDATE).append("), VM: ").append(Platform.getJavaVMName()); sb.append(", Runtime: ").append(Platform.getJavaRuntimeName()).append(Platform.getNewline()); sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()); - sb.append(", JavaSE: ").append(Platform.isJavaSE()); - sb.append(", Java6: ").append(Platform.isJava6()); + sb.append(", JavaSE: ").append(PlatformPropsImpl.JAVA_SE); + sb.append(", Java6: ").append(PlatformPropsImpl.JAVA_6); sb.append(", AWT enabled: ").append(Platform.AWT_AVAILABLE); sb.append(Platform.getNewline()).append(SEPERATOR); |