diff options
Diffstat (limited to 'src')
27 files changed, 504 insertions, 373 deletions
diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDataInfo.java index 2a4627e..0192cd8 100644 --- a/src/java/com/jogamp/common/os/MachineDescription.java +++ b/src/java/com/jogamp/common/os/MachineDataInfo.java @@ -43,48 +43,80 @@ package com.jogamp.common.os; import jogamp.common.os.PlatformPropsImpl; /** - * For alignment and size see {@link com.jogamp.gluegen} + * Machine data description for alignment and size onle, see {@link com.jogamp.gluegen}. + * <p> + * {@code little-endian} / {@code big/endian} description is left, + * allowing re-using instances in {@link MachineDataInfo.StaticConfig StaticConfig}. + * Use {@link {@link PlatformPropsImpl#LITTLE_ENDIAN}. + * </p> + * <p> + * Further more, the value {@ MachineDataInfo#pageSizeInBytes} shall be ignored + * in {@link MachineDataInfo.StaticConfig StaticConfig}, see {@link MachineDataInfo#compatible(MachineDataInfo)}. + * </p> */ -public class MachineDescription { +public class MachineDataInfo { /* arch os int, long, float, doubl, ldoubl, ptr, page */ - private final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 }; + private final static int[] size_arm_mips_32 = { 4, 4, 4, 8, 8, 4, 4096 }; private final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 }; private final static int[] size_x86_32_macos = { 4, 4, 4, 8, 16, 4, 4096 }; + private final static int[] size_ppc_32_unix = { 4, 4, 4, 8, 16, 4, 4096 }; + private final static int[] size_sparc_32_sunos = { 4, 4, 4, 8, 16, 4, 8192 }; private final static int[] size_x86_32_windows = { 4, 4, 4, 8, 12, 4, 4096 }; private final static int[] size_lp64_unix = { 4, 8, 4, 8, 16, 8, 4096 }; private final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 }; - private final static int[] size_sparc_32_sunos = { 4, 4, 4, 8, 16, 4, 8192 }; /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ - private final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; + private final static int[] align_arm_mips_32 = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; private final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 }; private final static int[] align_x86_32_macos = { 1, 2, 4, 4, 4, 4, 4, 4, 16, 4 }; + private final static int[] align_ppc_32_unix = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 4 }; + private final static int[] align_sparc_32_sunos = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; private final static int[] align_x86_32_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 4, 4 }; private final static int[] align_lp64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 }; private final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 }; - private final static int[] align_sparc_32_sunos = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; + /** + * Static enumeration of {@link MachineDataInfo} instances + * used for high performance data size and alignment lookups, + * e.g. for generated structures. + * <p> + * The value {@link MachineDataInfo#pageSizeInBytes} shall be ignored + * for static instances! + * </p> + * <p> + * If changing this table, you need to: + * <ul> + * <li>Rebuild GlueGen.</li> + * <li>Run ant {@code build.xml} target {@code generate.os.sources}.</li> + * <li>Rebuild everything.</li> + * </ul> + * .. b/c the generated code for glued structures must reflect this change! + * </p> + */ public enum StaticConfig { - /** {@link Platform.CPUType#ARM} EABI Little Endian */ - ARMle_EABI(true, size_armeabi, align_armeabi), - /** {@link Platform.CPUType#X86_32} Little Endian Unix */ - X86_32_UNIX(true, size_x86_32_unix, align_x86_32_unix), - /** LP64 Unix, e.g.: {@link Platform.CPUType#X86_64} Little Endian Unix, {@link Platform.CPUType#ARM64} EABI Little Endian, ... */ - LP64_UNIX(true, size_lp64_unix, align_lp64_unix), - /** {@link Platform.CPUType#X86_32} Little Endian MacOS (Special case gcc4/OSX) */ - X86_32_MACOS(true, size_x86_32_macos, align_x86_32_macos), - /** {@link Platform.CPUType#X86_32} Little Endian Windows */ - X86_32_WINDOWS(true, size_x86_32_windows, align_x86_32_windows), - /** {@link Platform.CPUType#X86_64} Little Endian Windows */ - X86_64_WINDOWS(true, size_x86_64_windows, align_x86_64_windows), - /** {@link Platform.CPUType#SPARC_32} Big Endian Solaris */ - SPARC_32_SUNOS(false, size_sparc_32_sunos, align_sparc_32_sunos); - - public final MachineDescription md; - - StaticConfig(final boolean littleEndian, final int[] sizes, final int[] alignments) { + /** {@link Platform.CPUType#ARM} or {@link Platform.CPUType#MIPS_32} */ + ARM_MIPS_32( size_arm_mips_32, align_arm_mips_32), + /** {@link Platform.CPUType#X86_32} Unix */ + X86_32_UNIX( size_x86_32_unix, align_x86_32_unix), + /** {@link Platform.CPUType#X86_32} MacOS (Special case gcc4/OSX) */ + X86_32_MACOS( size_x86_32_macos, align_x86_32_macos), + /** {@link Platform.CPUType#PPC} Unix */ + PPC_32_UNIX( size_ppc_32_unix, align_ppc_32_unix), + /** {@link Platform.CPUType#SPARC_32} Solaris */ + SPARC_32_SUNOS( size_sparc_32_sunos, align_sparc_32_sunos), + /** {@link Platform.CPUType#X86_32} Windows */ + X86_32_WINDOWS( size_x86_32_windows, align_x86_32_windows), + /** LP64 Unix, e.g.: {@link Platform.CPUType#X86_64} Unix, {@link Platform.CPUType#ARM64} EABI, {@link Platform.CPUType#PPC64} Unix, .. */ + LP64_UNIX( size_lp64_unix, align_lp64_unix), + /** {@link Platform.CPUType#X86_64} Windows */ + X86_64_WINDOWS( size_x86_64_windows, align_x86_64_windows); + // 8 + + public final MachineDataInfo md; + + StaticConfig(final int[] sizes, final int[] alignments) { int i=0, j=0; - this.md = new MachineDescription(false, littleEndian, + this.md = new MachineDataInfo(false, sizes[i++], sizes[i++], sizes[i++], @@ -108,7 +140,7 @@ public class MachineDescription { if(null==sb) { sb = new StringBuilder(); } - sb.append("MachineDescriptionStatic: ").append(this.name()).append("(").append(this.ordinal()).append("): "); + sb.append("MachineDataInfoStatic: ").append(this.name()).append("(").append(this.ordinal()).append("): "); md.toString(sb); return sb; } @@ -119,13 +151,44 @@ public class MachineDescription { public String toString() { return toString(null).toString(); } - } + /** + * Static's {@link MachineDataInfo} shall be unique by the + * {@link MachineDataInfo#compatible(MachineDataInfo) compatible} criteria. + */ + public static final void validateUniqueMachineDataInfo() { + final StaticConfig[] scs = StaticConfig.values(); + for(int i=scs.length-1; i>=0; i--) { + final StaticConfig a = scs[i]; + for(int j=scs.length-1; j>=0; j--) { + if( i != j ) { + final StaticConfig b = scs[j]; + if( a.md.compatible(b.md) ) { + // oops + final String msg = "Duplicate/Compatible MachineDataInfo in StaticConfigs: Elements ["+i+": "+a.toShortString()+"] and ["+j+": "+b.toShortString()+"]"; + System.err.println(msg); + System.err.println(a); + System.err.println(b); + throw new InternalError(msg); + } + } + } + } + } + public static final StaticConfig findCompatible(final MachineDataInfo md) { + final StaticConfig[] scs = StaticConfig.values(); + for(int i=scs.length-1; i>=0; i--) { + final StaticConfig a = scs[i]; + if( a.md.compatible(md) ) { + return a; + } + } + return null; + } + } final private boolean runtimeValidated; - final private boolean littleEndian; - final private int int8SizeInBytes = 1; final private int int16SizeInBytes = 2; final private int int32SizeInBytes = 4; @@ -150,8 +213,7 @@ public class MachineDescription { final private int ldoubleAlignmentInBytes; final private int pointerAlignmentInBytes; - public MachineDescription(final boolean runtimeValidated, - final boolean littleEndian, + public MachineDataInfo(final boolean runtimeValidated, final int intSizeInBytes, final int longSizeInBytes, @@ -172,7 +234,6 @@ public class MachineDescription { final int ldoubleAlignmentInBytes, final int pointerAlignmentInBytes) { this.runtimeValidated = runtimeValidated; - this.littleEndian = littleEndian; this.intSizeInBytes = intSizeInBytes; this.longSizeInBytes = longSizeInBytes; @@ -201,13 +262,6 @@ public class MachineDescription { return runtimeValidated; } - /** - * Returns true only if this system uses little endian byte ordering. - */ - public final boolean isLittleEndian() { - return littleEndian; - } - public final int intSizeInBytes() { return intSizeInBytes; } public final int longSizeInBytes() { return longSizeInBytes; } public final int int8SizeInBytes() { return int8SizeInBytes; } @@ -247,32 +301,32 @@ public class MachineDescription { /** * Checks whether two size objects are equal. Two instances - * of <code>MachineDescription</code> are considered equal if all components + * of <code>MachineDataInfo</code> are considered equal if all components * match but {@link #runtimeValidated}, {@link #isRuntimeValidated()}. - * @return <code>true</code> if the two MachineDescription are equal; + * @return <code>true</code> if the two MachineDataInfo are equal; * otherwise <code>false</code>. */ @Override public final boolean equals(final Object obj) { if (this == obj) { return true; } - if ( !(obj instanceof MachineDescription) ) { return false; } - final MachineDescription md = (MachineDescription) obj; + if ( !(obj instanceof MachineDataInfo) ) { return false; } + final MachineDataInfo md = (MachineDataInfo) obj; return pageSizeInBytes == md.pageSizeInBytes && compatible(md); } /** - * Checks whether two size objects are equal. Two instances - * of <code>MachineDescription</code> are considered equal if all components + * Checks whether two {@link MachineDataInfo} objects are equal. + * <p> + * Two {@link MachineDataInfo} instances are considered equal if all components * match but {@link #isRuntimeValidated()} and {@link #pageSizeInBytes()}. - * @return <code>true</code> if the two MachineDescription are equal; + * </p> + * @return <code>true</code> if the two {@link MachineDataInfo} are equal; * otherwise <code>false</code>. */ - public final boolean compatible(final MachineDescription md) { - return littleEndian == md.littleEndian && - - intSizeInBytes == md.intSizeInBytes && + public final boolean compatible(final MachineDataInfo md) { + return intSizeInBytes == md.intSizeInBytes && longSizeInBytes == md.longSizeInBytes && floatSizeInBytes == md.floatSizeInBytes && doubleSizeInBytes == md.doubleSizeInBytes && @@ -295,7 +349,7 @@ public class MachineDescription { if(null==sb) { sb = new StringBuilder(); } - sb.append("MachineDescription: runtimeValidated ").append(isRuntimeValidated()).append(", littleEndian ").append(isLittleEndian()).append(", 32Bit ").append(4 == pointerAlignmentInBytes).append(", primitive size / alignment:").append(PlatformPropsImpl.NEWLINE); + sb.append("MachineDataInfo: runtimeValidated ").append(isRuntimeValidated()).append(", 32Bit ").append(4 == pointerAlignmentInBytes).append(", primitive size / alignment:").append(PlatformPropsImpl.NEWLINE); sb.append(" int8 ").append(int8SizeInBytes) .append(" / ").append(int8AlignmentInBytes); sb.append(", int16 ").append(int16SizeInBytes) .append(" / ").append(int16AlignmentInBytes).append(Platform.getNewline()); sb.append(" int ").append(intSizeInBytes) .append(" / ").append(intAlignmentInBytes); diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 6f6c99d..2e63550 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -41,7 +41,7 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.cache.TempJarCache; import jogamp.common.jvm.JVMUtil; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; import jogamp.common.os.PlatformPropsImpl; /** @@ -50,7 +50,7 @@ import jogamp.common.os.PlatformPropsImpl; * 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()}, ..<br> + * and it's derived information {@link #getMachineDataInfo()}, {@link #is32Bit()}, ..<br> * This mechanism is preferred in this case to avoid synchronization and locking * and allow better performance accessing the mentioned fields/methods. * </p> @@ -75,42 +75,51 @@ public class Platform extends PlatformPropsImpl { /** PA RISC */ PA_RISC, /** Itanium */ - IA64; + IA64, + /** Hitachi SuperH */ + SuperH; } public enum CPUType { - /** X86 32bit */ - X86_32( CPUFamily.X86, true), - /** X86 64bit */ - X86_64( CPUFamily.X86, false), - /** ARM 32bit default */ + /** ARM 32bit default, usually little endian */ ARM( CPUFamily.ARM, true), - /** ARM7EJ, ARM9E, ARM10E, XScale */ + /** ARM7EJ, ARM9E, ARM10E, XScale, usually little endian */ ARMv5( CPUFamily.ARM, true), - /** ARM11 */ + /** ARM11, usually little endian */ ARMv6( CPUFamily.ARM, true), - /** ARM Cortex */ + /** ARM Cortex, usually little endian */ ARMv7( CPUFamily.ARM, true), - /** ARM64 default (64bit) */ + // 4 + + /** X86 32bit, little endian */ + X86_32( CPUFamily.X86, true), + /** PPC 32bit default, usually big endian */ + PPC( CPUFamily.PPC, true), + /** MIPS 32bit, big endian (mips) or little endian (mipsel) */ + MIPS_32( CPUFamily.MIPS, true), + /** Hitachi SuperH 32bit default, ??? endian */ + SuperH( CPUFamily.SuperH, true), + /** SPARC 32bit, big endian */ + SPARC_32( CPUFamily.SPARC, true), + // 9 + + /** ARM64 default (64bit), usually little endian */ ARM64( CPUFamily.ARM, false), - /** ARM AArch64 (64bit) */ + /** ARM AArch64 (64bit), usually little endian */ ARMv8_A( CPUFamily.ARM, false), - /** PPC 32bit default */ - PPC( CPUFamily.PPC, true), - /** PPC 64bit default */ + /** X86 64bit, little endian */ + X86_64( CPUFamily.X86, false), + /** PPC 64bit default, usually big endian */ PPC64( CPUFamily.PPC, false), - /** SPARC 32bit */ - SPARC_32( CPUFamily.SPARC, true), - /** SPARC 64bit */ - SPARCV9_64(CPUFamily.SPARC, false), - /** MIPS 32bit */ - MIPS_32( CPUFamily.MIPS, true), - /** MIPS 64bit */ + /** MIPS 64bit, big endian (mips64) or little endian (mipsel64) ? */ MIPS_64( CPUFamily.MIPS, false), - /** Itanium 64bit default */ + /** Itanium 64bit default, little endian */ IA64( CPUFamily.IA64, false), - /** PA_RISC2_0 64bit */ + /** SPARC 64bit, big endian */ + SPARCV9_64(CPUFamily.SPARC, false), + /** PA_RISC2_0 64bit, ??? endian */ PA_RISC2_0(CPUFamily.PA_RISC, false); + // 17 public final CPUFamily family; public final boolean is32Bit; @@ -186,8 +195,12 @@ public class Platform extends PlatformPropsImpl { return PPC64; } else if( cpuABILower.startsWith("ppc") ) { return PPC; + } else if( cpuABILower.startsWith("mips64") ) { + return MIPS_64; } else if( cpuABILower.startsWith("mips") ) { return MIPS_32; + } else if( cpuABILower.startsWith("superh") ) { + return SuperH; } else { throw new RuntimeException("Please port CPUType detection to your platform (CPU_ABI string '" + cpuABILower + "')"); } @@ -259,7 +272,7 @@ public class Platform extends PlatformPropsImpl { // post loading native lib: // - private static final MachineDescription machineDescription; + private static final MachineDataInfo machineDescription; /** <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */ public static final boolean AWT_AVAILABLE; @@ -320,19 +333,11 @@ public class Platform extends PlatformPropsImpl { USE_TEMP_JAR_CACHE = _USE_TEMP_JAR_CACHE[0]; AWT_AVAILABLE = _AWT_AVAILABLE[0]; - final MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic(); - MachineDescription md = MachineDescriptionRuntime.getRuntime(); - if(null == md) { - md = smd.md; - System.err.println("Warning: Using static MachineDescription: "+smd); - } else { - if(!md.compatible(smd.md)) { - throw new RuntimeException("Incompatible MachineDescriptions:"+PlatformPropsImpl.NEWLINE+ - " Static "+smd+PlatformPropsImpl.NEWLINE+ - " Runtime "+md); - } - } - machineDescription = md; + // + // Validate and setup MachineDataInfo.StaticConfig + // + MachineDataInfoRuntime.initialize(); + machineDescription = MachineDataInfoRuntime.getRuntime(); } private Platform() {} @@ -496,9 +501,9 @@ public class Platform extends PlatformPropsImpl { } /** - * Returns the MachineDescription of the running machine. + * Returns the MachineDataInfo of the running machine. */ - public static MachineDescription getMachineDescription() { + public static MachineDataInfo getMachineDataInfo() { return machineDescription; } diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 1fd7cbf..c773b21 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -54,7 +54,7 @@ import jogamp.common.os.PlatformPropsImpl; import com.jogamp.common.net.AssetURLContext; import com.jogamp.common.net.Uri; import com.jogamp.common.nio.Buffers; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; public class IOUtil { @@ -160,14 +160,14 @@ public class IOUtil { * @throws IOException */ public static int copyStream2Stream(final InputStream in, final OutputStream out, final int totalNumBytes) throws IOException { - return copyStream2Stream(Platform.getMachineDescription().pageSizeInBytes(), in, out, totalNumBytes); + return copyStream2Stream(Platform.getMachineDataInfo().pageSizeInBytes(), in, out, totalNumBytes); } /** * Copy the specified input stream to the specified output stream. The total * number of bytes written is returned. * - * @param bufferSize the intermediate buffer size, should be {@link MachineDescription#pageSizeInBytes()} for best performance. + * @param bufferSize the intermediate buffer size, should be {@link MachineDataInfo#pageSizeInBytes()} for best performance. * @param in the source * @param out the destination * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown @@ -246,7 +246,7 @@ public class IOUtil { if( initialCapacity < avail ) { initialCapacity = avail; } - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDataInfo machine = Platform.getMachineDataInfo(); ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize( initialCapacity ) ); final byte[] chunk = new byte[machine.pageSizeInBytes()]; int chunk2Read = Math.min(machine.pageSizeInBytes(), avail); diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index aef3fc2..6fec8fa 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -59,7 +59,7 @@ 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(" (").append(Platform.getCPUType()).append(", ").append(Platform.getABIType()).append("), "); - sb.append(Runtime.getRuntime().availableProcessors()).append(" cores"); + sb.append(Runtime.getRuntime().availableProcessors()).append(" cores, ").append("littleEndian ").append(PlatformPropsImpl.LITTLE_ENDIAN); sb.append(Platform.getNewline()); if( Platform.OSType.ANDROID == PlatformPropsImpl.OS_TYPE ) { sb.append("Platform: Android Version: ").append(AndroidVersion.CODENAME).append(", "); @@ -67,7 +67,7 @@ public class VersionUtil { sb.append(Platform.getNewline()); } - Platform.getMachineDescription().toString(sb).append(Platform.getNewline()); + Platform.getMachineDataInfo().toString(sb).append(Platform.getNewline()); // JVM/JRE sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(" (").append(Platform.getJavaVersionNumber()).append("u").append(PlatformPropsImpl.JAVA_VERSION_UPDATE).append("), VM: ").append(Platform.getJavaVMName()); diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java index 5673aac..93a1ecc 100644 --- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java +++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java @@ -43,7 +43,7 @@ import java.util.*; import java.io.*; import java.text.MessageFormat; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.gluegen.cgram.types.*; import java.util.logging.Logger; @@ -109,7 +109,7 @@ public class CMethodBindingEmitter extends FunctionEmitter { protected static final String STRING_CHARS_PREFIX = "_strchars_"; // We need this in order to compute sizes of certain types - protected MachineDescription machDesc; + protected MachineDataInfo machDesc; /** * Constructs an emitter for the specified binding, and sets a default @@ -124,7 +124,7 @@ public class CMethodBindingEmitter extends FunctionEmitter { final boolean isJavaMethodStatic, final boolean forImplementingMethodCall, final boolean forIndirectBufferAndArrayImplementation, - final MachineDescription machDesc) + final MachineDataInfo machDesc) { super(output, false); @@ -289,7 +289,7 @@ public class CMethodBindingEmitter extends FunctionEmitter { /** * Used for certain internal type size computations */ - public final MachineDescription getMachineDescription() { return machDesc; } + public final MachineDataInfo getMachineDataInfo() { return machDesc; } @Override diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java index 3924ec2..346920d 100644 --- a/src/java/com/jogamp/gluegen/JavaConfiguration.java +++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java @@ -54,7 +54,7 @@ import com.jogamp.gluegen.cgram.types.*; import java.util.logging.Logger; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; import static java.util.logging.Level.*; import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*; import static com.jogamp.gluegen.JavaEmitter.EmissionStyle.*; @@ -166,7 +166,7 @@ public class JavaConfiguration { private final Map<String, String> structPackages = new HashMap<String, String>(); private final List<String> customCCode = new ArrayList<String>(); private final List<String> forcedStructs = new ArrayList<String>(); - private final Map<String, String> structMachineDescriptorIndex = new HashMap<String, String>(); + private final Map<String, String> structMachineDataInfoIndex = new HashMap<String, String>(); private final Map<String, String> returnValueCapacities = new HashMap<String, String>(); private final Map<String, String> returnValueLengths = new HashMap<String, String>(); private final Map<String, List<String>> temporaryCVariableDeclarations = new HashMap<String, List<String>>(); @@ -650,12 +650,12 @@ public class JavaConfiguration { * <p> * If undefined, code generation uses the default expression: * <pre> - * private static final int mdIdx = MachineDescriptionRuntime.getStatic().ordinal(); + * private static final int mdIdx = MachineDataInfoRuntime.getStatic().ordinal(); * </pre> * </p> */ - public String returnStructMachineDescriptorIndex(final String structName) { - return structMachineDescriptorIndex.get(structName); + public String returnStructMachineDataInfoIndex(final String structName) { + return structMachineDataInfoIndex.get(structName); } /** @@ -1123,8 +1123,8 @@ public class JavaConfiguration { readTemporaryCVariableAssignment(tok, filename, lineNo); // Warning: make sure delimiters are reset at the top of this loop // because TemporaryCVariableAssignment changes them. - } else if (cmd.equalsIgnoreCase("StructMachineDescriptorIndex")) { - readStructMachineDescriptorIndex(tok, filename, lineNo); + } else if (cmd.equalsIgnoreCase("StructMachineDataInfoIndex")) { + readStructMachineDataInfoIndex(tok, filename, lineNo); // Warning: make sure delimiters are reset at the top of this loop // because StructMachineDescriptorIndex changes them. } else if (cmd.equalsIgnoreCase("ReturnValueCapacity")) { @@ -1525,14 +1525,14 @@ public class JavaConfiguration { } } - protected void readStructMachineDescriptorIndex(final StringTokenizer tok, final String filename, final int lineNo) { + protected void readStructMachineDataInfoIndex(final StringTokenizer tok, final String filename, final int lineNo) { try { final String structName = tok.nextToken(); String restOfLine = tok.nextToken("\n\r\f"); restOfLine = restOfLine.trim(); - structMachineDescriptorIndex.put(structName, restOfLine); + structMachineDataInfoIndex.put(structName, restOfLine); } catch (final NoSuchElementException e) { - throw new RuntimeException("Error parsing \"StructMachineDescriptorIndex\" command at line " + lineNo + + throw new RuntimeException("Error parsing \"StructMachineDataInfoIndex\" command at line " + lineNo + " in file \"" + filename + "\"", e); } } diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index 48c7047..d2dc4ba 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -42,7 +42,7 @@ package com.jogamp.gluegen; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.DynamicLookupHelper; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import java.io.*; import java.util.*; @@ -53,7 +53,7 @@ import com.jogamp.gluegen.cgram.types.*; import java.nio.Buffer; import java.util.logging.Logger; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; import static java.util.logging.Level.*; import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*; @@ -100,8 +100,8 @@ public class JavaEmitter implements GlueEmitter { private PrintWriter javaWriter; // Emits either interface or, in AllStatic mode, everything private PrintWriter javaImplWriter; // Only used in non-AllStatic modes for impl class private PrintWriter cWriter; - private final MachineDescription machDescJava = MachineDescription.StaticConfig.LP64_UNIX.md; - private final MachineDescription.StaticConfig[] machDescTargetConfigs = MachineDescription.StaticConfig.values(); + private final MachineDataInfo machDescJava = MachineDataInfo.StaticConfig.LP64_UNIX.md; + private final MachineDataInfo.StaticConfig[] machDescTargetConfigs = MachineDataInfo.StaticConfig.values(); protected final static Logger LOG = Logger.getLogger(JavaEmitter.class.getPackage().getName()); @@ -858,7 +858,7 @@ public class JavaEmitter implements GlueEmitter { this.requiresStaticInitialization = false; // reset - // machDescJava global MachineDescription is the one used to determine + // machDescJava global MachineDataInfo is the one used to determine // the sizes of the primitive types seen in the public API in Java. // For example, if a C long is an element of a struct, it is the size // of a Java int on a 32-bit machine but the size of a Java long @@ -868,11 +868,11 @@ public class JavaEmitter implements GlueEmitter { // implementation on a 32-bit platform must downcast this to an // int and set only an int's worth of data in the struct. // - // The machDescTarget MachineDescription is the one used to determine how + // The machDescTarget MachineDataInfo is the one used to determine how // much data to set in or get from the struct and exactly from // where it comes. // - // Note that machDescJava MachineDescription is always 64bit unix, + // Note that machDescJava MachineDataInfo is always 64bit unix, // which complies w/ Java types. boolean needsNativeCode = false; @@ -935,7 +935,7 @@ public class JavaEmitter implements GlueEmitter { javaWriter.println("import " + cfg.gluegenRuntimePackage() + ".*;"); javaWriter.println("import " + DynamicLookupHelper.class.getPackage().getName() + ".*;"); javaWriter.println("import " + Buffers.class.getPackage().getName() + ".*;"); - javaWriter.println("import " + MachineDescriptionRuntime.class.getName() + ";"); + javaWriter.println("import " + MachineDataInfoRuntime.class.getName() + ";"); javaWriter.println(); final List<String> imports = cfg.imports(); for (final String str : imports) { @@ -963,10 +963,10 @@ public class JavaEmitter implements GlueEmitter { javaWriter.println(); javaWriter.println(" StructAccessor accessor;"); javaWriter.println(); - final String cfgMachDescrIdxCode = cfg.returnStructMachineDescriptorIndex(containingJTypeName); - final String machDescrIdxCode = null != cfgMachDescrIdxCode ? cfgMachDescrIdxCode : "private static final int mdIdx = MachineDescriptionRuntime.getStatic().ordinal();"; + final String cfgMachDescrIdxCode = cfg.returnStructMachineDataInfoIndex(containingJTypeName); + final String machDescrIdxCode = null != cfgMachDescrIdxCode ? cfgMachDescrIdxCode : "private static final int mdIdx = MachineDataInfoRuntime.getStatic().ordinal();"; javaWriter.println(" "+machDescrIdxCode); - javaWriter.println(" private final MachineDescription md;"); + javaWriter.println(" private final MachineDataInfo md;"); javaWriter.println(); // generate all offset and size arrays generateOffsetAndSizeArrays(javaWriter, " ", containingJTypeName, structCType, null, null); /* w/o offset */ @@ -1058,7 +1058,7 @@ public class JavaEmitter implements GlueEmitter { } if( !cfg.manuallyImplement(JavaConfiguration.canonicalStructFieldSymbol(containingJTypeName, containingJTypeName)) ) { javaWriter.println(" " + containingJTypeName + "(java.nio.ByteBuffer buf) {"); - javaWriter.println(" md = MachineDescription.StaticConfig.values()[mdIdx].md;"); + javaWriter.println(" md = MachineDataInfo.StaticConfig.values()[mdIdx].md;"); javaWriter.println(" accessor = new StructAccessor(buf);"); javaWriter.println(" }"); javaWriter.println(); @@ -1948,7 +1948,7 @@ public class JavaEmitter implements GlueEmitter { } private static final boolean DEBUG_TYPEC2JAVA = false; - private JavaType typeToJavaType(final Type cType, final MachineDescription curMachDesc) { + private JavaType typeToJavaType(final Type cType, final MachineDataInfo curMachDesc) { final JavaType jt = typeToJavaTypeImpl(cType, curMachDesc); if( DEBUG_TYPEC2JAVA ) { System.err.println("typeToJavaType: "+cType.getDebugString()+" -> "+jt.getDebugString()); @@ -1961,7 +1961,7 @@ public class JavaEmitter implements GlueEmitter { (opt.getTargetType().getName() != null) && (opt.getTargetType().getName().equals("JNIEnv")); } - private JavaType typeToJavaTypeImpl(final Type cType, final MachineDescription curMachDesc) { + private JavaType typeToJavaTypeImpl(final Type cType, final MachineDataInfo curMachDesc) { // Recognize JNIEnv* case up front if( isJNIEnvPointer(cType) ) { return JavaType.createForJNIEnv(); @@ -2194,7 +2194,7 @@ public class JavaEmitter implements GlueEmitter { private String compatiblePrimitiveJavaTypeName(final Type fieldType, final JavaType javaType, - final MachineDescription curMachDesc) { + final MachineDataInfo curMachDesc) { final Class<?> c = javaType.getJavaClass(); if (!isIntegerType(c)) { // FIXME @@ -2583,7 +2583,7 @@ public class JavaEmitter implements GlueEmitter { private MethodBinding bindFunction(final FunctionSymbol sym, final JavaType containingType, final Type containingCType, - final MachineDescription curMachDesc) { + final MachineDataInfo curMachDesc) { final MethodBinding binding = new MethodBinding(sym, containingType, containingCType); diff --git a/src/java/com/jogamp/gluegen/cgram/types/Field.java b/src/java/com/jogamp/gluegen/cgram/types/Field.java index afaeade..858d81a 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/Field.java +++ b/src/java/com/jogamp/gluegen/cgram/types/Field.java @@ -39,7 +39,7 @@ package com.jogamp.gluegen.cgram.types; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; /** Represents a field in a struct or union. */ @@ -83,8 +83,8 @@ public class Field { public SizeThunk getOffset() { return offset; } /** Offset, in bytes, of this field in the containing data structure - given the specified MachineDescription. */ - public long getOffset(final MachineDescription machDesc) { return offset.computeSize(machDesc); } + given the specified MachineDataInfo. */ + public long getOffset(final MachineDataInfo machDesc) { return offset.computeSize(machDesc); } /** Sets the offset of this field in the containing data structure. */ public void setOffset(final SizeThunk offset) { this.offset = offset; } diff --git a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java index c13e5d5..9843d6b 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java +++ b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java @@ -40,7 +40,7 @@ package com.jogamp.gluegen.cgram.types; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; /** Provides a level of indirection between the definition of a type's size and the absolute value of this size. Necessary when @@ -64,104 +64,104 @@ public abstract class SizeThunk implements Cloneable { public final boolean hasFixedNativeSize() { return fixedNativeSize; } - public abstract long computeSize(MachineDescription machDesc); - public abstract long computeAlignment(MachineDescription machDesc); + public abstract long computeSize(MachineDataInfo machDesc); + public abstract long computeAlignment(MachineDataInfo machDesc); public static final SizeThunk INT8 = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.int8SizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.int8AlignmentInBytes(); } }; public static final SizeThunk INT16 = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.int16SizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.int16AlignmentInBytes(); } }; public static final SizeThunk INT32 = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.int32SizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.int32AlignmentInBytes(); } }; public static final SizeThunk INTxx = new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.intSizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.intAlignmentInBytes(); } }; public static final SizeThunk LONG = new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.longSizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.longAlignmentInBytes(); } }; public static final SizeThunk INT64 = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.int64SizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.int64AlignmentInBytes(); } }; public static final SizeThunk FLOAT = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.floatSizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.floatAlignmentInBytes(); } }; public static final SizeThunk DOUBLE = new SizeThunk(true) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.doubleSizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.doubleAlignmentInBytes(); } }; public static final SizeThunk POINTER = new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return machDesc.pointerSizeInBytes(); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return machDesc.pointerAlignmentInBytes(); } }; @@ -172,11 +172,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return thunk1.computeSize(machDesc) + thunk2.computeSize(machDesc); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -188,11 +188,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return thunk1.computeSize(machDesc) * thunk2.computeSize(machDesc); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -204,22 +204,37 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk alignmentThunk) { return new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { - // x % 2n == x & (2n - 1) - // remainder = net_size & ( alignment - 1 ) - // padding = alignment - remainder ; - // aligned_size = net_size + padding ; + public long computeSize(final MachineDataInfo machDesc) { + /** + * padding = ( alignment - ( net_size % alignment ) ) % alignment ; + * aligned_size = net_size + padding ; + * + * With x % 2n == x & (2n - 1) + * + * Either: + * remainder = net_size & ( alignment - 1 ) + * padding = ( remainder > 0 ) ? alignment - remainder ; + * aligned_size = net_size + padding ; + * + * Or: + * padding = ( alignment - ( net_size & ( alignment - 1 ) ) ) & ( alignment - 1 ); + * aligned_size = net_size + padding ; + * + */ - final long size = offsetThunk.computeSize(machDesc); + final long net_size = offsetThunk.computeSize(machDesc); final long alignment = alignmentThunk.computeAlignment(machDesc); - final long remainder = size & ( alignment - 1 ) ; + /** + final long remainder = net_size & ( alignment - 1 ) ; final long padding = (remainder > 0) ? alignment - remainder : 0; - return size + padding; + */ + final long padding = ( alignment - ( net_size & ( alignment - 1 ) ) ) & ( alignment - 1 ); + return net_size + padding; } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { final long thunk1A = offsetThunk.computeAlignment(machDesc); final long thunk2A = alignmentThunk.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -231,11 +246,11 @@ public abstract class SizeThunk implements Cloneable { final SizeThunk thunk2) { return new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return Math.max(thunk1.computeSize(machDesc), thunk2.computeSize(machDesc)); } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { final long thunk1A = thunk1.computeAlignment(machDesc); final long thunk2A = thunk2.computeAlignment(machDesc); return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ; @@ -246,11 +261,11 @@ public abstract class SizeThunk implements Cloneable { public static SizeThunk constant(final int constant) { return new SizeThunk(false) { @Override - public long computeSize(final MachineDescription machDesc) { + public long computeSize(final MachineDataInfo machDesc) { return constant; } @Override - public long computeAlignment(final MachineDescription machDesc) { + public long computeAlignment(final MachineDataInfo machDesc) { return 1; // no alignment for constants } }; diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java index 9d1a293..86f1ae1 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java +++ b/src/java/com/jogamp/gluegen/cgram/types/StructLayout.java @@ -40,7 +40,7 @@ package com.jogamp.gluegen.cgram.types; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.gluegen.GlueGen; /** Encapsulates algorithm for laying out data structures. Note that @@ -67,9 +67,9 @@ public class StructLayout { SizeThunk curOffset = SizeThunk.constant(baseOffset); SizeThunk maxSize = SizeThunk.constant(0); - final MachineDescription dbgMD; + final MachineDataInfo dbgMD; if( GlueGen.debug() ) { - dbgMD = MachineDescription.StaticConfig.LP64_UNIX.md; + dbgMD = MachineDataInfo.StaticConfig.LP64_UNIX.md; System.err.printf("SL.__: o %03d, s %03d, t %s{%d}%n", curOffset.computeSize(dbgMD), 0, t, t.getNumFields()); } else { dbgMD = null; diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java index 63890a1..28ba6b4 100644 --- a/src/java/com/jogamp/gluegen/cgram/types/Type.java +++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java @@ -42,7 +42,7 @@ package com.jogamp.gluegen.cgram.types; import java.util.List; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; /** Models a C type. Primitive types include int, float, and double. All types have an associated name. Structs and unions are @@ -112,7 +112,7 @@ public abstract class Type implements Cloneable { { long _mdSize = -1; try { - _mdSize = size.computeSize(MachineDescription.StaticConfig.LP64_UNIX.md); + _mdSize = size.computeSize(MachineDataInfo.StaticConfig.LP64_UNIX.md); } catch (final Exception e) {} mdSize = _mdSize; } @@ -180,8 +180,8 @@ public abstract class Type implements Cloneable { /** SizeThunk which computes size of this type in bytes. */ public SizeThunk getSize() { return size; } - /** Size of this type in bytes according to the given MachineDescription. */ - public long getSize(final MachineDescription machDesc) { + /** Size of this type in bytes according to the given MachineDataInfo. */ + public long getSize(final MachineDataInfo machDesc) { final SizeThunk thunk = getSize(); if (thunk == null) { throw new RuntimeException("No size set for type \"" + getName() + "\""); diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html index 2b4f1fa..689fa05 100644 --- a/src/java/com/jogamp/gluegen/package.html +++ b/src/java/com/jogamp/gluegen/package.html @@ -60,13 +60,23 @@ </ul> <h5>Simple alignment arithmetic</h5> - <blockquote>remainder = offset % alignment</blockquote> - since alignment is a multiple of 2 <code>-> x % 2n == x & (2n - 1)</code><br> - <blockquote>remainder = offset & ( alignment - 1 )</blockquote> + Modulo operation, where the 2nd handles the case offset == alignment: <blockquote> - padding = (remainder > 0) ? alignment - remainder : 0 ;<br> + padding = ( alignment - ( offset % alignment ) ) % alignment ; <br> + aligned_offset = offset + padding ; + </blockquote> + Optimization utilizing alignment as a multiple of 2 <code>-> x % 2n == x & ( 2n - 1 )</code><br> + <blockquote> + remainder = offset & ( alignment - 1 ) ; <br> + padding = ( remainder > 0 ) ? alignment - remainder : 0 ;<br> + aligned_offset = offset + padding ; + </blockquote> + Without branching, using the 2nd modulo operation for the case offset == alignment: + <blockquote> + padding = ( alignment - ( offset & ( alignment - 1 ) ) ) & ( alignment - 1 ) ;<br> aligned_offset = offset + padding ; </blockquote> + See <code>com.jogamp.gluegen.cgram.types.SizeThunk.align(..)</code>. <h5>Type Size & Alignment for x86, x86_64, armv6l-32bit-eabi and Window(mingw/mingw64)</h5> Runtime query is implemented as follows: diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java index 351e0cd..5c059c9 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java @@ -76,7 +76,7 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter { methodToWrap.getIsJavaMethodStatic(), true, methodToWrap.forIndirectBufferAndArrayImplementation(), - methodToWrap.getMachineDescription() + methodToWrap.getMachineDataInfo() ); if (methodToWrap.getReturnValueCapacityExpression() != null) { diff --git a/src/java/jogamp/common/os/MachineDescriptionRuntime.java b/src/java/jogamp/common/os/MachineDataInfoRuntime.java index 9becd21..af90cc5 100644 --- a/src/java/jogamp/common/os/MachineDescriptionRuntime.java +++ b/src/java/jogamp/common/os/MachineDataInfoRuntime.java @@ -28,76 +28,98 @@ package jogamp.common.os; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; -import com.jogamp.common.os.MachineDescription.StaticConfig; +import com.jogamp.common.os.MachineDataInfo.StaticConfig; /** - * Runtime MachineDescription + * Runtime operations of {@link MachineDataInfo}. */ -public class MachineDescriptionRuntime { - - static volatile boolean smdHardQueried = false; - static MachineDescription.StaticConfig smdHard = null; - - static volatile boolean smdSoftQueried = false; - static MachineDescription.StaticConfig smdSoft = null; - - public static MachineDescription.StaticConfig getStatic() { - if(!smdHardQueried) { - synchronized(MachineDescription.class) { // volatile dbl-checked-locking OK - if(!smdHardQueried) { - smdHard = get(PlatformPropsImpl.OS_TYPE, PlatformPropsImpl.CPU_ARCH, PlatformPropsImpl.LITTLE_ENDIAN); - smdHardQueried=true; +public class MachineDataInfoRuntime { + + static volatile boolean initialized = false; + static volatile MachineDataInfo runtimeMD = null; + static volatile MachineDataInfo.StaticConfig staticMD = null; + + public static void initialize() { + if( !initialized ) { + synchronized(MachineDataInfo.class) { // volatile dbl-checked-locking OK + if( !initialized ) { + MachineDataInfo.StaticConfig.validateUniqueMachineDataInfo(); + + final MachineDataInfo runtimeMD = getRuntimeImpl(); + final MachineDataInfo.StaticConfig staticMD = MachineDataInfo.StaticConfig.findCompatible(runtimeMD); + if( null == staticMD ) { + throw new RuntimeException("No compatible MachineDataInfo.StaticConfig for runtime:"+PlatformPropsImpl.NEWLINE+runtimeMD); + } + if( !staticMD.md.compatible(runtimeMD) ) { + throw new RuntimeException("Incompatible MachineDataInfo:"+PlatformPropsImpl.NEWLINE+ + " Static "+staticMD+PlatformPropsImpl.NEWLINE+ + " Runtime "+runtimeMD); + } + MachineDataInfoRuntime.runtimeMD = runtimeMD; + MachineDataInfoRuntime.staticMD = staticMD; + initialized=true; if( PlatformPropsImpl.DEBUG ) { - System.err.println("MachineDescription.StaticConfig.getStatic_Hard(os "+PlatformPropsImpl.OS_TYPE+", CpuType "+PlatformPropsImpl.CPU_ARCH+", little "+PlatformPropsImpl.LITTLE_ENDIAN+"): "+smdHard.toShortString()); + System.err.println("MachineDataInfoRuntime.initialize():"+PlatformPropsImpl.NEWLINE+ + " Static "+staticMD+PlatformPropsImpl.NEWLINE+ + " Runtime "+runtimeMD); } + return; + } + } + } + throw new InternalError("Already initialized"); + } + public static MachineDataInfo.StaticConfig getStatic() { + if(!initialized) { + synchronized(MachineDataInfo.class) { // volatile dbl-checked-locking OK + if(!initialized) { + throw new InternalError("Not set"); } } } - return smdHard; + return staticMD; + } + public static MachineDataInfo getRuntime() { + if(!initialized) { + synchronized(MachineDataInfo.class) { // volatile dbl-checked-locking OK + if(!initialized) { + throw new InternalError("Not set"); + } + } + } + return runtimeMD; } - public static MachineDescription.StaticConfig get(final Platform.OSType osType, final Platform.CPUType cpuType, final boolean littleEndian) { + public static MachineDataInfo.StaticConfig guessStaticMachineDataInfo(final Platform.OSType osType, final Platform.CPUType cpuType) { if( cpuType.is32Bit ) { - if( cpuType.family == Platform.CPUFamily.ARM && littleEndian) { - return StaticConfig.ARMle_EABI; - } else if( osType == Platform.OSType.WINDOWS ) { + if( Platform.CPUFamily.ARM == cpuType.family || + Platform.CPUType.MIPS_32 == cpuType ) { + return StaticConfig.ARM_MIPS_32; + } else if( Platform.OSType.WINDOWS == osType ) { return StaticConfig.X86_32_WINDOWS; - } else if( osType == Platform.OSType.MACOS ) { + } else if( Platform.OSType.MACOS == osType ) { return StaticConfig.X86_32_MACOS; - } else if ( osType == Platform.OSType.SUNOS ) { - if ( cpuType == Platform.CPUType.SPARC_32 ) { - return StaticConfig.SPARC_32_SUNOS; - } - // TODO SPARCv9 description is missing + } else if ( Platform.OSType.SUNOS == osType && + Platform.CPUType.SPARC_32 == cpuType ) { + return StaticConfig.SPARC_32_SUNOS; + } else if ( Platform.CPUType.PPC == cpuType ) { + return StaticConfig.PPC_32_UNIX; + } else { + return StaticConfig.X86_32_UNIX; } - return StaticConfig.X86_32_UNIX; } else { if( osType == Platform.OSType.WINDOWS ) { return StaticConfig.X86_64_WINDOWS; } else { - // for all 64bit unix types (x86_64, aarch64, ..) + // for all 64bit unix types (x86_64, aarch64, sparcv9, ..) return StaticConfig.LP64_UNIX; } } } - static volatile boolean rmdQueried = false; - static MachineDescription rmd = null; - - public static MachineDescription getRuntime() { - if(!rmdQueried) { - synchronized(MachineDescription.class) { // volatile dbl-checked-locking OK - if(!rmdQueried) { - rmd = getRuntimeImpl(); - rmdQueried=true; - } - } - } - return rmd; - } - private static MachineDescription getRuntimeImpl() { + private static MachineDataInfo getRuntimeImpl() { try { Platform.initSingleton(); // loads native gluegen-rt library } catch (final UnsatisfiedLinkError err) { @@ -120,8 +142,8 @@ public class MachineDescriptionRuntime { // size: int, long, float, double, pointer, pageSize // alignment: int8, int16, int32, int64, int, long, float, double, pointer - return new MachineDescription( - true /* runtime validated */, PlatformPropsImpl.LITTLE_ENDIAN, + return new MachineDataInfo( + true /* runtime validated */, getSizeOfIntImpl(), getSizeOfLongImpl(), getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(), diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java index b35533f..0d0063c 100644 --- a/src/java/jogamp/common/os/PlatformPropsImpl.java +++ b/src/java/jogamp/common/os/PlatformPropsImpl.java @@ -140,15 +140,6 @@ public abstract class PlatformPropsImpl { OS_TYPE = getOSTypeImpl(OS_lower, isAndroid); // Hard values, i.e. w/ probing binaries - // - // FIXME / HACK: - // We use preCpuType for MachineDescriptionRuntime.getStatic() - // until we have determined the final CPU_TYPE, etc. - // MachineDescriptionRuntime gets notified via MachineDescriptionRuntime.notifyPropsInitialized() below. - // - // We could use Elf Ehdr's machine value to determine the bit-size - // used for it's offset table! - // However, 'os.arch' should be a good guess for this task. final String elfCpuName; final CPUType elfCpuType; final ABIType elfABIType; @@ -324,7 +315,7 @@ public abstract class PlatformPropsImpl { if( DEBUG ) { System.err.println("Platform.Hard: ARCH "+ARCH+", CPU_ARCH "+CPU_ARCH+", ABI_TYPE "+ABI_TYPE+" - strategy "+strategy+"(isAndroid "+isAndroid+", elfValid "+elfValid+")"); } - os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE); + os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE, LITTLE_ENDIAN); } protected PlatformPropsImpl() {} @@ -504,20 +495,34 @@ public abstract class PlatformPropsImpl { public static void initSingleton() { } /** - * Returns the GlueGen common name for the given OSType and CPUType - * as implemented in the build system in 'gluegen-cpptasks-base.xml'.<br> + * Returns the GlueGen common name for the given + * {@link OSType}, {@link CPUType}, {@link ABIType} and {@code littleEndian}. + * <p> + * Consult 'gluegen/make/gluegen-cpptasks-base.xml' to complete/sync mapping! + * </p> * - * A list of currently supported <code>os.and.arch</code> strings: + * An excerpt of supported <code>os.and.arch</code> strings: * <ul> + * <li>android-armv6</li> + * <li>android-aarch64</li> + * <li>linux-armv6</li> + * <li>linux-armv6hf</li> + * <li>linux-i586</li> + * <li>linux-ppc</li> + * <li>linux-mips</li> + * <li>linux-mipsel</li> + * <li>linux-superh</li> + * <li>linux-sparc</li> + * <li>linux-aarch64</li> + * <li>linux-amd64</li> + * <li>linux-ppc64</li> + * <li>linux-mips64</li> + * <li>linux-ia64</li> + * <li>linux-sparcv9</li> + * <li>linux-risc2.0</li> * <li>freebsd-i586</li> * <li>freebsd-amd64</li> * <li>hpux-hppa</li> - * <li>linux-amd64</li> - * <li>linux-ia64</li> - * <li>linux-i586</li> - * <li>linux-armv6</li> - * <li>linux-armv6hf</li> - * <li>android-armv6</li> * <li>macosx-universal</li> * <li>solaris-sparc</li> * <li>solaris-sparcv9</li> @@ -528,40 +533,50 @@ public abstract class PlatformPropsImpl { * </ul> * @return The <i>os.and.arch</i> value. */ - public static final String getOSAndArch(final OSType osType, final CPUType cpuType, final ABIType abiType) { + public static final String getOSAndArch(final OSType osType, final CPUType cpuType, final ABIType abiType, final boolean littleEndian) { final String os_; final String _and_arch_tmp, _and_arch_final; switch( cpuType ) { - case X86_32: - _and_arch_tmp = "i586"; - break; case ARM: case ARMv5: case ARMv6: case ARMv7: if( ABIType.EABI_GNU_ARMHF == abiType ) { - _and_arch_tmp = "armv6hf" ; // TODO: sync with gluegen-cpptasks-base.xml + _and_arch_tmp = "armv6hf"; } else { - _and_arch_tmp = "armv6"; // TODO: sync with gluegen-cpptasks-base.xml + _and_arch_tmp = "armv6"; } break; - case ARM64: - case ARMv8_A: - _and_arch_tmp = "aarch64"; + case X86_32: + _and_arch_tmp = "i586"; + break; + case PPC: + _and_arch_tmp = "ppc"; + break; + case MIPS_32: + _and_arch_tmp = littleEndian ? "mipsel" : "mips"; + break; + case SuperH: + _and_arch_tmp = "superh"; break; case SPARC_32: _and_arch_tmp = "sparc"; break; - case PPC64: - _and_arch_tmp = "ppc64"; // TODO: sync with gluegen-cpptasks-base.xml - break; - case PPC: - _and_arch_tmp = "ppc"; // TODO: sync with gluegen-cpptasks-base.xml + + case ARM64: + case ARMv8_A: + _and_arch_tmp = "aarch64"; break; case X86_64: _and_arch_tmp = "amd64"; break; + case PPC64: + _and_arch_tmp = "ppc64"; + break; + case MIPS_64: + _and_arch_tmp = "mips64"; + break; case IA64: _and_arch_tmp = "ia64"; break; @@ -569,7 +584,7 @@ public abstract class PlatformPropsImpl { _and_arch_tmp = "sparcv9"; break; case PA_RISC2_0: - _and_arch_tmp = "risc2.0"; // TODO: sync with gluegen-cpptasks-base.xml + _and_arch_tmp = "risc2.0"; break; default: throw new InternalError("Unhandled CPUType: "+cpuType); diff --git a/src/java/jogamp/common/os/elf/Ehdr_p1.java b/src/java/jogamp/common/os/elf/Ehdr_p1.java index 0d23a0a..8953776 100644 --- a/src/java/jogamp/common/os/elf/Ehdr_p1.java +++ b/src/java/jogamp/common/os/elf/Ehdr_p1.java @@ -1,4 +1,4 @@ -/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 03:27:25 CET 2015 ----! */ +/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 23:28:47 CET 2015 ----! */ package jogamp.common.os.elf; @@ -8,7 +8,7 @@ import java.nio.*; import com.jogamp.gluegen.runtime.*; import com.jogamp.common.os.*; import com.jogamp.common.nio.*; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; public class Ehdr_p1 { @@ -16,17 +16,17 @@ public class Ehdr_p1 { StructAccessor accessor; private static final int mdIdx = 0; - private final MachineDescription md; - - private static final int[] Ehdr_p1_size = new int[] { 24 /* ARMle_EABI */, 24 /* X86_32_UNIX */, 24 /* LP64_UNIX */, 24 /* X86_32_MACOS */, 24 /* X86_32_WINDOWS */, 24 /* X86_64_WINDOWS */, 24 /* SPARC_32_SUNOS */ }; - private static final int[] e_ident_offset = new int[] { 0 /* ARMle_EABI */, 0 /* X86_32_UNIX */, 0 /* LP64_UNIX */, 0 /* X86_32_MACOS */, 0 /* X86_32_WINDOWS */, 0 /* X86_64_WINDOWS */, 0 /* SPARC_32_SUNOS */ }; - private static final int[] e_ident_size = new int[] { 16 /* ARMle_EABI */, 16 /* X86_32_UNIX */, 16 /* LP64_UNIX */, 16 /* X86_32_MACOS */, 16 /* X86_32_WINDOWS */, 16 /* X86_64_WINDOWS */, 16 /* SPARC_32_SUNOS */ }; - private static final int[] e_type_offset = new int[] { 16 /* ARMle_EABI */, 16 /* X86_32_UNIX */, 16 /* LP64_UNIX */, 16 /* X86_32_MACOS */, 16 /* X86_32_WINDOWS */, 16 /* X86_64_WINDOWS */, 16 /* SPARC_32_SUNOS */ }; -//private static final int[] e_type_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_machine_offset = new int[] { 18 /* ARMle_EABI */, 18 /* X86_32_UNIX */, 18 /* LP64_UNIX */, 18 /* X86_32_MACOS */, 18 /* X86_32_WINDOWS */, 18 /* X86_64_WINDOWS */, 18 /* SPARC_32_SUNOS */ }; -//private static final int[] e_machine_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_version_offset = new int[] { 20 /* ARMle_EABI */, 20 /* X86_32_UNIX */, 20 /* LP64_UNIX */, 20 /* X86_32_MACOS */, 20 /* X86_32_WINDOWS */, 20 /* X86_64_WINDOWS */, 20 /* SPARC_32_SUNOS */ }; -//private static final int[] e_version_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; + private final MachineDataInfo md; + + private static final int[] Ehdr_p1_size = new int[] { 24 /* ARM_MIPS_32 */, 24 /* X86_32_UNIX */, 24 /* X86_32_MACOS */, 24 /* PPC_32_UNIX */, 24 /* SPARC_32_SUNOS */, 24 /* X86_32_WINDOWS */, 24 /* LP64_UNIX */, 24 /* X86_64_WINDOWS */ }; + private static final int[] e_ident_offset = new int[] { 0 /* ARM_MIPS_32 */, 0 /* X86_32_UNIX */, 0 /* X86_32_MACOS */, 0 /* PPC_32_UNIX */, 0 /* SPARC_32_SUNOS */, 0 /* X86_32_WINDOWS */, 0 /* LP64_UNIX */, 0 /* X86_64_WINDOWS */ }; + private static final int[] e_ident_size = new int[] { 16 /* ARM_MIPS_32 */, 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */ }; + private static final int[] e_type_offset = new int[] { 16 /* ARM_MIPS_32 */, 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */ }; +//private static final int[] e_type_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_machine_offset = new int[] { 18 /* ARM_MIPS_32 */, 18 /* X86_32_UNIX */, 18 /* X86_32_MACOS */, 18 /* PPC_32_UNIX */, 18 /* SPARC_32_SUNOS */, 18 /* X86_32_WINDOWS */, 18 /* LP64_UNIX */, 18 /* X86_64_WINDOWS */ }; +//private static final int[] e_machine_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_version_offset = new int[] { 20 /* ARM_MIPS_32 */, 20 /* X86_32_UNIX */, 20 /* X86_32_MACOS */, 20 /* PPC_32_UNIX */, 20 /* SPARC_32_SUNOS */, 20 /* X86_32_WINDOWS */, 20 /* LP64_UNIX */, 20 /* X86_64_WINDOWS */ }; +//private static final int[] e_version_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; public static int size() { return Ehdr_p1_size[mdIdx]; @@ -41,7 +41,7 @@ public class Ehdr_p1 { } Ehdr_p1(java.nio.ByteBuffer buf) { - md = MachineDescription.StaticConfig.values()[mdIdx].md; + md = MachineDataInfo.StaticConfig.values()[mdIdx].md; accessor = new StructAccessor(buf); } diff --git a/src/java/jogamp/common/os/elf/Ehdr_p2.java b/src/java/jogamp/common/os/elf/Ehdr_p2.java index 9dc561a..0842e15 100644 --- a/src/java/jogamp/common/os/elf/Ehdr_p2.java +++ b/src/java/jogamp/common/os/elf/Ehdr_p2.java @@ -1,4 +1,4 @@ -/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 03:27:25 CET 2015 ----! */ +/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 23:28:47 CET 2015 ----! */ package jogamp.common.os.elf; @@ -8,7 +8,7 @@ import java.nio.*; import com.jogamp.gluegen.runtime.*; import com.jogamp.common.os.*; import com.jogamp.common.nio.*; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; public class Ehdr_p2 { @@ -16,29 +16,29 @@ public class Ehdr_p2 { StructAccessor accessor; private final int mdIdx; - private final MachineDescription md; - - private static final int[] Ehdr_p2_size = new int[] { 28 /* ARMle_EABI */, 28 /* X86_32_UNIX */, 40 /* LP64_UNIX */, 28 /* X86_32_MACOS */, 28 /* X86_32_WINDOWS */, 40 /* X86_64_WINDOWS */, 28 /* SPARC_32_SUNOS */ }; - private static final int[] e_entry_offset = new int[] { 0 /* ARMle_EABI */, 0 /* X86_32_UNIX */, 0 /* LP64_UNIX */, 0 /* X86_32_MACOS */, 0 /* X86_32_WINDOWS */, 0 /* X86_64_WINDOWS */, 0 /* SPARC_32_SUNOS */ }; -//private static final int[] e_entry_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] e_phoff_offset = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; -//private static final int[] e_phoff_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] e_shoff_offset = new int[] { 8 /* ARMle_EABI */, 8 /* X86_32_UNIX */, 16 /* LP64_UNIX */, 8 /* X86_32_MACOS */, 8 /* X86_32_WINDOWS */, 16 /* X86_64_WINDOWS */, 8 /* SPARC_32_SUNOS */ }; -//private static final int[] e_shoff_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] e_flags_offset = new int[] { 12 /* ARMle_EABI */, 12 /* X86_32_UNIX */, 24 /* LP64_UNIX */, 12 /* X86_32_MACOS */, 12 /* X86_32_WINDOWS */, 24 /* X86_64_WINDOWS */, 12 /* SPARC_32_SUNOS */ }; -//private static final int[] e_flags_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] e_ehsize_offset = new int[] { 16 /* ARMle_EABI */, 16 /* X86_32_UNIX */, 28 /* LP64_UNIX */, 16 /* X86_32_MACOS */, 16 /* X86_32_WINDOWS */, 28 /* X86_64_WINDOWS */, 16 /* SPARC_32_SUNOS */ }; -//private static final int[] e_ehsize_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_phentsize_offset = new int[] { 18 /* ARMle_EABI */, 18 /* X86_32_UNIX */, 30 /* LP64_UNIX */, 18 /* X86_32_MACOS */, 18 /* X86_32_WINDOWS */, 30 /* X86_64_WINDOWS */, 18 /* SPARC_32_SUNOS */ }; -//private static final int[] e_phentsize_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_phnum_offset = new int[] { 20 /* ARMle_EABI */, 20 /* X86_32_UNIX */, 32 /* LP64_UNIX */, 20 /* X86_32_MACOS */, 20 /* X86_32_WINDOWS */, 32 /* X86_64_WINDOWS */, 20 /* SPARC_32_SUNOS */ }; -//private static final int[] e_phnum_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_shentsize_offset = new int[] { 22 /* ARMle_EABI */, 22 /* X86_32_UNIX */, 34 /* LP64_UNIX */, 22 /* X86_32_MACOS */, 22 /* X86_32_WINDOWS */, 34 /* X86_64_WINDOWS */, 22 /* SPARC_32_SUNOS */ }; -//private static final int[] e_shentsize_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_shnum_offset = new int[] { 24 /* ARMle_EABI */, 24 /* X86_32_UNIX */, 36 /* LP64_UNIX */, 24 /* X86_32_MACOS */, 24 /* X86_32_WINDOWS */, 36 /* X86_64_WINDOWS */, 24 /* SPARC_32_SUNOS */ }; -//private static final int[] e_shnum_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; - private static final int[] e_shstrndx_offset = new int[] { 26 /* ARMle_EABI */, 26 /* X86_32_UNIX */, 38 /* LP64_UNIX */, 26 /* X86_32_MACOS */, 26 /* X86_32_WINDOWS */, 38 /* X86_64_WINDOWS */, 26 /* SPARC_32_SUNOS */ }; -//private static final int[] e_shstrndx_size = new int[] { 2 /* ARMle_EABI */, 2 /* X86_32_UNIX */, 2 /* LP64_UNIX */, 2 /* X86_32_MACOS */, 2 /* X86_32_WINDOWS */, 2 /* X86_64_WINDOWS */, 2 /* SPARC_32_SUNOS */ }; + private final MachineDataInfo md; + + private static final int[] Ehdr_p2_size = new int[] { 28 /* ARM_MIPS_32 */, 28 /* X86_32_UNIX */, 28 /* X86_32_MACOS */, 28 /* PPC_32_UNIX */, 28 /* SPARC_32_SUNOS */, 28 /* X86_32_WINDOWS */, 40 /* LP64_UNIX */, 40 /* X86_64_WINDOWS */ }; + private static final int[] e_entry_offset = new int[] { 0 /* ARM_MIPS_32 */, 0 /* X86_32_UNIX */, 0 /* X86_32_MACOS */, 0 /* PPC_32_UNIX */, 0 /* SPARC_32_SUNOS */, 0 /* X86_32_WINDOWS */, 0 /* LP64_UNIX */, 0 /* X86_64_WINDOWS */ }; +//private static final int[] e_entry_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] e_phoff_offset = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; +//private static final int[] e_phoff_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] e_shoff_offset = new int[] { 8 /* ARM_MIPS_32 */, 8 /* X86_32_UNIX */, 8 /* X86_32_MACOS */, 8 /* PPC_32_UNIX */, 8 /* SPARC_32_SUNOS */, 8 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */ }; +//private static final int[] e_shoff_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] e_flags_offset = new int[] { 12 /* ARM_MIPS_32 */, 12 /* X86_32_UNIX */, 12 /* X86_32_MACOS */, 12 /* PPC_32_UNIX */, 12 /* SPARC_32_SUNOS */, 12 /* X86_32_WINDOWS */, 24 /* LP64_UNIX */, 24 /* X86_64_WINDOWS */ }; +//private static final int[] e_flags_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; + private static final int[] e_ehsize_offset = new int[] { 16 /* ARM_MIPS_32 */, 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 28 /* LP64_UNIX */, 28 /* X86_64_WINDOWS */ }; +//private static final int[] e_ehsize_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_phentsize_offset = new int[] { 18 /* ARM_MIPS_32 */, 18 /* X86_32_UNIX */, 18 /* X86_32_MACOS */, 18 /* PPC_32_UNIX */, 18 /* SPARC_32_SUNOS */, 18 /* X86_32_WINDOWS */, 30 /* LP64_UNIX */, 30 /* X86_64_WINDOWS */ }; +//private static final int[] e_phentsize_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_phnum_offset = new int[] { 20 /* ARM_MIPS_32 */, 20 /* X86_32_UNIX */, 20 /* X86_32_MACOS */, 20 /* PPC_32_UNIX */, 20 /* SPARC_32_SUNOS */, 20 /* X86_32_WINDOWS */, 32 /* LP64_UNIX */, 32 /* X86_64_WINDOWS */ }; +//private static final int[] e_phnum_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_shentsize_offset = new int[] { 22 /* ARM_MIPS_32 */, 22 /* X86_32_UNIX */, 22 /* X86_32_MACOS */, 22 /* PPC_32_UNIX */, 22 /* SPARC_32_SUNOS */, 22 /* X86_32_WINDOWS */, 34 /* LP64_UNIX */, 34 /* X86_64_WINDOWS */ }; +//private static final int[] e_shentsize_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_shnum_offset = new int[] { 24 /* ARM_MIPS_32 */, 24 /* X86_32_UNIX */, 24 /* X86_32_MACOS */, 24 /* PPC_32_UNIX */, 24 /* SPARC_32_SUNOS */, 24 /* X86_32_WINDOWS */, 36 /* LP64_UNIX */, 36 /* X86_64_WINDOWS */ }; +//private static final int[] e_shnum_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; + private static final int[] e_shstrndx_offset = new int[] { 26 /* ARM_MIPS_32 */, 26 /* X86_32_UNIX */, 26 /* X86_32_MACOS */, 26 /* PPC_32_UNIX */, 26 /* SPARC_32_SUNOS */, 26 /* X86_32_WINDOWS */, 38 /* LP64_UNIX */, 38 /* X86_64_WINDOWS */ }; +//private static final int[] e_shstrndx_size = new int[] { 2 /* ARM_MIPS_32 */, 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */ }; public java.nio.ByteBuffer getBuffer() { return accessor.getBuffer(); @@ -169,7 +169,7 @@ public class Ehdr_p2 { Ehdr_p2(final int mdIdx, final java.nio.ByteBuffer buf) { this.mdIdx = mdIdx; - this.md = MachineDescription.StaticConfig.values()[mdIdx].md; + this.md = MachineDataInfo.StaticConfig.values()[mdIdx].md; this.accessor = new StructAccessor(buf); } // ---- End CustomJavaCode .cfg declarations diff --git a/src/java/jogamp/common/os/elf/ElfHeaderPart1.java b/src/java/jogamp/common/os/elf/ElfHeaderPart1.java index ec926e9..4f5b135 100644 --- a/src/java/jogamp/common/os/elf/ElfHeaderPart1.java +++ b/src/java/jogamp/common/os/elf/ElfHeaderPart1.java @@ -32,9 +32,9 @@ import java.io.RandomAccessFile; import java.nio.ByteBuffer; import jogamp.common.Debug; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform.ABIType; import com.jogamp.common.os.Platform.CPUType; import com.jogamp.common.os.Platform.OSType; @@ -49,8 +49,9 @@ import static jogamp.common.os.elf.IOUtils.readBytes; * <p> * References: * <ul> - * <li>http://linux.die.net/man/5/elf</li> * <li>http://www.sco.com/developers/gabi/latest/contents.html</li> + * <li>https://en.wikipedia.org/wiki/Executable_and_Linkable_Format</li> + * <li>http://linux.die.net/man/5/elf</li> * <li>http://infocenter.arm.com/ * <ul> * <li>ARM IHI 0044E, current through ABI release 2.09</li> @@ -327,7 +328,7 @@ public class ElfHeaderPart1 { public final CPUType cpuType; public final ABIType abiType; - public final MachineDescription.StaticConfig machDesc; + public final MachineDataInfo.StaticConfig machDesc; /** * Note: The input stream shall stay untouch to be able to read sections! @@ -387,15 +388,20 @@ public class ElfHeaderPart1 { abiType = ABIType.GENERIC_ABI; break; case EM_MIPS: - cpuName = "mips"; + // Can be little-endian or big-endian and 32 or 64 bits + if( 64 == getArchClassBits() ) { + cpuName = isLittleEndian() ? "mips64le" : "mips64"; + } else { + cpuName = isLittleEndian() ? "mipsle" : "mips"; + } abiType = ABIType.GENERIC_ABI; break; - case EM_MIPS_X: - cpuName = "mips-x"; + case EM_MIPS_RS3_LE: + cpuName = "mipsle-rs3"; // FIXME: Only little-endian? abiType = ABIType.GENERIC_ABI; break; - case EM_MIPS_RS3_LE: - cpuName = "mips-rs3-le"; + case EM_MIPS_X: + cpuName = isLittleEndian() ? "mipsle-x" : "mips-x"; // Can be little-endian abiType = ABIType.GENERIC_ABI; break; case EM_PPC: @@ -406,12 +412,15 @@ public class ElfHeaderPart1 { cpuName = "ppc64"; abiType = ABIType.GENERIC_ABI; break; - case EM_SH: // Hitachi SuperH ? + case EM_SH: + cpuName = "superh"; + abiType = ABIType.GENERIC_ABI; + break; default: throw new IllegalArgumentException("CPUType and ABIType could not be determined"); } cpuType = CPUType.query(cpuName.toLowerCase()); - machDesc = MachineDescriptionRuntime.get(osType, cpuType, isLittleEndian()); + machDesc = MachineDataInfoRuntime.guessStaticMachineDataInfo(osType, cpuType); if(DEBUG) { System.err.println("ELF-1: cpuName "+cpuName+" -> "+cpuType+", "+abiType+", machDesc "+machDesc.toShortString()); } diff --git a/src/java/jogamp/common/os/elf/ElfHeaderPart2.java b/src/java/jogamp/common/os/elf/ElfHeaderPart2.java index 320b8b4..e019b05 100644 --- a/src/java/jogamp/common/os/elf/ElfHeaderPart2.java +++ b/src/java/jogamp/common/os/elf/ElfHeaderPart2.java @@ -48,8 +48,9 @@ import static jogamp.common.os.elf.IOUtils.toHexString; * <p> * References: * <ul> - * <li>http://linux.die.net/man/5/elf</li> * <li>http://www.sco.com/developers/gabi/latest/contents.html</li> + * <li>https://en.wikipedia.org/wiki/Executable_and_Linkable_Format</li> + * <li>http://linux.die.net/man/5/elf</li> * <li>http://infocenter.arm.com/ * <ul> * <li>ARM IHI 0044E, current through ABI release 2.09</li> diff --git a/src/java/jogamp/common/os/elf/Shdr.java b/src/java/jogamp/common/os/elf/Shdr.java index 0b75fd6..18f50b2 100644 --- a/src/java/jogamp/common/os/elf/Shdr.java +++ b/src/java/jogamp/common/os/elf/Shdr.java @@ -1,4 +1,4 @@ -/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 03:27:25 CET 2015 ----! */ +/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/JavaEmitter.java on Sun Feb 01 23:28:47 CET 2015 ----! */ package jogamp.common.os.elf; @@ -8,7 +8,7 @@ import java.nio.*; import com.jogamp.gluegen.runtime.*; import com.jogamp.common.os.*; import com.jogamp.common.nio.*; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; public class Shdr { @@ -16,29 +16,29 @@ public class Shdr { StructAccessor accessor; private final int mdIdx; - private final MachineDescription md; - - private static final int[] Shdr_size = new int[] { 40 /* ARMle_EABI */, 40 /* X86_32_UNIX */, 64 /* LP64_UNIX */, 40 /* X86_32_MACOS */, 40 /* X86_32_WINDOWS */, 64 /* X86_64_WINDOWS */, 40 /* SPARC_32_SUNOS */ }; - private static final int[] sh_name_offset = new int[] { 0 /* ARMle_EABI */, 0 /* X86_32_UNIX */, 0 /* LP64_UNIX */, 0 /* X86_32_MACOS */, 0 /* X86_32_WINDOWS */, 0 /* X86_64_WINDOWS */, 0 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_name_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_type_offset = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_type_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_flags_offset = new int[] { 8 /* ARMle_EABI */, 8 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 8 /* X86_32_MACOS */, 8 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 8 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_flags_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_addr_offset = new int[] { 12 /* ARMle_EABI */, 12 /* X86_32_UNIX */, 16 /* LP64_UNIX */, 12 /* X86_32_MACOS */, 12 /* X86_32_WINDOWS */, 16 /* X86_64_WINDOWS */, 12 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_addr_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_offset_offset = new int[] { 16 /* ARMle_EABI */, 16 /* X86_32_UNIX */, 24 /* LP64_UNIX */, 16 /* X86_32_MACOS */, 16 /* X86_32_WINDOWS */, 24 /* X86_64_WINDOWS */, 16 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_offset_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_size_offset = new int[] { 20 /* ARMle_EABI */, 20 /* X86_32_UNIX */, 32 /* LP64_UNIX */, 20 /* X86_32_MACOS */, 20 /* X86_32_WINDOWS */, 32 /* X86_64_WINDOWS */, 20 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_size_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_link_offset = new int[] { 24 /* ARMle_EABI */, 24 /* X86_32_UNIX */, 40 /* LP64_UNIX */, 24 /* X86_32_MACOS */, 24 /* X86_32_WINDOWS */, 40 /* X86_64_WINDOWS */, 24 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_link_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_info_offset = new int[] { 28 /* ARMle_EABI */, 28 /* X86_32_UNIX */, 44 /* LP64_UNIX */, 28 /* X86_32_MACOS */, 28 /* X86_32_WINDOWS */, 44 /* X86_64_WINDOWS */, 28 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_info_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 4 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 4 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_addralign_offset = new int[] { 32 /* ARMle_EABI */, 32 /* X86_32_UNIX */, 48 /* LP64_UNIX */, 32 /* X86_32_MACOS */, 32 /* X86_32_WINDOWS */, 48 /* X86_64_WINDOWS */, 32 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_addralign_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; - private static final int[] sh_entsize_offset = new int[] { 36 /* ARMle_EABI */, 36 /* X86_32_UNIX */, 56 /* LP64_UNIX */, 36 /* X86_32_MACOS */, 36 /* X86_32_WINDOWS */, 56 /* X86_64_WINDOWS */, 36 /* SPARC_32_SUNOS */ }; -//private static final int[] sh_entsize_size = new int[] { 4 /* ARMle_EABI */, 4 /* X86_32_UNIX */, 8 /* LP64_UNIX */, 4 /* X86_32_MACOS */, 4 /* X86_32_WINDOWS */, 8 /* X86_64_WINDOWS */, 4 /* SPARC_32_SUNOS */ }; + private final MachineDataInfo md; + + private static final int[] Shdr_size = new int[] { 40 /* ARM_MIPS_32 */, 40 /* X86_32_UNIX */, 40 /* X86_32_MACOS */, 40 /* PPC_32_UNIX */, 40 /* SPARC_32_SUNOS */, 40 /* X86_32_WINDOWS */, 64 /* LP64_UNIX */, 64 /* X86_64_WINDOWS */ }; + private static final int[] sh_name_offset = new int[] { 0 /* ARM_MIPS_32 */, 0 /* X86_32_UNIX */, 0 /* X86_32_MACOS */, 0 /* PPC_32_UNIX */, 0 /* SPARC_32_SUNOS */, 0 /* X86_32_WINDOWS */, 0 /* LP64_UNIX */, 0 /* X86_64_WINDOWS */ }; +//private static final int[] sh_name_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; + private static final int[] sh_type_offset = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; +//private static final int[] sh_type_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; + private static final int[] sh_flags_offset = new int[] { 8 /* ARM_MIPS_32 */, 8 /* X86_32_UNIX */, 8 /* X86_32_MACOS */, 8 /* PPC_32_UNIX */, 8 /* SPARC_32_SUNOS */, 8 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; +//private static final int[] sh_flags_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] sh_addr_offset = new int[] { 12 /* ARM_MIPS_32 */, 12 /* X86_32_UNIX */, 12 /* X86_32_MACOS */, 12 /* PPC_32_UNIX */, 12 /* SPARC_32_SUNOS */, 12 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */ }; +//private static final int[] sh_addr_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] sh_offset_offset = new int[] { 16 /* ARM_MIPS_32 */, 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 24 /* LP64_UNIX */, 24 /* X86_64_WINDOWS */ }; +//private static final int[] sh_offset_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] sh_size_offset = new int[] { 20 /* ARM_MIPS_32 */, 20 /* X86_32_UNIX */, 20 /* X86_32_MACOS */, 20 /* PPC_32_UNIX */, 20 /* SPARC_32_SUNOS */, 20 /* X86_32_WINDOWS */, 32 /* LP64_UNIX */, 32 /* X86_64_WINDOWS */ }; +//private static final int[] sh_size_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] sh_link_offset = new int[] { 24 /* ARM_MIPS_32 */, 24 /* X86_32_UNIX */, 24 /* X86_32_MACOS */, 24 /* PPC_32_UNIX */, 24 /* SPARC_32_SUNOS */, 24 /* X86_32_WINDOWS */, 40 /* LP64_UNIX */, 40 /* X86_64_WINDOWS */ }; +//private static final int[] sh_link_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; + private static final int[] sh_info_offset = new int[] { 28 /* ARM_MIPS_32 */, 28 /* X86_32_UNIX */, 28 /* X86_32_MACOS */, 28 /* PPC_32_UNIX */, 28 /* SPARC_32_SUNOS */, 28 /* X86_32_WINDOWS */, 44 /* LP64_UNIX */, 44 /* X86_64_WINDOWS */ }; +//private static final int[] sh_info_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */ }; + private static final int[] sh_addralign_offset = new int[] { 32 /* ARM_MIPS_32 */, 32 /* X86_32_UNIX */, 32 /* X86_32_MACOS */, 32 /* PPC_32_UNIX */, 32 /* SPARC_32_SUNOS */, 32 /* X86_32_WINDOWS */, 48 /* LP64_UNIX */, 48 /* X86_64_WINDOWS */ }; +//private static final int[] sh_addralign_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; + private static final int[] sh_entsize_offset = new int[] { 36 /* ARM_MIPS_32 */, 36 /* X86_32_UNIX */, 36 /* X86_32_MACOS */, 36 /* PPC_32_UNIX */, 36 /* SPARC_32_SUNOS */, 36 /* X86_32_WINDOWS */, 56 /* LP64_UNIX */, 56 /* X86_64_WINDOWS */ }; +//private static final int[] sh_entsize_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ }; public java.nio.ByteBuffer getBuffer() { return accessor.getBuffer(); @@ -169,7 +169,7 @@ public class Shdr { Shdr(final int mdIdx, final java.nio.ByteBuffer buf) { this.mdIdx = mdIdx; - this.md = MachineDescription.StaticConfig.values()[mdIdx].md; + this.md = MachineDataInfo.StaticConfig.values()[mdIdx].md; this.accessor = new StructAccessor(buf); } // ---- End CustomJavaCode .cfg declarations diff --git a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java index 3334f7f..d97e98c 100644 --- a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java +++ b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java @@ -20,7 +20,7 @@ import org.junit.runners.MethodSorters; public class TestPointerBufferEndian extends SingletonJunitCase { protected void testImpl (final boolean direct) { - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDataInfo machine = Platform.getMachineDataInfo(); final int bitsPtr = machine.pointerSizeInBytes() * 8; final String bitsProp = System.getProperty("sun.arch.data.model"); out.println("OS: <"+PlatformPropsImpl.OS+"> CPU: <"+PlatformPropsImpl.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); diff --git a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java index 081337e..a569b54 100644 --- a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java +++ b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java @@ -10,7 +10,7 @@ import jogamp.common.os.PlatformPropsImpl; import org.junit.Assert; import org.junit.Test; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; import com.jogamp.junit.util.SingletonJunitCase; @@ -22,7 +22,7 @@ public class TestStructAccessorEndian extends SingletonJunitCase { @Test public void testStructAccessorEndian1 () { - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDataInfo machine = Platform.getMachineDataInfo(); final int bitsPtr = machine.pointerSizeInBytes() * 8; final String bitsProp = System.getProperty("sun.arch.data.model"); out.println("OS: <"+PlatformPropsImpl.OS+"> CPU: <"+PlatformPropsImpl.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); diff --git a/src/junit/com/jogamp/common/util/TestIOUtil01.java b/src/junit/com/jogamp/common/util/TestIOUtil01.java index 539f883..e85aa37 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtil01.java +++ b/src/junit/com/jogamp/common/util/TestIOUtil01.java @@ -43,7 +43,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; import com.jogamp.junit.util.SingletonJunitCase; @@ -53,7 +53,7 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestIOUtil01 extends SingletonJunitCase { - static final MachineDescription machine = Platform.getMachineDescription(); + static final MachineDataInfo machine = Platform.getMachineDataInfo(); static final int tsz = machine.pageSizeInBytes() + machine.pageSizeInBytes() / 2 ; static final byte[] orig = new byte[tsz]; static final String tfilename = "./test.bin" ; diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java index fc88067..6f1fe0e 100644 --- a/src/junit/com/jogamp/common/util/TestPlatform01.java +++ b/src/junit/com/jogamp/common/util/TestPlatform01.java @@ -31,7 +31,7 @@ package com.jogamp.common.util; import org.junit.Assert; import org.junit.Test; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; import com.jogamp.junit.util.SingletonJunitCase; @@ -55,14 +55,14 @@ public class TestPlatform01 extends SingletonJunitCase { System.err.println("Java vendor[name/url]: "+Platform.getJavaVendor()+"/"+Platform.getJavaVendorURL()); System.err.println("Java version, vm: "+Platform.getJavaVersion()+", "+Platform.getJavaVMName()); System.err.println(); - System.err.println("MD: "+Platform.getMachineDescription()); + System.err.println("MD: "+Platform.getMachineDataInfo()); System.err.println(); System.err.println(); } @Test public void testPageSize01() { - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDataInfo machine = Platform.getMachineDataInfo(); final int ps = machine.pageSizeInBytes(); System.err.println("PageSize: "+ps); Assert.assertTrue("PageSize is 0", 0 < ps ); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java index 82e8cd4..3b1857d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -30,7 +30,7 @@ package com.jogamp.gluegen.test.junit.generation; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform; import com.jogamp.junit.util.SingletonJunitCase; @@ -41,7 +41,7 @@ import java.nio.IntBuffer; import java.nio.LongBuffer; import java.util.Arrays; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; import org.junit.Assert; @@ -824,8 +824,8 @@ public class BaseClass extends SingletonJunitCase { public void chapter09TestCompoundAlignment(final Bindingtest1 binding) throws Exception { - final MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic(); - final MachineDescription md = MachineDescriptionRuntime.getRuntime(); + final MachineDataInfo.StaticConfig smd = MachineDataInfoRuntime.getStatic(); + final MachineDataInfo md = MachineDataInfoRuntime.getRuntime(); System.err.println("static md: "+smd); System.err.println("runtime md: "+md); diff --git a/src/junit/com/jogamp/junit/sec/Applet01.java b/src/junit/com/jogamp/junit/sec/Applet01.java index 2312aa4..f028d7c 100644 --- a/src/junit/com/jogamp/junit/sec/Applet01.java +++ b/src/junit/com/jogamp/junit/sec/Applet01.java @@ -37,7 +37,7 @@ import java.net.URISyntaxException; import java.security.AccessControlException; import com.jogamp.common.net.Uri; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.NativeLibrary; import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; @@ -52,7 +52,7 @@ public class Applet01 extends Applet { static final String os_name_propkey = "os.name"; static final String tfilename = "test.bin" ; - static final MachineDescription machine = Platform.getMachineDescription(); + static final MachineDataInfo machine = Platform.getMachineDataInfo(); static final int tsz = machine.pageSizeInBytes(); static final boolean usesSecurityManager; diff --git a/src/native/common/MachineDescriptionRuntime.c b/src/native/common/MachineDataInfoRuntime.c index a8a69ee..4c6c9e3 100644 --- a/src/native/common/MachineDescriptionRuntime.c +++ b/src/native/common/MachineDataInfoRuntime.c @@ -3,7 +3,7 @@ #include <assert.h> -#include "jogamp_common_os_MachineDescriptionRuntime.h" +#include "jogamp_common_os_MachineDataInfoRuntime.h" #if defined(_WIN32) #include <windows.h> @@ -14,12 +14,12 @@ #include <gluegen_stdint.h> JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getPointerSizeInBytesImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getPointerSizeInBytesImpl(JNIEnv *env, jclass _unused) { return sizeof(void *); } JNIEXPORT jlong JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getPageSizeInBytesImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getPageSizeInBytesImpl(JNIEnv *env, jclass _unused) { #if defined(_WIN32) SYSTEM_INFO si; GetSystemInfo(&si); @@ -84,77 +84,77 @@ typedef struct { #define ALIGNMENT(a, b) ( (a) - (b) ) JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentInt8Impl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentInt8Impl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_int8 ), sizeof(int8_t)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentInt16Impl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentInt16Impl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_int16 ), sizeof(int16_t)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentInt32Impl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentInt32Impl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_int32 ), sizeof(int32_t)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentInt64Impl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentInt64Impl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_int64 ), sizeof(int64_t)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentIntImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentIntImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_int ), sizeof(int)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentLongImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentLongImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_long ), sizeof(long)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentPointerImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentPointerImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_pointer ), sizeof(void *)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentFloatImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentFloatImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_float ), sizeof(float)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentDoubleImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentDoubleImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_double ), sizeof(double)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentLongDoubleImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getAlignmentLongDoubleImpl(JNIEnv *env, jclass _unused) { return ALIGNMENT(sizeof( struct_alignment_ldouble ), sizeof(long double)); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfIntImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getSizeOfIntImpl(JNIEnv *env, jclass _unused) { return sizeof(int); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfLongImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getSizeOfLongImpl(JNIEnv *env, jclass _unused) { return sizeof(long); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfFloatImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getSizeOfFloatImpl(JNIEnv *env, jclass _unused) { return sizeof(float); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfDoubleImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getSizeOfDoubleImpl(JNIEnv *env, jclass _unused) { return sizeof(double); } JNIEXPORT jint JNICALL -Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfLongDoubleImpl(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MachineDataInfoRuntime_getSizeOfLongDoubleImpl(JNIEnv *env, jclass _unused) { return sizeof(long double); } |