diff options
-rw-r--r-- | make/build-crosscompile.xml | 86 | ||||
-rwxr-xr-x | make/gluegen-cpptasks-base.xml | 35 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/MachineDescription.java | 162 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 101 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/GlueGen.java | 7 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/JavaEmitter.java | 5 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/package.html | 2 | ||||
-rw-r--r-- | src/java/jogamp/common/os/MachineDescription32Bit.java | 61 | ||||
-rw-r--r-- | src/java/jogamp/common/os/MachineDescription64Bit.java | 61 | ||||
-rw-r--r-- | src/java/jogamp/common/os/MachineDescriptionRuntime.java | 25 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/IntIntHashMapTest.java | 2 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/IntObjectHashMapTest.java | 2 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/LongIntHashMapTest.java | 2 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java | 2 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java | 8 | ||||
-rw-r--r-- | src/native/common/MachineDescriptionRuntime.c | 15 |
16 files changed, 277 insertions, 299 deletions
diff --git a/make/build-crosscompile.xml b/make/build-crosscompile.xml deleted file mode 100644 index aba6e44..0000000 --- a/make/build-crosscompile.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Document : build-crosscompile.xml - Created on : November 18, 2009, 3:38 PM - Author : Michael Bien - Description: - crosscompiler configuration and ant task for crosscompiling for - linux32/64 and win32/64 on linux64 as host system. ---> -<project name="gluegen-crosscompiler" basedir="." default="gluegen.cross-compile"> - - <import file="build.xml"/> - - <!-- TODO remove hardcoded path --> - <property name="java.includes.dir.windows" value="/media/store/gluegenSetup/win32"/> - - <!-- crosscompiles to other platforms, requirement: linux64 host os --> - <target name="gluegen.cross-compile"> - - <echo message=" - - - cross-compiling gluegen natives - - - "/> - - <antcall target="build.nativelibrary" inheritall="false"> - <param name="namespace" value="linux-amd64"/> - <param name="crosscompile" value="true"/> - <param name="build.dir" value="${build.dir}"/> - <param name="isLinuxAMD64" value="true"/> - <param name="isLinux" value="true"/> - <param name="isUnix" value="true"/> - <param name="isX11" value="true"/> - </antcall> - - <antcall target="build.nativelibrary" inheritall="false"> - <param name="namespace" value="linux-x86"/> - <param name="crosscompile" value="true"/> - <param name="build.dir" value="${build.dir}"/> - <param name="isLinuxX86" value="true"/> - <param name="isLinux" value="true"/> - <param name="isUnix" value="true"/> - <param name="isX11" value="true"/> - </antcall> - - <!-- use mingw crosscompiler to compile for win32 and win64 (linux64 only) --> - <antcall target="build.nativelibrary" inheritall="false"> - <param name="namespace" value="linux-amd64"/> - <param name="crosscompile" value="true"/> - <param name="build.dir" value="${build.dir}"/> - <param name="isLinuxAMD64" value="true"/> - <param name="isLinux" value="true"/> - <param name="isUnix" value="true"/> - <param name="isX11" value="true"/> - - <!-- overwrite --> - <param name="java.includes.dir.platform" value="${java.includes.dir.windows}"/> - <param name="compiler.cfg.id" value="compiler.cfg.linux64.mingw64"/> - <param name="linker.cfg.id" value="linker.cfg.linux64.mingw64.gluegen"/> - </antcall> - - <antcall target="build.nativelibrary" inheritall="false"> - <param name="namespace" value="linux-x86"/> - <param name="crosscompile" value="true"/> - <param name="build.dir" value="${build.dir}"/> - <param name="isLinuxX86" value="true"/> - <param name="isLinux" value="true"/> - <param name="isUnix" value="true"/> - <param name="isX11" value="true"/> - - <!-- overwrite --> - <param name="java.includes.dir.platform" value="${java.includes.dir.windows}"/> - <param name="compiler.cfg.id" value="compiler.cfg.linux64.mingw32"/> - <param name="linker.cfg.id" value="linker.cfg.linux64.mingw32.gluegen"/> - </antcall> - - <echo message=" - - - gluegen natives cross-compiled - - - "/> - - </target> - - - <target name="configure.crosscompiler"> - <linker id="linker.cfg.linux64.mingw64.gluegen" extends="linker.cfg.linux64.mingw64"> - </linker> - - <linker id="linker.cfg.linux64.mingw32.gluegen" extends="linker.cfg.linux64.mingw32"> - </linker> - </target> - -</project>
\ No newline at end of file diff --git a/make/gluegen-cpptasks-base.xml b/make/gluegen-cpptasks-base.xml index 5be1361..7ea3da4 100755 --- a/make/gluegen-cpptasks-base.xml +++ b/make/gluegen-cpptasks-base.xml @@ -24,7 +24,7 @@ - isLinuxAMD64 - isLinuxIA64 - isLinuxX86 - - isLinuxARM + - isLinuxARMv7l - isOSX - isOSXPPC - isSolaris @@ -94,7 +94,7 @@ - - compiler.cfg.linux - compiler.cfg.linux.amd64 - - compiler.cfg.linux.arm7 + - compiler.cfg.linux.armv7l - compiler.cfg.solaris - compiler.cfg.solaris.sparcv9 - compiler.cfg.solaris.amd64 @@ -106,7 +106,7 @@ - compiler.cfg.hpux - linker.cfg.linux - linker.cfg.linux.amd64 - - linker.cfg.linux.arm7 + - linker.cfg.linux.armv7l - linker.cfg.freebsd.x86 - linker.cfg.freebsd.amd64 - linker.cfg.solaris @@ -222,10 +222,13 @@ <condition property="isHPUX"> <os name="HP-UX" /> </condition> - <condition property="isLinuxARM7"> + <condition property="isLinuxARMv7l"> <and> <istrue value="${isLinux}" /> - <os arch="arm" /> + <or> + <os arch="arm" /> + <os arch="armv7l" /> + </or> </and> </condition> <condition property="isLinuxX86"> @@ -324,7 +327,7 @@ <echo message="LinuxAMD64=${isLinuxAMD64}" /> <echo message="LinuxIA64=${isLinuxIA64}" /> <echo message="LinuxX86=${isLinuxX86}" /> - <echo message="LinuxARM=${isLinuxARM}" /> + <echo message="LinuxARMv7l=${isLinuxARMv7l}" /> <echo message="OS X=${isOSX}" /> <echo message="OS X PPC=${use.macosppc}" /> <echo message="OS X x32=${use.macosx32}" /> @@ -366,11 +369,11 @@ <property name="os.and.arch" value="linux-i586" /> </target> - <target name="gluegen.cpptasks.detect.os.linux.arm7" unless="gluegen.cpptasks.detected.os.2" if="isLinuxARM7"> - <property name="os.and.arch" value="linux-arm7" /> + <target name="gluegen.cpptasks.detect.os.linux.armv7l" unless="gluegen.cpptasks.detected.os.2" if="isLinuxARMv7l"> + <property name="os.and.arch" value="linux-armv7l" /> </target> - <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86,gluegen.cpptasks.detect.os.linux.arm7" unless="gluegen.cpptasks.detected.os.2" /> + <target name="gluegen.cpptasks.detect.os.linux" depends="gluegen.cpptasks.detect.os.linux.amd64,gluegen.cpptasks.detect.os.linux.ia64,gluegen.cpptasks.detect.os.linux.x86,gluegen.cpptasks.detect.os.linux.armv7l" unless="gluegen.cpptasks.detected.os.2" /> <target name="gluegen.cpptasks.detect.os.osx" unless="gluegen.cpptasks.detected.os.2" if="isOSX"> <property name="native.library.suffix" value="*lib" /> @@ -592,7 +595,7 @@ </defineset> </compiler> - <compiler id="compiler.cfg.linux.arm7" name="gcc"> + <compiler id="compiler.cfg.linux.armv7l" name="gcc"> <defineset> <define name="__unix__"/> <define name="_DEBUG" if="c.compiler.use-debug"/> @@ -770,7 +773,7 @@ <linkerarg value="-m64"/> </linker> - <linker id="linker.cfg.linux.arm7" name="gcc"> + <linker id="linker.cfg.linux.armv7l" name="gcc"> </linker> <linker id="linker.cfg.hpux" name="aCC"> @@ -908,10 +911,10 @@ <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/i386" /> </target> - <target name="gluegen.cpptasks.declare.compiler.linux.arm7" if="isLinuxARM7"> - <echo message="Linux.arm7" /> - <property name="compiler.cfg.id.base" value="compiler.cfg.linux.arm7" /> - <property name="linker.cfg.id.base" value="linker.cfg.linux.arm7" /> + <target name="gluegen.cpptasks.declare.compiler.linux.armv7l" if="isLinuxARMv7l"> + <echo message="Linux.armv7l" /> + <property name="compiler.cfg.id.base" value="compiler.cfg.linux.armv7l" /> + <property name="linker.cfg.id.base" value="linker.cfg.linux.armv7l" /> <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/arm" /> </target> @@ -929,7 +932,7 @@ <property name="java.lib.dir.platform" value="${java.home.dir}/jre/lib/ia64" /> </target> - <target name="gluegen.cpptasks.declare.compiler.linux" depends="gluegen.cpptasks.declare.compiler.linux.x86,gluegen.cpptasks.declare.compiler.linux.amd64,gluegen.cpptasks.declare.compiler.linux.ia64,gluegen.cpptasks.declare.compiler.linux.arm7" if="isLinux"> + <target name="gluegen.cpptasks.declare.compiler.linux" depends="gluegen.cpptasks.declare.compiler.linux.x86,gluegen.cpptasks.declare.compiler.linux.amd64,gluegen.cpptasks.declare.compiler.linux.ia64,gluegen.cpptasks.declare.compiler.linux.armv7l" if="isLinux"> <property name="java.includes.dir.platform" value="${java.includes.dir}/linux" /> </target> diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java index 99383b4..7534917 100644 --- a/src/java/com/jogamp/common/os/MachineDescription.java +++ b/src/java/com/jogamp/common/os/MachineDescription.java @@ -40,12 +40,81 @@ package com.jogamp.common.os; -import com.jogamp.common.util.VersionUtil; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; + +import com.jogamp.common.nio.Buffers; /** * For alignment and size see {@link com.jogamp.gluegen} */ public class MachineDescription { + /* arch os int, long, float, doubl, ldoubl, ptr, page */ + final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 }; + final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 }; + final static int[] size_x86_32_windows = { 4, 4, 4, 8, 12, 4, 4096 }; + final static int[] size_x86_64_unix = { 4, 8, 4, 8, 16, 8, 4096 }; + final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 }; + + /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ + final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; + final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 }; + final static int[] align_x86_32_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 4, 4 }; + final static int[] align_x86_64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 }; + final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 }; + + public enum Config { + ARM_EABI(size_armeabi, align_armeabi), + X86_32_UNIX(size_x86_32_unix, align_x86_32_unix), + X86_64_UNIX(size_x86_64_unix, align_x86_64_unix), + X86_32_WINDOWS(size_x86_32_windows, align_x86_32_windows), + X86_64_WINDOWS(size_x86_64_windows, align_x86_64_windows); + + public final int intSizeInBytes; + public final int longSizeInBytes; + public final int floatSizeInBytes; + public final int doubleSizeInBytes; + public final int ldoubleSizeInBytes; + public final int pointerSizeInBytes; + public final int pageSizeInBytes; + + public final int int8AlignmentInBytes; + public final int int16AlignmentInBytes; + public final int int32AlignmentInBytes; + public final int int64AlignmentInBytes; + public final int intAlignmentInBytes; + public final int longAlignmentInBytes; + public final int floatAlignmentInBytes; + public final int doubleAlignmentInBytes; + public final int ldoubleAlignmentInBytes; + public final int pointerAlignmentInBytes; + + Config(int[] sizes, int[] alignments) { + int i=0; + intSizeInBytes = sizes[i++]; + longSizeInBytes = sizes[i++];; + floatSizeInBytes = sizes[i++];; + doubleSizeInBytes = sizes[i++];; + ldoubleSizeInBytes = sizes[i++];; + pointerSizeInBytes = sizes[i++];; + pageSizeInBytes = sizes[i++];; + + i=0; + int8AlignmentInBytes = alignments[i++]; + int16AlignmentInBytes = alignments[i++]; + int32AlignmentInBytes = alignments[i++]; + int64AlignmentInBytes = alignments[i++]; + intAlignmentInBytes = alignments[i++]; + longAlignmentInBytes = alignments[i++]; + floatAlignmentInBytes = alignments[i++]; + doubleAlignmentInBytes = alignments[i++]; + ldoubleAlignmentInBytes = alignments[i++]; + pointerAlignmentInBytes = alignments[i++]; + } + } + + final private boolean runtimeValidated; final private boolean littleEndian; @@ -59,6 +128,7 @@ public class MachineDescription { final private int longSizeInBytes; final private int floatSizeInBytes; final private int doubleSizeInBytes; + final private int ldoubleSizeInBytes; final private int pointerSizeInBytes; final private int pageSizeInBytes; final private boolean is32Bit; @@ -71,16 +141,83 @@ public class MachineDescription { final private int longAlignmentInBytes; final private int floatAlignmentInBytes; final private int doubleAlignmentInBytes; + final private int ldoubleAlignmentInBytes; final private int pointerAlignmentInBytes; + public static boolean queryIsLittleEndian() { + ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order + IntBuffer tst_i = tst_b.asIntBuffer(); + ShortBuffer tst_s = tst_b.asShortBuffer(); + tst_i.put(0, 0x0A0B0C0D); + return 0x0C0D == tst_s.get(0); + } + + public static MachineDescription createStaticArmEABI() { + return new MachineDescription(false, queryIsLittleEndian(), Config.ARM_EABI); + } + public static MachineDescription createStaticUnix32() { + return new MachineDescription(false, queryIsLittleEndian(), Config.X86_32_UNIX); + } + public static MachineDescription createStaticUnix64() { + return new MachineDescription(false, queryIsLittleEndian(), Config.X86_64_UNIX); + } + public static MachineDescription createStaticWindows32() { + return new MachineDescription(false, queryIsLittleEndian(), Config.X86_32_WINDOWS); + } + public static MachineDescription createStaticWindows64() { + return new MachineDescription(false, queryIsLittleEndian(), Config.X86_64_WINDOWS); + } + public static MachineDescription createStatic(boolean is32BitByCPUArch) { + if(is32BitByCPUArch) { + if(Platform.getCPUFamily() == Platform.CPUFamily.ARM) { + return createStaticArmEABI(); + } else if(Platform.getOSType() == Platform.OSType.WINDOWS) { + return createStaticWindows32(); + } + return createStaticUnix32(); + } else { + if(Platform.getOSType() == Platform.OSType.WINDOWS) { + return createStaticWindows64(); + } + return createStaticUnix64(); + } + } + + public MachineDescription(boolean runtimeValidated, + boolean littleEndian, + Config config) { + this.runtimeValidated = runtimeValidated; + this.littleEndian = littleEndian; + + this.intSizeInBytes = config.intSizeInBytes; + this.longSizeInBytes = config.longSizeInBytes; + this.floatSizeInBytes = config.floatSizeInBytes; + this.doubleSizeInBytes = config.doubleSizeInBytes; + this.ldoubleSizeInBytes = config.ldoubleSizeInBytes; + this.pointerSizeInBytes = config.pointerSizeInBytes; + this.pageSizeInBytes = config.pageSizeInBytes; + this.is32Bit = 4 == config.pointerSizeInBytes; + + this.int8AlignmentInBytes = config.int8AlignmentInBytes; + this.int16AlignmentInBytes = config.int16AlignmentInBytes; + this.int32AlignmentInBytes = config.int32AlignmentInBytes; + this.int64AlignmentInBytes = config.int64AlignmentInBytes; + this.intAlignmentInBytes = config.intAlignmentInBytes; + this.longAlignmentInBytes = config.longAlignmentInBytes; + this.floatAlignmentInBytes = config.floatAlignmentInBytes; + this.doubleAlignmentInBytes = config.doubleAlignmentInBytes; + this.ldoubleAlignmentInBytes = config.ldoubleAlignmentInBytes; + this.pointerAlignmentInBytes = config.pointerAlignmentInBytes; + } + public MachineDescription(boolean runtimeValidated, - boolean littleEndian, int intSizeInBytes, int longSizeInBytes, int floatSizeInBytes, int doubleSizeInBytes, + int ldoubleSizeInBytes, int pointerSizeInBytes, int pageSizeInBytes, @@ -92,27 +229,29 @@ public class MachineDescription { int longAlignmentInBytes, int floatAlignmentInBytes, int doubleAlignmentInBytes, + int ldoubleAlignmentInBytes, int pointerAlignmentInBytes) { - this.runtimeValidated = runtimeValidated; - + this.runtimeValidated = runtimeValidated; this.littleEndian = littleEndian; this.intSizeInBytes = intSizeInBytes; this.longSizeInBytes = longSizeInBytes; this.floatSizeInBytes = floatSizeInBytes; this.doubleSizeInBytes = doubleSizeInBytes; + this.ldoubleSizeInBytes = ldoubleSizeInBytes; this.pointerSizeInBytes = pointerSizeInBytes; this.pageSizeInBytes = pageSizeInBytes; - this.is32Bit = 4 == pointerSizeInBytes; + this.is32Bit = 4 == pointerSizeInBytes; - this.int8AlignmentInBytes = int8AlignmentInBytes; - this.int16AlignmentInBytes = int16AlignmentInBytes; - this.int32AlignmentInBytes = int32AlignmentInBytes; - this.int64AlignmentInBytes = int64AlignmentInBytes; + this.int8AlignmentInBytes = int8AlignmentInBytes; + this.int16AlignmentInBytes = int16AlignmentInBytes; + this.int32AlignmentInBytes = int32AlignmentInBytes; + this.int64AlignmentInBytes = int64AlignmentInBytes; this.intAlignmentInBytes = intAlignmentInBytes; this.longAlignmentInBytes = longAlignmentInBytes; this.floatAlignmentInBytes = floatAlignmentInBytes; this.doubleAlignmentInBytes = doubleAlignmentInBytes; + this.ldoubleAlignmentInBytes = ldoubleAlignmentInBytes; this.pointerAlignmentInBytes = pointerAlignmentInBytes; } @@ -152,6 +291,7 @@ public class MachineDescription { public final int int64SizeInBytes() { return int64SizeInBytes; } public final int floatSizeInBytes() { return floatSizeInBytes; } public final int doubleSizeInBytes() { return doubleSizeInBytes; } + public final int ldoubleSizeInBytes() { return ldoubleSizeInBytes; } public final int pointerSizeInBytes() { return pointerSizeInBytes; } public final int pageSizeInBytes() { return pageSizeInBytes; } @@ -163,6 +303,7 @@ public class MachineDescription { public final int int64AlignmentInBytes() { return int64AlignmentInBytes; } public final int floatAlignmentInBytes() { return floatAlignmentInBytes; } public final int doubleAlignmentInBytes() { return doubleAlignmentInBytes; } + public final int ldoubleAlignmentInBytes() { return ldoubleAlignmentInBytes; } public final int pointerAlignmentInBytes() { return pointerAlignmentInBytes; } /** @@ -191,7 +332,8 @@ public class MachineDescription { sb.append(" int32 ").append(int32SizeInBytes) .append(" / ").append(int32AlignmentInBytes); sb.append(", int64 ").append(int64SizeInBytes) .append(" / ").append(int64AlignmentInBytes).append(Platform.getNewline()); sb.append(" float ").append(floatSizeInBytes) .append(" / ").append(floatAlignmentInBytes); - sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes).append(Platform.getNewline()); + sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes); + sb.append(", ldouble ").append(ldoubleSizeInBytes).append(" / ").append(ldoubleAlignmentInBytes).append(Platform.getNewline()); sb.append(" pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes); sb.append(", page ").append(pageSizeInBytes); return sb; diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 680d5be..85567a8 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -52,7 +52,7 @@ public class Platform { public static final String NEWLINE; public enum OSType { - LINUX(0), FREEBSD(1), DALVIK(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); + LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); public final int id; @@ -62,27 +62,61 @@ public class Platform { } public static final OSType OS_TYPE; - public enum CPUType { - X86(0), IA(1), ARM(2), SPARC(3), PA_RISC(4), PPC(5); + public enum CPUFamily { + /** AMD/Intel */ + X86( 0x00000000), + /** ARM */ + ARM( 0x00010000), + /** Power PC */ + PPC( 0x00020000), + /** SPARC */ + SPARC( 0x00030000), + /** PA RISC */ + PA_RISC(0xFFFF0000), + /** Itanium */ + IA64( 0xFFFF1000); public final int id; - CPUType(int id){ + CPUFamily(int id){ this.id = id; } } - public static final CPUType CPU_TYPE; - - public enum CPUArch { - X86_32(0), X86_64(1), IA64(2), ARM_32(3), SPARC_32(4), SPARCV9_64(5), PA_RISC2_0(6), PPC(7); + public enum CPUType { + /** X86 32bit */ + X86_32( CPUFamily.X86, 0x0001), + /** X86 64bit */ + X86_64( CPUFamily.X86, 0x0002), + /** ARM default */ + ARM( CPUFamily.ARM, 0x0000), + /** ARM7EJ, ARM9E, ARM10E, XScale */ + ARMv5( CPUFamily.ARM, 0x0001), + /** ARM11 */ + ARMv6( CPUFamily.ARM, 0x0002), + /** ARM Cortex */ + ARMv7( CPUFamily.ARM, 0x0004), + /** PPC default */ + PPC( CPUFamily.PPC, 0x0000), + /** SPARC 32bit */ + SPARC_32( CPUFamily.SPARC, 0x0001), + /** SPARC 64bit */ + SPARCV9_64(CPUFamily.SPARC, 0x0002), + /** Itanium default */ + IA64( CPUFamily.IA64, 0x0000), + /** PA_RISC2_0 */ + PA_RISC2_0(CPUFamily.PA_RISC, 0x0001); public final int id; - - CPUArch(int id){ + public final CPUFamily family; + + CPUType(CPUFamily type, int id){ + this.family = type; this.id = id; } + + public CPUFamily getFamily() { return family; } } - public static final CPUArch CPU_ARCH; + public static final CPUType CPU_ARCH; private static final boolean is32Bit; @@ -110,30 +144,28 @@ public class Platform { ARCH_lower.equals("i486") || ARCH_lower.equals("i586") || ARCH_lower.equals("i686") ) { - CPU_ARCH = CPUArch.X86_32; - CPU_TYPE = CPUType.X86; + CPU_ARCH = CPUType.X86_32; } else if( ARCH_lower.equals("x86_64") || ARCH_lower.equals("amd64") ) { - CPU_ARCH = CPUArch.X86_64; - CPU_TYPE = CPUType.X86; + CPU_ARCH = CPUType.X86_64; } else if( ARCH_lower.equals("ia64") ) { - CPU_ARCH = CPUArch.IA64; - CPU_TYPE = CPUType.IA; + CPU_ARCH = CPUType.IA64; } else if( ARCH_lower.equals("arm") ) { - CPU_ARCH = CPUArch.ARM_32; - CPU_TYPE = CPUType.ARM; + CPU_ARCH = CPUType.ARM; + } else if( ARCH_lower.equals("armv5l") ) { + CPU_ARCH = CPUType.ARMv5; + } else if( ARCH_lower.equals("armv6l") ) { + CPU_ARCH = CPUType.ARMv6; + } else if( ARCH_lower.equals("armv7l") ) { + CPU_ARCH = CPUType.ARMv7; } else if( ARCH_lower.equals("sparc") ) { - CPU_ARCH = CPUArch.SPARC_32; - CPU_TYPE = CPUType.SPARC; + CPU_ARCH = CPUType.SPARC_32; } else if( ARCH_lower.equals("sparcv9") ) { - CPU_ARCH = CPUArch.SPARCV9_64; - CPU_TYPE = CPUType.SPARC; + CPU_ARCH = CPUType.SPARCV9_64; } else if( ARCH_lower.equals("pa_risc2.0") ) { - CPU_ARCH = CPUArch.PA_RISC2_0; - CPU_TYPE = CPUType.PA_RISC; + CPU_ARCH = CPUType.PA_RISC2_0; } else if( ARCH_lower.equals("ppc") ) { - CPU_ARCH = CPUArch.PPC; - CPU_TYPE = CPUType.PPC; + CPU_ARCH = CPUType.PPC; } else { throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + ARCH_lower + ")"); } @@ -148,7 +180,10 @@ public class Platform { private static boolean getIs32BitByCPUArchImpl() throws RuntimeException { switch( CPU_ARCH ) { case X86_32: - case ARM_32: + case ARM: + case ARMv5: + case ARMv6: + case ARMv7: case SPARC_32: case PPC: return true; @@ -169,8 +204,8 @@ public class Platform { if ( OS_lower.startsWith("freebsd") ) { return OSType.FREEBSD; } - if ( OS_lower.startsWith("dalvik") ) { - return OSType.DALVIK; + if ( OS_lower.startsWith("android") ) { + return OSType.ANDROID; } if ( OS_lower.startsWith("mac os x") || OS_lower.startsWith("darwin") ) { @@ -253,14 +288,14 @@ public class Platform { /** * Returns the CPU type. */ - public static CPUType getCPUType() { - return CPU_TYPE; + public static CPUFamily getCPUFamily() { + return CPU_ARCH.getFamily(); } /** * Returns the CPU architecture. */ - public static CPUArch getCPUArch() { + public static CPUType getCPUType() { return CPU_ARCH; } diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java index 9b0bb5f..c0e87ee 100644 --- a/src/java/com/jogamp/gluegen/GlueGen.java +++ b/src/java/com/jogamp/gluegen/GlueGen.java @@ -45,9 +45,6 @@ import com.jogamp.common.os.MachineDescription; import java.io.*; import java.util.*; -import jogamp.common.os.MachineDescription32Bit; -import jogamp.common.os.MachineDescription64Bit; - import antlr.*; import com.jogamp.gluegen.cgram.*; import com.jogamp.gluegen.cgram.types.*; @@ -192,8 +189,8 @@ public class GlueGen implements GlueEmitterControls { } // Provide MachineDescriptions to emitter - MachineDescription md32 = new MachineDescription32Bit(); - MachineDescription md64 = new MachineDescription64Bit(); + final MachineDescription md32 = MachineDescription.createStaticUnix32(); + final MachineDescription md64 = MachineDescription.createStaticUnix64(); emit.setMachineDescription(md32, md64); // Repackage the enum and #define statements from the parser into a common format diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index a3ee962..770db38 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -1410,11 +1410,12 @@ public class JavaEmitter implements GlueEmitter { private int slot(Type t, int byteOffset, MachineDescription curMachDesc) { if (t.isInt()) { - switch ((int) t.getSize(curMachDesc)) { + final int tsz = (int) t.getSize(curMachDesc); + switch (tsz) { case 1: case 2: case 4: - case 8: return byteOffset / (int) t.getSize(curMachDesc); + case 8: return byteOffset / tsz; default: throw new RuntimeException("Illegal type"); } } else if (t.isFloat()) { diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html index cc97ad5..cd23370 100644 --- a/src/java/com/jogamp/gluegen/package.html +++ b/src/java/com/jogamp/gluegen/package.html @@ -89,7 +89,7 @@ <tr><td>long double</td><td>12<sup>†</sup><sup>∗</sup>,8<sup>+</sup></td> <td>4<sup>†</sup><sup>∗</sup>,8<sup>+</sup></td> <td> 16</td> <td>16</td></tr> </table><br> <sup>†</sup> Linux, Darwin<br> - <sup>+</sup>armv7l-32bit-eabi (linux)<br> + <sup>+</sup>armv7l-eabi<br> <sup>∗</sup> Windows<br> </P> diff --git a/src/java/jogamp/common/os/MachineDescription32Bit.java b/src/java/jogamp/common/os/MachineDescription32Bit.java deleted file mode 100644 index aebac80..0000000 --- a/src/java/jogamp/common/os/MachineDescription32Bit.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.common.os; - -import com.jogamp.common.os.MachineDescription; - -/** - * Compile time machine description. - * <p>littleEndian is guessed, true</p> - * <p>pageSize is guessed, 4096</p> - * <p>alignments are wrong, just set to sizeof</p> - * For alignment and size see {@link com.jogamp.gluegen} - */ -public class MachineDescription32Bit extends MachineDescription { - public MachineDescription32Bit() { - // size: int, long, float, double, pointer, pageSize - // alignment: int8, int16, int32, int64, int, long, float, double, pointer - super( false /* runtime validated */, true /* little endian */, - /* size */ 4, 4, 4, 8, 4, 4096, - /*align */ 1, 2, 4, 8, 4, 4, 4, 8, 4); - - } -} diff --git a/src/java/jogamp/common/os/MachineDescription64Bit.java b/src/java/jogamp/common/os/MachineDescription64Bit.java deleted file mode 100644 index 4b3b13f..0000000 --- a/src/java/jogamp/common/os/MachineDescription64Bit.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.common.os; - -import com.jogamp.common.os.MachineDescription; - -/** - * Compile time machine description. - * <p>littleEndian is guessed, true</p> - * <p>sizeof(long) is wrong for Windows (64bit only)</p> - * <p>pageSize is guessed, 4096</p> - * <p>alignments are wrong, just set to sizeof</p> - * For alignment and size see {@link com.jogamp.gluegen} - */ -public class MachineDescription64Bit extends MachineDescription { - public MachineDescription64Bit() { - // size: int, long, float, double, pointer, pageSize - // alignment: int8, int16, int32, int64, int, long, float, double, pointer - super( false /* runtime validated */, true /* little endian */, - /* size */ 4, 8 /* on win, long is 4 !!! */, 4, 8, 8, 4096, - /*align */ 1, 2, 4, 8, 4, 8, 4, 8, 8); - } -} diff --git a/src/java/jogamp/common/os/MachineDescriptionRuntime.java b/src/java/jogamp/common/os/MachineDescriptionRuntime.java index 5d4a8c3..a5ecc1d 100644 --- a/src/java/jogamp/common/os/MachineDescriptionRuntime.java +++ b/src/java/jogamp/common/os/MachineDescriptionRuntime.java @@ -31,6 +31,7 @@ package jogamp.common.os; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.os.Platform; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -66,11 +67,7 @@ public class MachineDescriptionRuntime { return getMachineDescriptionImpl(pointerSizeInBytes, (int) pageSizeL); } else { - if(is32BitByCPUArch) { - return new MachineDescription32Bit(); - } else { - return new MachineDescription64Bit(); - } + return MachineDescription.createStatic(is32BitByCPUArch); } } @@ -78,21 +75,15 @@ 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 */, - isLittleEndianImpl(), + true /* runtime validated */, MachineDescription.queryIsLittleEndian(), + getSizeOfIntImpl(), getSizeOfLongImpl(), - getSizeOfFloatImpl(), getSizeOfDoubleImpl(), pointerSize, pageSize, + getSizeOfFloatImpl(), getSizeOfDoubleImpl(), getSizeOfLongDoubleImpl(), pointerSize, pageSize, getAlignmentInt8Impl(), getAlignmentInt16Impl(), getAlignmentInt32Impl(), getAlignmentInt64Impl(), getAlignmentIntImpl(), getAlignmentLongImpl(), - getAlignmentFloatImpl(), getAlignmentDoubleImpl(), getAlignmentPointerImpl()); - } - private static boolean isLittleEndianImpl() { - ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order - IntBuffer tst_i = tst_b.asIntBuffer(); - ShortBuffer tst_s = tst_b.asShortBuffer(); - tst_i.put(0, 0x0A0B0C0D); - return 0x0C0D == tst_s.get(0); + getAlignmentFloatImpl(), getAlignmentDoubleImpl(), getAlignmentLongDoubleImpl(), + getAlignmentPointerImpl()); } private static native int getPointerSizeInBytesImpl(); @@ -107,10 +98,12 @@ public class MachineDescriptionRuntime { private static native int getAlignmentPointerImpl(); private static native int getAlignmentFloatImpl(); private static native int getAlignmentDoubleImpl(); + private static native int getAlignmentLongDoubleImpl(); private static native int getSizeOfIntImpl(); private static native int getSizeOfLongImpl(); private static native int getSizeOfPointerImpl(); private static native int getSizeOfFloatImpl(); private static native int getSizeOfDoubleImpl(); + private static native int getSizeOfLongDoubleImpl(); } diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java index 09aff1c..22ff25a 100644 --- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java @@ -55,7 +55,7 @@ public class IntIntHashMapTest { @BeforeClass public static void init() { - iterations = ( Platform.CPUType.ARM == Platform.CPU_TYPE ) ? 100 : 10000; + iterations = ( Platform.getCPUType().getFamily() == Platform.CPUFamily.ARM ) ? 100 : 10000; pairs = new IntIntUniqueRndValues(iterations); } diff --git a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java index 00de133..2bbce8b 100644 --- a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java @@ -54,7 +54,7 @@ public class IntObjectHashMapTest { @BeforeClass public static void init() { - iterations = ( Platform.getCPUType() == Platform.CPUType.ARM ) ? 100 : 10000; + iterations = ( Platform.getCPUType().getFamily() == Platform.CPUFamily.ARM ) ? 100 : 10000; pairs = new IntIntObjUniqueRndValues(iterations); } diff --git a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java index 239bef1..2426526 100644 --- a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java @@ -55,7 +55,7 @@ public class LongIntHashMapTest { @BeforeClass public static void init() { - iterations = ( Platform.getCPUType() == Platform.CPUType.ARM ) ? 100 : 10000; + iterations = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 100 : 10000; pairs = new LongIntUniqueRndValues(iterations); } diff --git a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java index da797dc..6bdfbd1 100644 --- a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java +++ b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java @@ -42,7 +42,7 @@ import com.jogamp.common.os.Platform; public class TestIteratorIndexCORE { static int elems = 10; - static int loop = ( Platform.getCPUType() == Platform.CPUType.ARM ) ? 100 : 9999999; + static int loop = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 100 : 9999999; public void populate(List l, int len) { while(len>0) { diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java index bee9b44..099f8b8 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java @@ -212,7 +212,7 @@ public class TestRecursiveLock01 { // @Test public void testLockedObjectThreading2x10000() throws InterruptedException { System.err.println("++++ TestRecursiveLock01.testLockedObjectThreading2x10000"); - if( Platform.getCPUType() == Platform.CPUType.ARM ) { + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { testLockedObjectImpl(2, 10, 10, YIELD_NONE); } else { testLockedObjectImpl(2, 10000, 10000, YIELD_NONE); @@ -223,7 +223,7 @@ public class TestRecursiveLock01 { @Test public void testLockedObjectThreading25x25Yield() throws InterruptedException { System.err.println("++++ TestRecursiveLock01.testLockedObjectThreading25x25-Yield"); - if( Platform.getCPUType() == Platform.CPUType.ARM ) { + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { testLockedObjectImpl(5, 25, 10, YIELD_YIELD); } else { testLockedObjectImpl(25, 25, 100, YIELD_YIELD); @@ -234,7 +234,7 @@ public class TestRecursiveLock01 { // @Test public void testLockedObjectThreading25x25Sleep() throws InterruptedException { System.err.println("++++ TestRecursiveLock01.testLockedObjectThreading25x25-Sleep"); - if( Platform.getCPUType() == Platform.CPUType.ARM ) { + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { testLockedObjectImpl(5, 25, 10, YIELD_SLEEP); } else { testLockedObjectImpl(25, 25, 100, YIELD_SLEEP); @@ -245,7 +245,7 @@ public class TestRecursiveLock01 { @Test public void testLockedObjectThreading25x25None() throws InterruptedException { System.err.println("++++ TestRecursiveLock01.testLockedObjectThreading25x25-None"); - if( Platform.getCPUType() == Platform.CPUType.ARM ) { + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { testLockedObjectImpl(5, 25, 10, YIELD_NONE); } else { testLockedObjectImpl(25, 25, 100, YIELD_NONE); diff --git a/src/native/common/MachineDescriptionRuntime.c b/src/native/common/MachineDescriptionRuntime.c index 0e6475c..a8a69ee 100644 --- a/src/native/common/MachineDescriptionRuntime.c +++ b/src/native/common/MachineDescriptionRuntime.c @@ -74,6 +74,11 @@ typedef struct { double v; } struct_alignment_double; +typedef struct { + int8_t c1; + long double v; +} struct_alignment_ldouble; + // size_t padding(size_t totalsize, size_t typesize) { return totalsize - typesize - sizeof(char); } // static size_t alignment(size_t totalsize, size_t typesize) { return totalsize - typesize; } #define ALIGNMENT(a, b) ( (a) - (b) ) @@ -124,6 +129,11 @@ Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentDoubleImpl(JNIEnv *e } JNIEXPORT jint JNICALL +Java_jogamp_common_os_MachineDescriptionRuntime_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) { return sizeof(int); } @@ -143,3 +153,8 @@ Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfDoubleImpl(JNIEnv *env, return sizeof(double); } +JNIEXPORT jint JNICALL +Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfLongDoubleImpl(JNIEnv *env, jclass _unused) { + return sizeof(long double); +} + |