diff options
author | Sven Gothel <[email protected]> | 2011-07-17 16:34:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-07-17 16:34:39 +0200 |
commit | f733203dfbd034a6b1aa3eb2cd616437c982c435 (patch) | |
tree | 4ace71d4b129870b02f962b714c9dce9f83bc294 /src/junit/com/jogamp/common | |
parent | ad3dc39ccfddb007c3e91acf454f804573969419 (diff) |
GlueGen proper size / alignment of primitive and compound types usage [1/2] - Preparation.
Currently GlueGen fails for type long (size) and some alignments (see package.html).
- The size and alignment values shall be queried at runtime.
- Compound alignment needs to follow the described natural alignment (also @runtime).
-
- Build
- add Linux Arm7 (EABI)
- junit test
- added compound/struct tests, pointing out the shortcomings of current impl.
- package.html
- Added alignment documentation
- remove intptr.cfg
- add GluGen types int8_t, int16_t, uint8_t, uint16_t
- move MachineDescription* into runtime
- Platform
- has runtime MachineDescription
- moved size, .. to MachineDescription
- use enums for OSType, CPUArch and CPUType defined by os.name/os.arch,
triggering exception if os/arch is not supported.
This avoids Java String comparison and conscious os/arch detection.
- MachineDescription:
- compile time instances MachineDescription32Bits, MachineDescription64Bits
- runtime queried instance MachineDescriptionRuntime
- correct size, alignment, page size, ..
Diffstat (limited to 'src/junit/com/jogamp/common')
4 files changed, 20 insertions, 19 deletions
diff --git a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java index da232a2..e587acf 100644 --- a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java +++ b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java @@ -11,13 +11,11 @@ import static java.lang.System.*; public class TestPointerBufferEndian { protected void testImpl (boolean direct) { - int bitsPtr = Platform.getPointerSizeInBits(); + final MachineDescription machine = Platform.getMachineDescription(); + int bitsPtr = machine.pointerSizeInBytes() * 8; String bitsProp = System.getProperty("sun.arch.data.model"); - String os = System.getProperty("os.name"); - String cpu = System.getProperty("os.arch"); - out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); - out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); - out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); + out.println("OS: <"+Platform.OS+"> CPU: <"+Platform.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + out.println(machine.toString()); long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; long[] values32Bit = { 0x0000000089ABCDEFL, 0x0000000044332211L, 0x00000000BEEFAFFEL }; diff --git a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java index 09781ec..8a20272 100644 --- a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java +++ b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java @@ -14,13 +14,12 @@ public class TestStructAccessorEndian { @Test public void testStructAccessorEndian1 () { - int bitsPtr = Platform.getPointerSizeInBits(); + final MachineDescription machine = Platform.getMachineDescription(); + int bitsPtr = machine.pointerSizeInBytes() * 8; String bitsProp = System.getProperty("sun.arch.data.model"); - String os = System.getProperty("os.name"); - String cpu = System.getProperty("os.arch"); - out.println("OS: <"+os+"> CPU: <"+cpu+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + out.println("OS: <"+Platform.OS+"> CPU: <"+Platform.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); - out.println("Buffer is in: "+ (Platform.isLittleEndian()?"little":"big") + " endian"); + out.println(machine.toString()); long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; ByteBuffer tst = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG * valuesSource.length); diff --git a/src/junit/com/jogamp/common/util/TestIOUtil01.java b/src/junit/com/jogamp/common/util/TestIOUtil01.java index ad95213..fd95652 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtil01.java +++ b/src/junit/com/jogamp/common/util/TestIOUtil01.java @@ -44,11 +44,13 @@ import org.junit.BeforeClass; import org.junit.AfterClass; import org.junit.Test; +import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; public class TestIOUtil01 { - static final int tsz = Platform.getPageSize() + Platform.getPageSize() / 2 ; + static final MachineDescription machine = Platform.getMachineDescription(); + 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 544418a..1266c45 100644 --- a/src/junit/com/jogamp/common/util/TestPlatform01.java +++ b/src/junit/com/jogamp/common/util/TestPlatform01.java @@ -31,34 +31,36 @@ package com.jogamp.common.util; import org.junit.Assert; import org.junit.Test; +import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; public class TestPlatform01 { @Test public void testPageSize01() { - final int ps = Platform.getPageSize(); + final MachineDescription machine = Platform.getMachineDescription(); + final int ps = machine.pageSizeInBytes(); System.err.println("PageSize: "+ps); Assert.assertTrue("PageSize is 0", 0 < ps ); - final int ps_pages = Platform.getPageNumber(ps); + final int ps_pages = machine.pageCount(ps); Assert.assertTrue("PageNumber of PageSize is not 1, but "+ps_pages, 1 == ps_pages); final int sz0 = ps - 10; - final int sz0_pages = Platform.getPageNumber(sz0); + final int sz0_pages = machine.pageCount(sz0); Assert.assertTrue("PageNumber of PageSize-10 is not 1, but "+sz0_pages, 1 == sz0_pages); final int sz1 = ps + 10; - final int sz1_pages = Platform.getPageNumber(sz1); + final int sz1_pages = machine.pageCount(sz1); Assert.assertTrue("PageNumber of PageSize+10 is not 2, but "+sz1_pages, 2 == sz1_pages); - final int ps_psa = Platform.getPageAlignedSize(ps); + final int ps_psa = machine.pageAlignedSize(ps); Assert.assertTrue("PageAlignedSize of PageSize is not PageSize, but "+ps_psa, ps == ps_psa); - final int sz0_psa = Platform.getPageAlignedSize(sz0); + final int sz0_psa = machine.pageAlignedSize(sz0); Assert.assertTrue("PageAlignedSize of PageSize-10 is not PageSize, but "+sz0_psa, ps == sz0_psa); - final int sz1_psa = Platform.getPageAlignedSize(sz1); + final int sz1_psa = machine.pageAlignedSize(sz1); Assert.assertTrue("PageAlignedSize of PageSize+10 is not 2*PageSize, but "+sz1_psa, ps*2 == sz1_psa); } |