From f733203dfbd034a6b1aa3eb2cd616437c982c435 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sun, 17 Jul 2011 16:34:39 +0200
Subject: 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, ..
---
 make/build-test.xml                                |   4 +
 make/build.xml                                     |  10 +-
 make/config/intptr.cfg                             |  17 --
 make/gluegen-cpptasks-base.xml                     |  41 +++-
 make/scripts/runtest.sh                            |   4 +-
 make/stub_includes/gluegen/gluegen_types.h         |   4 +
 make/stub_includes/platform/gluegen_stdint.h       |  20 +-
 .../com/jogamp/common/os/MachineDescription.java   | 223 ++++++++++++++++++
 src/java/com/jogamp/common/os/NativeLibrary.java   |  64 +++---
 src/java/com/jogamp/common/os/Platform.java        | 256 ++++++++++++---------
 src/java/com/jogamp/common/util/IOUtil.java        |  18 +-
 src/java/com/jogamp/common/util/VersionUtil.java   |   5 +-
 .../com/jogamp/gluegen/CMethodBindingEmitter.java  |   1 +
 src/java/com/jogamp/gluegen/DebugEmitter.java      |   1 +
 src/java/com/jogamp/gluegen/GlueEmitter.java       |   2 +
 src/java/com/jogamp/gluegen/GlueGen.java           |   5 +
 src/java/com/jogamp/gluegen/JavaEmitter.java       |   2 +
 src/java/com/jogamp/gluegen/StructLayout.java      |  53 +++--
 src/java/com/jogamp/gluegen/cgram/GnuCParser.g     |   4 +
 src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g |   4 +
 src/java/com/jogamp/gluegen/cgram/HeaderParser.g   |  12 +-
 src/java/com/jogamp/gluegen/cgram/StdCParser.g     |   4 +
 src/java/com/jogamp/gluegen/cgram/types/Field.java |   2 +
 .../gluegen/cgram/types/MachineDescription.java    |  82 -------
 .../cgram/types/MachineDescription32Bit.java       |  46 ----
 .../cgram/types/MachineDescription64Bit.java       |  46 ----
 .../com/jogamp/gluegen/cgram/types/SizeThunk.java  |  20 ++
 src/java/com/jogamp/gluegen/cgram/types/Type.java  |   2 +
 src/java/com/jogamp/gluegen/package.html           |  90 ++++++--
 .../jogamp/common/os/MachineDescription32Bit.java  |  61 +++++
 .../jogamp/common/os/MachineDescription64Bit.java  |  61 +++++
 .../jogamp/common/nio/TestPointerBufferEndian.java |  10 +-
 .../common/nio/TestStructAccessorEndian.java       |   9 +-
 src/junit/com/jogamp/common/util/TestIOUtil01.java |   4 +-
 .../com/jogamp/common/util/TestPlatform01.java     |  16 +-
 .../gluegen/test/junit/generation/BaseClass.java   |  75 ++++++
 .../test/junit/generation/BuildEnvironment.java    |   4 +-
 .../test/junit/generation/Test1p1JavaEmitter.java  |   8 +
 .../generation/Test1p2ProcAddressEmitter.java      |   8 +
 .../gluegen/test/junit/generation/test1-common.cfg |  20 ++
 .../test/junit/generation/test1-gluegen.cfg        |   1 +
 .../jogamp/gluegen/test/junit/generation/test1.c   |  81 +++++++
 .../jogamp/gluegen/test/junit/generation/test1.h   |  62 +++++
 .../test/junit/generation/test1p2-gluegen.cfg      |   1 -
 src/native/common/MachineDescriptionRuntime.c      | 174 ++++++++++++++
 src/native/common/Platform.c                       |  29 ---
 46 files changed, 1215 insertions(+), 451 deletions(-)
 delete mode 100755 make/config/intptr.cfg
 create mode 100644 src/java/com/jogamp/common/os/MachineDescription.java
 delete mode 100644 src/java/com/jogamp/gluegen/cgram/types/MachineDescription.java
 delete mode 100644 src/java/com/jogamp/gluegen/cgram/types/MachineDescription32Bit.java
 delete mode 100644 src/java/com/jogamp/gluegen/cgram/types/MachineDescription64Bit.java
 create mode 100644 src/java/jogamp/common/os/MachineDescription32Bit.java
 create mode 100644 src/java/jogamp/common/os/MachineDescription64Bit.java
 create mode 100644 src/native/common/MachineDescriptionRuntime.c
 delete mode 100644 src/native/common/Platform.c

diff --git a/make/build-test.xml b/make/build-test.xml
index 10b464c..27638ad 100644
--- a/make/build-test.xml
+++ b/make/build-test.xml
@@ -333,6 +333,8 @@
 
         <patternset id="junit.test1p1.c.src.files">
           <include name="${build_t.gen.rootrel}/native/Bindingtest1p1Impl_JNI.c"/>
+          <include name="${build_t.gen.rootrel}/native/TK_Engine_JNI.c"/>
+          <include name="${build_t.gen.rootrel}/native/TK_Surface_JNI.c"/>
         </patternset>
 
         <c.build c.compiler.src.files="junit.test1p1.c.src.files"
@@ -355,6 +357,8 @@
 
         <patternset id="junit.test1p2.c.src.files">
           <include name="${build_t.gen.rootrel}/native/Bindingtest1p2Impl_JNI.c"/>
+          <include name="${build_t.gen.rootrel}/native/TK_Engine_JNI.c"/>
+          <include name="${build_t.gen.rootrel}/native/TK_Surface_JNI.c"/>
         </patternset>
 
         <c.build c.compiler.src.files="junit.test1p2.c.src.files"
diff --git a/make/build.xml b/make/build.xml
index d26beec..d27b801 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -291,7 +291,13 @@
       <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
     </target>
 
-    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64" if="isLinux" >
+    <target name="declare.linux.arm7" if="isLinuxARM7">
+      <echo message="Linux.arm7" />
+      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.arm7" /> 
+      <property name="linker.cfg.id"                        value="linker.cfg.linux.arm7" /> 
+    </target>
+    
+    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64,declare.linux.arm7" if="isLinux" >
       <property name="c.src.dir.os"                         value="unix" />
       <property name="java.includes.dir.platform"           value="${java.includes.dir}/linux" />
     </target>
@@ -393,7 +399,7 @@
       <fail message="Requires '${compiler.cfg.id}'"      unless="compiler.cfg.id"/>
       <fail message="Requires '${linker.cfg.id}'"        unless="linker.cfg.id"/>
 
-      <javah destdir="${src.generated.c}"         classpath="${classes}" class="com.jogamp.common.os.Platform" />
+      <javah destdir="${src.generated.c}"         classpath="${classes}" class="jogamp.common.os.MachineDescriptionRuntime" />
       <javah destdir="${src.generated.c}"         classpath="${classes}" class="com.jogamp.common.jvm.JVMUtil" />
       <javah destdir="${src.generated.c}"         classpath="${classes}" class="com.jogamp.common.nio.PointerBuffer" />
       <javah destdir="${src.generated.c}/Unix"    classpath="${classes}" class="com.jogamp.common.os.UnixDynamicLinkerImpl" />
diff --git a/make/config/intptr.cfg b/make/config/intptr.cfg
deleted file mode 100755
index c946e48..0000000
--- a/make/config/intptr.cfg
+++ /dev/null
@@ -1,17 +0,0 @@
-CustomCCode #ifdef _WIN32
-CustomCCode  #ifdef _MSC_VER
-CustomCCode  /* This typedef is apparently needed for Microsoft compilers before VC8,
-CustomCCode     and on Windows CE */
-CustomCCode   #if (_MSC_VER < 1400) || defined(UNDER_CE)
-CustomCCode    #ifdef _WIN64
-CustomCCode     typedef long long intptr_t;
-CustomCCode    #else
-CustomCCode     typedef int intptr_t;
-CustomCCode    #endif
-CustomCCode   #endif
-CustomCCode  #else
-CustomCCode   #include <inttypes.h>
-CustomCCode  #endif
-CustomCCode #else
-CustomCCode  #include <inttypes.h>
-CustomCCode #endif
diff --git a/make/gluegen-cpptasks-base.xml b/make/gluegen-cpptasks-base.xml
index ac09037..5be1361 100755
--- a/make/gluegen-cpptasks-base.xml
+++ b/make/gluegen-cpptasks-base.xml
@@ -24,6 +24,7 @@
    -   isLinuxAMD64
    -   isLinuxIA64
    -   isLinuxX86
+   -   isLinuxARM
    -   isOSX
    -   isOSXPPC
    -   isSolaris
@@ -93,6 +94,7 @@
    - 
    -   compiler.cfg.linux
    -   compiler.cfg.linux.amd64
+   -   compiler.cfg.linux.arm7
    -   compiler.cfg.solaris
    -   compiler.cfg.solaris.sparcv9
    -   compiler.cfg.solaris.amd64
@@ -104,6 +106,7 @@
    -   compiler.cfg.hpux
    -   linker.cfg.linux
    -   linker.cfg.linux.amd64
+   -   linker.cfg.linux.arm7
    -   linker.cfg.freebsd.x86
    -   linker.cfg.freebsd.amd64
    -   linker.cfg.solaris
@@ -123,6 +126,10 @@
 <project name="GlueGen-cpptasks-base" basedir=".">
 
   <target name="gluegen.cpptasks.initialize" depends="gluegen.properties.load.user">
+    <echo message="os.name=${os.name}" />
+    <echo message="os.version=${os.version}" />
+    <echo message="os.arch=${os.arch}" />
+
     <!-- NOTE: the value of the debug attribute will not be overridden if already set externally -->
     <property name="c.compiler.debug"     value="false" /> 
 
@@ -215,6 +222,12 @@
     <condition property="isHPUX">
       <os name="HP-UX" />
     </condition>
+    <condition property="isLinuxARM7">
+      <and>
+        <istrue value="${isLinux}" />
+        <os arch="arm" />
+      </and>
+    </condition>
     <condition property="isLinuxX86">
       <and>
         <istrue value="${isLinux}" />
@@ -311,6 +324,7 @@
     <echo message="LinuxAMD64=${isLinuxAMD64}" />
     <echo message="LinuxIA64=${isLinuxIA64}" />
     <echo message="LinuxX86=${isLinuxX86}" />
+    <echo message="LinuxARM=${isLinuxARM}" />
     <echo message="OS X=${isOSX}" />
     <echo message="OS X PPC=${use.macosppc}" />
     <echo message="OS X x32=${use.macosx32}" />
@@ -352,7 +366,11 @@
     <property name="os.and.arch" value="linux-i586" />
   </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" unless="gluegen.cpptasks.detected.os.2" />
+  <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>
+
+  <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.osx" unless="gluegen.cpptasks.detected.os.2" if="isOSX">
     <property name="native.library.suffix"     value="*lib" />
@@ -574,6 +592,15 @@
       </defineset>
     </compiler>
 
+    <compiler id="compiler.cfg.linux.arm7" name="gcc">
+      <defineset>
+        <define name="__unix__"/>
+        <define name="_DEBUG"   if="c.compiler.use-debug"/>        
+        <define name="DEBUG"    if="c.compiler.use-debug"/>        
+        <define name="NDEBUG"   unless="c.compiler.use-debug"/>        
+      </defineset>
+    </compiler>
+
     <compiler id="compiler.cfg.freebsd" name="gcc">
       <defineset>
         <define name="__unix__"/>
@@ -743,6 +770,9 @@
         <linkerarg value="-m64"/>
     </linker>
 
+    <linker id="linker.cfg.linux.arm7" name="gcc">
+    </linker>
+
     <linker id="linker.cfg.hpux" name="aCC">
     </linker>
 
@@ -878,6 +908,13 @@
       <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" /> 
+      <property name="java.lib.dir.platform"         value="${java.home.dir}/jre/lib/arm" />
+    </target>
+
     <target name="gluegen.cpptasks.declare.compiler.linux.amd64" if="isLinuxAMD64">
       <echo message="Linux.AMD64" />
       <property name="compiler.cfg.id.base"          value="compiler.cfg.linux.amd64" /> 
@@ -892,7 +929,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" 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.arm7" if="isLinux">
         <property name="java.includes.dir.platform" value="${java.includes.dir}/linux" />
     </target>
 
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh
index 558d4f1..f720dcf 100755
--- a/make/scripts/runtest.sh
+++ b/make/scripts/runtest.sh
@@ -39,13 +39,13 @@ function onetest() {
     echo
 }
 
-#onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG
+onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.TestIteratorIndexCORE 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.locks.TestRecursiveLock01 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.TestArrayHashSet01 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.IntIntHashMapTest 2>&1 | tee -a $LOG
-onetest com.jogamp.common.util.IntObjectHashMapTest 2>&1 | tee -a $LOG
+#onetest com.jogamp.common.util.IntObjectHashMapTest 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.util.LongIntHashMapTest 2>&1 | tee -a $LOG
 #onetest com.jogamp.common.nio.TestBuffersFloatDoubleConversion 2>&1 | tee -a $LOG
 #onetest com.jogamp.gluegen.PCPPTest 2>&1 | tee -a $LOG
diff --git a/make/stub_includes/gluegen/gluegen_types.h b/make/stub_includes/gluegen/gluegen_types.h
index d1f003a..3df8eb4 100644
--- a/make/stub_includes/gluegen/gluegen_types.h
+++ b/make/stub_includes/gluegen/gluegen_types.h
@@ -24,6 +24,10 @@
  * 
  * The following types are build-in:
  *
+ * int8_t        - stdint.h
+ * uint8_t       - stdint.h
+ * int16_t       - stdint.h
+ * uint16_t      - stdint.h
  * __int32       - windows
  * int32_t       - stdint.h
  * wchar_t       - stddef.h
diff --git a/make/stub_includes/platform/gluegen_stdint.h b/make/stub_includes/platform/gluegen_stdint.h
index 1dd712b..8b1dbe3 100644
--- a/make/stub_includes/platform/gluegen_stdint.h
+++ b/make/stub_includes/platform/gluegen_stdint.h
@@ -10,14 +10,22 @@
 #elif defined(WIN32) && defined(__GNUC__)
     #include <stdint.h>
 #elif defined(_WIN64)
+    typedef signed        char   int8_t;
+    typedef unsigned      char  uint8_t;
+    typedef signed       short  int16_t;
+    typedef unsigned     short uint16_t;
     typedef            __int32  int32_t;
     typedef unsigned   __int32 uint32_t;
     typedef            __int64  int64_t;
     typedef unsigned   __int64 uint64_t;
 
-    typedef            __int64  intptr_t;
-    typedef unsigned   __int64 uintptr_t;
+    typedef           __int64  intptr_t;
+    typedef unsigned  __int64 uintptr_t;
 #elif defined(_WIN32)
+    typedef signed        char   int8_t;
+    typedef unsigned      char  uint8_t;
+    typedef signed       short  int16_t;
+    typedef unsigned     short uint16_t;
     typedef            __int32  int32_t;
     typedef unsigned   __int32 uint32_t;
     typedef            __int64  int64_t;
@@ -26,6 +34,10 @@
     typedef            __int32  intptr_t;
     typedef unsigned   __int32 uintptr_t;
 #elif defined(__ia64__) || defined(__x86_64__)
+    typedef signed        char   int8_t;
+    typedef unsigned      char  uint8_t;
+    typedef signed       short  int16_t;
+    typedef unsigned     short uint16_t;
     typedef signed         int  int32_t;
     typedef unsigned       int uint32_t;
     typedef signed        long  int64_t;
@@ -34,6 +46,10 @@
     typedef               long  intptr_t;
     typedef unsigned      long uintptr_t;
 #else
+    typedef signed        char   int8_t;
+    typedef unsigned      char  uint8_t;
+    typedef signed       short  int16_t;
+    typedef unsigned     short uint16_t;
     typedef signed         int  int32_t;
     typedef unsigned       int uint32_t;
     typedef signed   long long  int64_t;
diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java
new file mode 100644
index 0000000..a407187
--- /dev/null
+++ b/src/java/com/jogamp/common/os/MachineDescription.java
@@ -0,0 +1,223 @@
+/*
+ * 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 com.jogamp.common.os;
+
+import com.jogamp.common.util.VersionUtil;
+
+/**
+ * For alignment and size see {@link com.jogamp.gluegen}
+ */
+public class MachineDescription {
+  final private boolean runtimeValidated;
+  
+  final private boolean littleEndian;
+    
+  final private int int8SizeInBytes = 1;
+  final private int int16SizeInBytes = 2;
+  final private int int32SizeInBytes = 4;
+  final private int int64SizeInBytes = 8;
+  
+  final private int charSizeInBytes;
+  final private int shortSizeInBytes;
+  final private int intSizeInBytes;
+  final private int longSizeInBytes;
+  final private int floatSizeInBytes;
+  final private int doubleSizeInBytes;
+  final private int pointerSizeInBytes;
+  final private int pageSizeInBytes;
+  final private boolean is32Bit;
+    
+  final private int int8AlignmentInBytes;
+  final private int int16AlignmentInBytes;
+  final private int int32AlignmentInBytes;
+  final private int int64AlignmentInBytes;
+  final private int charAlignmentInBytes;
+  final private int shortAlignmentInBytes;
+  final private int intAlignmentInBytes;
+  final private int longAlignmentInBytes;
+  final private int floatAlignmentInBytes;
+  final private int doubleAlignmentInBytes;
+  final private int pointerAlignmentInBytes;
+
+  public MachineDescription(boolean runtimeValidated,
+          
+                            boolean littleEndian,
+          
+                            int charSizeInBytes,
+                            int shortSizeInBytes,
+                            int intSizeInBytes,
+                            int longSizeInBytes,
+                            int floatSizeInBytes,
+                            int doubleSizeInBytes,
+                            int pointerSizeInBytes,
+                            int pageSizeInBytes,
+                            
+                            int int8AlignmentInBytes,
+                            int int16AlignmentInBytes,
+                            int int32AlignmentInBytes,
+                            int int64AlignmentInBytes,
+                            int charAlignmentInBytes,
+                            int shortAlignmentInBytes,
+                            int intAlignmentInBytes,
+                            int longAlignmentInBytes,
+                            int floatAlignmentInBytes,
+                            int doubleAlignmentInBytes,
+                            int pointerAlignmentInBytes) {
+    this.runtimeValidated = runtimeValidated;
+    
+    this.littleEndian = littleEndian;
+    
+    this.charSizeInBytes    = charSizeInBytes;
+    this.shortSizeInBytes   = shortSizeInBytes;
+    this.intSizeInBytes     = intSizeInBytes;
+    this.longSizeInBytes    = longSizeInBytes;
+    this.floatSizeInBytes   = floatSizeInBytes;
+    this.doubleSizeInBytes  = doubleSizeInBytes;
+    this.pointerSizeInBytes = pointerSizeInBytes;
+    this.pageSizeInBytes    = pageSizeInBytes; 
+    this.is32Bit = 4 == pointerSizeInBytes;
+
+    this.int8AlignmentInBytes = int8AlignmentInBytes;
+    this.int16AlignmentInBytes = int16AlignmentInBytes;
+    this.int32AlignmentInBytes = int32AlignmentInBytes;
+    this.int64AlignmentInBytes = int64AlignmentInBytes;
+    this.charAlignmentInBytes    = charAlignmentInBytes;
+    this.shortAlignmentInBytes   = shortAlignmentInBytes;
+    this.intAlignmentInBytes     = intAlignmentInBytes;
+    this.longAlignmentInBytes    = longAlignmentInBytes;
+    this.floatAlignmentInBytes   = floatAlignmentInBytes;
+    this.doubleAlignmentInBytes  = doubleAlignmentInBytes;
+    this.pointerAlignmentInBytes = pointerAlignmentInBytes;
+  }
+  
+  /**
+   * @return true if all values are validated at runtime, otherwise false (i.e. for static compilation w/ preset values)
+   */
+  public final boolean isRuntimeValidated() {
+      return runtimeValidated;
+  }
+  
+  /**
+   * Returns true only if this system uses little endian byte ordering.
+   */
+  public final boolean isLittleEndian() {
+      return littleEndian;
+  }
+
+  /**
+   * Returns true if this JVM/ARCH is 32bit.
+   */
+  public final boolean is32Bit() {
+    return is32Bit;
+  }
+
+  /**
+   * Returns true if this JVM/ARCH is 64bit.
+   */
+  public final  boolean is64Bit() {
+    return !is32Bit;
+  }
+  
+  public final int charSizeInBytes()    { return charSizeInBytes;   }
+  public final int shortSizeInBytes()   { return shortSizeInBytes;  }
+  public final int intSizeInBytes()     { return intSizeInBytes;    }
+  public final int longSizeInBytes()    { return longSizeInBytes;   }
+  public final int int8SizeInBytes()    { return int8SizeInBytes;  }
+  public final int int16SizeInBytes()   { return int16SizeInBytes;  }
+  public final int int32SizeInBytes()   { return int32SizeInBytes;  }
+  public final int int64SizeInBytes()   { return int64SizeInBytes;  }
+  public final int floatSizeInBytes()   { return floatSizeInBytes;  }
+  public final int doubleSizeInBytes()  { return doubleSizeInBytes; }
+  public final int pointerSizeInBytes() { return pointerSizeInBytes; }
+  public final int pageSizeInBytes()    { return pageSizeInBytes; }
+  
+  public final int charAlignmentInBytes()    { return charAlignmentInBytes;   }
+  public final int shortAlignmentInBytes()   { return shortAlignmentInBytes;  }
+  public final int intAlignmentInBytes()     { return intAlignmentInBytes;    }
+  public final int longAlignmentInBytes()    { return longAlignmentInBytes;   }
+  public final int int8AlignmentInBytes()    { return int8AlignmentInBytes;  }
+  public final int int16AlignmentInBytes()   { return int16AlignmentInBytes;  }
+  public final int int32AlignmentInBytes()   { return int32AlignmentInBytes;  }
+  public final int int64AlignmentInBytes()   { return int64AlignmentInBytes;  }
+  public final int floatAlignmentInBytes()   { return floatAlignmentInBytes;  }
+  public final int doubleAlignmentInBytes()  { return doubleAlignmentInBytes; }
+  public final int pointerAlignmentInBytes() { return pointerAlignmentInBytes; }
+  
+  /**
+   * @return number of pages required for size in bytes
+   */
+  public int pageCount(int size) {
+    return ( size + ( pageSizeInBytes - 1) ) / pageSizeInBytes ; // integer arithmetic
+  }
+    
+  /**
+   * @return page aligned size in bytes
+   */
+  public int pageAlignedSize(int size) {
+    return pageCount(size) * pageSizeInBytes;
+  }    
+  
+    public StringBuilder toString(StringBuilder sb) {
+        if(null==sb) {
+            sb = new StringBuilder();
+        }
+        sb.append("MachineDescription: runtimeValidated ").append(isRuntimeValidated()).append(", littleEndian ").append(isLittleEndian()).append(", 32Bit ").append(is32Bit()).append(", primitive size / alignment:").append(Platform.getNewline());
+        sb.append("  char    ").append(charSizeInBytes)   .append(" / ").append(charAlignmentInBytes);
+        sb.append(", short   ").append(shortSizeInBytes)  .append(" / ").append(shortAlignmentInBytes);
+        sb.append(", int     ").append(intSizeInBytes)    .append(" / ").append(intAlignmentInBytes);
+        sb.append(", long    ").append(longSizeInBytes)   .append(" / ").append(longAlignmentInBytes).append(Platform.getNewline());
+        sb.append("  int8    ").append(int8SizeInBytes)   .append(" / ").append(int8AlignmentInBytes);
+        sb.append(", int16   ").append(int16SizeInBytes)  .append(" / ").append(int16AlignmentInBytes);
+        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);
+        sb.append(", pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes);
+        sb.append(", page    ").append(pageSizeInBytes);                
+        return sb;
+    }
+    
+    @Override
+    public String toString() {
+        return toString(null).toString();
+    }
+  
+}
diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java
index 558aa3e..30075fd 100755
--- a/src/java/com/jogamp/common/os/NativeLibrary.java
+++ b/src/java/com/jogamp/common/os/NativeLibrary.java
@@ -59,54 +59,39 @@ import java.util.*;
     supporting code needed in the generated library. */
 
 public class NativeLibrary implements DynamicLookupHelper {
-  private static final int WINDOWS = 1;
-  private static final int UNIX    = 2;
-  private static final int MACOSX  = 3;
   protected static boolean DEBUG;
   protected static boolean DEBUG_LOOKUP;
-  private static int platform;
   private static DynamicLinker dynLink;
   private static String[] prefixes;
   private static String[] suffixes;
 
   static {
-    // Determine platform we're running on
-    AccessController.doPrivileged(new PrivilegedAction() {
-        public Object run() {
-          String osName = System.getProperty("os.name").toLowerCase();
-          if (osName.startsWith("wind")) {
-            platform = WINDOWS;
-          } else if (osName.startsWith("mac os x")) {
-            platform = MACOSX;
-          } else {
-            platform = UNIX;
-          }
-
-          DEBUG = (System.getProperty("jogamp.debug.NativeLibrary") != null);
-          DEBUG_LOOKUP = (System.getProperty("jogamp.debug.NativeLibrary.Lookup") != null);
-
-          return null;
-        }
-      });
     // Instantiate dynamic linker implementation
-    switch (platform) {
+    switch (Platform.OS_TYPE) {
       case WINDOWS:
         dynLink = new WindowsDynamicLinkerImpl();
         prefixes = new String[] { "" };
         suffixes = new String[] { ".dll" };
         break;
-      case UNIX:
-        dynLink = new UnixDynamicLinkerImpl();
-        prefixes = new String[] { "lib" };
-        suffixes = new String[] { ".so" };
-        break;
-      case MACOSX:
+        
+      case MACOS:
         dynLink = new MacOSXDynamicLinkerImpl();
         prefixes = new String[] { "lib", "" };
         suffixes = new String[] { ".dylib", ".jnilib", "" };
         break;
+
+      /*
+      case FREEBSD:
+      case DALVIK:
+      case SUNOS:
+      case HPUX: 
+      case OPENKODE:         
+      case LINUX: */
       default:
-        throw new InternalError("Platform not initialized properly");
+        dynLink = new UnixDynamicLinkerImpl();
+        prefixes = new String[] { "lib" };
+        suffixes = new String[] { ".so" };
+        break;
     }
   }
 
@@ -306,7 +291,7 @@ public class NativeLibrary implements DynamicLookupHelper {
     addPaths(userDir, baseNames, paths);
 
     // Add probable Mac OS X-specific paths
-    if (platform == MACOSX) {
+    if (Platform.OS_TYPE == Platform.OSType.MACOS) {
       // Add historical location
       addPaths("/Library/Frameworks/" + libName + ".Framework", baseNames, paths);
       // Add current location
@@ -325,15 +310,22 @@ public class NativeLibrary implements DynamicLookupHelper {
   private static String selectName(String windowsLibName,
                                    String unixLibName,
                                    String macOSXLibName) {
-    switch (platform) {
+    switch (Platform.OS_TYPE) {
       case WINDOWS:
         return windowsLibName;
-      case UNIX:
-        return unixLibName;
-      case MACOSX:
+        
+      case MACOS:
         return macOSXLibName;
+
+      /*
+      case FREEBSD:
+      case DALVIK:
+      case SUNOS:
+      case HPUX: 
+      case OPENKODE:         
+      case LINUX: */
       default:
-        throw new InternalError();
+        return unixLibName;
     }
   }
 
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index 0775f37..680d5be 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -26,18 +26,13 @@
  * or implied, of JogAmp Community.
  */
  
-/*
- * Created on Sunday, March 28 2010 14:43
- */
 package com.jogamp.common.os;
 
-import com.jogamp.common.nio.Buffers;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import jogamp.common.os.MachineDescriptionRuntime;
+
 /**
  * Utility class for querying platform specific properties.
  * @author Michael Bien
@@ -46,97 +41,157 @@ import java.security.PrivilegedAction;
 public class Platform {
 
     public static final boolean JAVA_SE;
-    public static final boolean LITTLE_ENDIAN;
     public static final String OS;
+    public static final String OS_lower;
     public static final String OS_VERSION;
     public static final String ARCH;
+    public static final String ARCH_lower;
     public static final String JAVA_VENDOR;
     public static final String JAVA_VENDOR_URL;
     public static final String JAVA_VERSION;
     public static final String NEWLINE;
 
+    public enum OSType {
+        LINUX(0), FREEBSD(1), DALVIK(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); 
+        
+        public final int id;
+
+        OSType(int id){
+            this.id = id;
+        }
+    }    
+    public static final OSType OS_TYPE;
+    
+    public enum CPUType {
+        X86(0), IA(1), ARM(2), SPARC(3), PA_RISC(4), PPC(5);
+        
+        public final int id;
+
+        CPUType(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 final int id;
+
+        CPUArch(int id){
+            this.id = id;
+        }
+    }      
+    public static final CPUArch CPU_ARCH;
+    
     private static final boolean is32Bit;
-    private static final int pointerSizeInBits;
-    private static final int pageSize;
 
+    private static final MachineDescription machineDescription;
+    
     static {
         
         // We don't seem to need an AccessController.doPrivileged() block
         // here as these system properties are visible even to unsigned
         // applets
         OS =  System.getProperty("os.name");
+        OS_lower = OS.toLowerCase();
         OS_VERSION =  System.getProperty("os.version");
         ARCH = System.getProperty("os.arch");
+        ARCH_lower = ARCH.toLowerCase();
         JAVA_VENDOR = System.getProperty("java.vendor");
         JAVA_VENDOR_URL = System.getProperty("java.vendor.url");
         JAVA_VERSION = System.getProperty("java.version");
         NEWLINE = System.getProperty("line.separator");
 
         JAVA_SE = initIsJavaSE();
-        LITTLE_ENDIAN = initByteOrder();
 
-        boolean libsLoaded = true;
-        try{
-            NativeLibrary.ensureNativeLibLoaded();
-        }catch (UnsatisfiedLinkError err){
-            libsLoaded = false;
-        }
+        if(        ARCH_lower.equals("x86")  ||
+                   ARCH_lower.equals("i386") ||
+                   ARCH_lower.equals("i486") ||
+                   ARCH_lower.equals("i586") ||
+                   ARCH_lower.equals("i686") ) {
+            CPU_ARCH = CPUArch.X86_32;
+            CPU_TYPE = CPUType.X86;
+        } else if( ARCH_lower.equals("x86_64") ||
+                   ARCH_lower.equals("amd64")  ) {
+            CPU_ARCH = CPUArch.X86_64;
+            CPU_TYPE = CPUType.X86;
+        } else if( ARCH_lower.equals("ia64") ) {
+            CPU_ARCH = CPUArch.IA64;
+            CPU_TYPE = CPUType.IA;
+        } else if( ARCH_lower.equals("arm") ) {
+            CPU_ARCH = CPUArch.ARM_32;
+            CPU_TYPE = CPUType.ARM;
+        } else if( ARCH_lower.equals("sparc") ) {
+            CPU_ARCH = CPUArch.SPARC_32;
+            CPU_TYPE = CPUType.SPARC;
+        } else if( ARCH_lower.equals("sparcv9") ) {
+            CPU_ARCH = CPUArch.SPARCV9_64;
+            CPU_TYPE = CPUType.SPARC;
+        } else if( ARCH_lower.equals("pa_risc2.0") ) {
+            CPU_ARCH = CPUArch.PA_RISC2_0;
+            CPU_TYPE = CPUType.PA_RISC;
+        } else if( ARCH_lower.equals("ppc") ) {
+            CPU_ARCH = CPUArch.PPC;
+            CPU_TYPE = CPUType.PPC;
+        } else {
+            throw new RuntimeException("Please port CPU detection to your platform (" + OS_lower + "/" + ARCH_lower + ")");
+        }               
+        OS_TYPE = getOSTypeImpl();
         
-        if(libsLoaded) {
-            pointerSizeInBits = getPointerSizeInBitsImpl();
-            final long pageSizeL =  getPageSizeImpl();
-            if(Integer.MAX_VALUE < pageSizeL) {
-                throw new InternalError("PageSize exceeds integer value: " + pageSizeL);
-            }
-            pageSize = (int) pageSizeL ;
-        }else{
-            pointerSizeInBits = -1;
-            pageSize = -1;
-        }
-
-        is32Bit = initArch();
-
+        machineDescription = MachineDescriptionRuntime.getMachineDescription(getIs32BitByCPUArchImpl());
+        is32Bit = machineDescription.is32Bit();
     }
 
     private Platform() {}
 
-    private static boolean initArch() throws RuntimeException {
-        if ( 32 == pointerSizeInBits || 64 == pointerSizeInBits ) {
-            return 32 == pointerSizeInBits;
-        }else {
-            String os_lc = OS.toLowerCase();
-            String arch_lc = ARCH.toLowerCase();
-
-            if ((os_lc.startsWith("windows") && arch_lc.equals("x86")) ||
-                (os_lc.startsWith("windows") && arch_lc.equals("arm")) ||
-                (os_lc.startsWith("linux") && arch_lc.equals("i386")) ||
-                (os_lc.startsWith("linux") && arch_lc.equals("x86")) ||
-                (os_lc.startsWith("mac os") && arch_lc.equals("ppc")) ||
-                (os_lc.startsWith("mac os") && arch_lc.equals("i386")) ||
-                (os_lc.startsWith("darwin") && arch_lc.equals("ppc")) ||
-                (os_lc.startsWith("darwin") && arch_lc.equals("i386")) ||
-                (os_lc.startsWith("sunos") && arch_lc.equals("sparc")) ||
-                (os_lc.startsWith("sunos") && arch_lc.equals("x86")) ||
-                (os_lc.startsWith("freebsd") && arch_lc.equals("i386")) ||
-                (os_lc.startsWith("hp-ux") && arch_lc.equals("pa_risc2.0"))) {
+    private static boolean getIs32BitByCPUArchImpl() throws RuntimeException {
+        switch( CPU_ARCH ) {
+            case X86_32:
+            case ARM_32:
+            case SPARC_32:
+            case PPC:
                 return true;
-            } else if ((os_lc.startsWith("windows") && arch_lc.equals("amd64")) ||
-                      (os_lc.startsWith("linux") && arch_lc.equals("amd64")) ||
-                      (os_lc.startsWith("linux") && arch_lc.equals("x86_64")) ||
-                      (os_lc.startsWith("linux") && arch_lc.equals("ia64")) ||
-                      (os_lc.startsWith("mac os") && arch_lc.equals("x86_64")) ||
-                      (os_lc.startsWith("darwin") && arch_lc.equals("x86_64")) ||
-                      (os_lc.startsWith("sunos") && arch_lc.equals("sparcv9")) ||
-                      (os_lc.startsWith("sunos") && arch_lc.equals("amd64"))) {
+            case X86_64:
+            case IA64:
+            case SPARCV9_64:
+            case PA_RISC2_0:
                 return false;
-            }else{
-              throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os_lc + "/" + arch_lc + ")");
-            }
+            default:
+                throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + Platform.OS_lower + "/" + Platform.ARCH_lower + "("+Platform.CPU_ARCH+"))");
         }
     }
-
+        
+    private static OSType getOSTypeImpl() throws RuntimeException {
+        if ( OS_lower.startsWith("linux") ) {
+            return OSType.LINUX;            
+        }
+        if ( OS_lower.startsWith("freebsd") ) {
+            return OSType.FREEBSD;            
+        }
+        if ( OS_lower.startsWith("dalvik") ) {
+            return OSType.DALVIK;            
+        }
+        if ( OS_lower.startsWith("mac os x") ||
+             OS_lower.startsWith("darwin") ) {
+            return OSType.MACOS;            
+        }
+        if ( OS_lower.startsWith("sunos") ) {
+            return OSType.SUNOS;            
+        }
+        if ( OS_lower.startsWith("hp-ux") ) {
+            return OSType.HPUX;            
+        }
+        if ( OS_lower.startsWith("windows") ) {
+            return OSType.WINDOWS;
+        }
+        if ( OS_lower.startsWith("kd") ) {
+            return OSType.OPENKODE;
+        }
+        throw new RuntimeException("Please port OS detection to your platform (" + OS_lower + "/" + ARCH_lower + ")");        
+    }
+    
     private static boolean initIsJavaSE() {
-
         // the fast path, check property Java SE instead of traversing through the ClassLoader
         String java_runtime_name = (String) AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
@@ -159,18 +214,6 @@ public class Platform {
         return false;
     }
 
-    private static boolean initByteOrder() {
-        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);
-    }
-
-    private static native int getPointerSizeInBitsImpl();
-    private static native long getPageSizeImpl();
-
-    
     /**
      * Returns true only if this program is running on the Java Standard Edition.
      */
@@ -178,13 +221,6 @@ public class Platform {
         return JAVA_SE;
     }
 
-    /**
-     * Returns true only if this system uses little endian byte ordering.
-     */
-    public static boolean isLittleEndian() {
-        return LITTLE_ENDIAN;
-    }
-
     /**
      * Returns the OS name.
      */
@@ -207,6 +243,27 @@ public class Platform {
         return ARCH;
     }
 
+    /**
+     * Returns the OS type.
+     */
+    public static OSType getOSType() {
+        return OS_TYPE;
+    }
+    
+    /**
+     * Returns the CPU type.
+     */
+    public static CPUType getCPUType() {
+        return CPU_TYPE;
+    }
+    
+    /**
+     * Returns the CPU architecture.
+     */
+    public static CPUArch getCPUArch() {
+        return CPU_ARCH;
+    }
+    
     /**
      * Returns the JAVA.
      */
@@ -236,37 +293,28 @@ public class Platform {
     }
 
     /**
-     * Returns true if this JVM is a 32bit JVM.
+     * Returns true if this JVM/ARCH is 32bit.
+     * <p>Shortcut to {@link #getMachineDescription()}.{@link MachineDescription#is32Bit() is32Bit()}</p>
      */
     public static boolean is32Bit() {
-        return is32Bit;
+        // return Platform.machineDescription.is32Bit();
+        return Platform.is32Bit; // used very often
     }
 
     /**
-     * Returns true if this JVM is a 64bit JVM.
+     * Returns true if this JVM/ARCH is 64bit.
+     * <p>Shortcut to {@link #getMachineDescription()}.{@link MachineDescription#is32Bit() is64Bit()}</p>
      */
     public static boolean is64Bit() {
-        return !is32Bit;
-    }
-
-    public static int getPointerSizeInBits() {
-        return pointerSizeInBits;
+        // return Platform.machineDescription.is64Bit();
+        return !Platform.is32Bit; // used very often
     }
 
-    public static int getPointerSizeInBytes() {
-        return pointerSizeInBits/8;
-    }
-
-    public static int getPageSize() {
-        return pageSize;
-    }
-
-    public static int getPageNumber(int size) {
-        return ( size + ( pageSize - 1) ) / pageSize ; // integer arithmetic
+    /**
+     * Returns the MachineDescription of the running machine.
+     */
+    public static MachineDescription getMachineDescription() {
+        return machineDescription;
     }
-    
-    public static int getPageAlignedSize(int size) {
-        return getPageNumber(size) * pageSize;
-    }    
 }
 
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java
index b2d9ed4..5b00fb4 100644
--- a/src/java/com/jogamp/common/util/IOUtil.java
+++ b/src/java/com/jogamp/common/util/IOUtil.java
@@ -42,6 +42,7 @@ import java.net.URLConnection;
 import java.nio.ByteBuffer;
 
 import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.os.MachineDescription;
 import com.jogamp.common.os.Platform;
 
 public class IOUtil {
@@ -81,7 +82,7 @@ public class IOUtil {
      * number of bytes written is returned.
      */
     public static int copyStream2Stream(InputStream in, OutputStream out, int totalNumBytes) throws IOException {
-        final byte[] buf = new byte[Platform.getPageSize()];
+        final byte[] buf = new byte[Platform.getMachineDescription().pageSizeInBytes()];
         int numBytes = 0;
         while (true) {
             int count;
@@ -137,16 +138,16 @@ public class IOUtil {
         if( !(stream instanceof BufferedInputStream) ) {
             stream = new BufferedInputStream(stream);
         }
-        int totalRead = 0;
         int avail = stream.available();
-        ByteBuffer data = Buffers.newDirectByteBuffer( Platform.getPageAlignedSize(avail) );
-        byte[] chunk = new byte[Platform.getPageSize()];
-        int chunk2Read = Math.min(Platform.getPageSize(), avail);
+        final MachineDescription machine = Platform.getMachineDescription(); 
+        ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize(avail) );
+        byte[] chunk = new byte[machine.pageSizeInBytes()];
+        int chunk2Read = Math.min(machine.pageSizeInBytes(), avail);
         int numRead = 0;
         do {
             if (avail > data.remaining()) {
-                final ByteBuffer newData = Buffers.newDirectByteBuffer( 
-                                               Platform.getPageAlignedSize(data.position() + avail) );
+                final ByteBuffer newData = Buffers.newDirectByteBuffer(
+                                               machine.pageAlignedSize(data.position() + avail) );
                 newData.put(data);
                 data = newData;
             }
@@ -154,10 +155,9 @@ public class IOUtil {
             numRead = stream.read(chunk, 0, chunk2Read);
             if (numRead >= 0) {
                 data.put(chunk, 0, numRead);
-                totalRead += numRead;
             }
             avail = stream.available();
-            chunk2Read = Math.min(Platform.getPageSize(), avail);
+            chunk2Read = Math.min(machine.pageSizeInBytes(), avail);
         } while (avail > 0 && numRead >= 0);
 
         data.flip();
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java
index 632e127..1589755 100644
--- a/src/java/com/jogamp/common/util/VersionUtil.java
+++ b/src/java/com/jogamp/common/util/VersionUtil.java
@@ -57,10 +57,7 @@ public class VersionUtil {
         sb.append(Platform.getArch()).append(" (arch) ").append(Runtime.getRuntime().availableProcessors()).append(" cores");
         sb.append(Platform.getNewline());
 
-        // arch
-        sb.append("Platform: littleEndian ").append(Platform.isLittleEndian()).append(", 32Bit ");
-        sb.append(Platform.is32Bit()).append(", a-ptr bit-size ").append(Platform.getPointerSizeInBits());
-        sb.append(Platform.getNewline());
+        Platform.getMachineDescription().toString(sb).append(Platform.getNewline());
 
         // JVM/JRE
         sb.append("Platform: Java ").append(Platform.getJavaVersion()).append(", ").append(System.getProperty("java.vm.name")).append(", ");
diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
index ba2eb17..d47cded 100644
--- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
@@ -43,6 +43,7 @@ import java.util.*;
 import java.io.*;
 import java.text.MessageFormat;
 
+import com.jogamp.common.os.MachineDescription;
 import com.jogamp.gluegen.cgram.types.*;
 import java.util.logging.Logger;
 
diff --git a/src/java/com/jogamp/gluegen/DebugEmitter.java b/src/java/com/jogamp/gluegen/DebugEmitter.java
index 22cc0c5..fc536c8 100644
--- a/src/java/com/jogamp/gluegen/DebugEmitter.java
+++ b/src/java/com/jogamp/gluegen/DebugEmitter.java
@@ -41,6 +41,7 @@ package com.jogamp.gluegen;
 
 import java.util.*;
 
+import com.jogamp.common.os.MachineDescription;
 import com.jogamp.gluegen.cgram.types.*;
 
 /** Debug emitter which prints the parsing results to standard output. */
diff --git a/src/java/com/jogamp/gluegen/GlueEmitter.java b/src/java/com/jogamp/gluegen/GlueEmitter.java
index 5f627f9..ed06b19 100644
--- a/src/java/com/jogamp/gluegen/GlueEmitter.java
+++ b/src/java/com/jogamp/gluegen/GlueEmitter.java
@@ -40,6 +40,8 @@
 package com.jogamp.gluegen;
 
 import java.util.*;
+
+import com.jogamp.common.os.MachineDescription;
 import com.jogamp.gluegen.cgram.types.*;
 
 /** Specifies the interface by which GlueGen requests glue code to be
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java
index 286aac4..c898058 100644
--- a/src/java/com/jogamp/gluegen/GlueGen.java
+++ b/src/java/com/jogamp/gluegen/GlueGen.java
@@ -40,9 +40,14 @@
 package com.jogamp.gluegen;
 
 import com.jogamp.common.GlueGenVersion;
+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.*;
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 745176a..d92e589 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -42,6 +42,8 @@ package com.jogamp.gluegen;
 
 import com.jogamp.common.nio.Buffers;
 import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.MachineDescription;
+
 import java.io.*;
 import java.util.*;
 import java.text.MessageFormat;
diff --git a/src/java/com/jogamp/gluegen/StructLayout.java b/src/java/com/jogamp/gluegen/StructLayout.java
index ea8768f..392e1b1 100644
--- a/src/java/com/jogamp/gluegen/StructLayout.java
+++ b/src/java/com/jogamp/gluegen/StructLayout.java
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -39,6 +40,7 @@
 
 package com.jogamp.gluegen;
 
+import com.jogamp.common.os.Platform;
 import com.jogamp.gluegen.cgram.types.*;
 
 /** Encapsulates algorithm for laying out data structures. Note that
@@ -119,36 +121,39 @@ public class StructLayout {
 
   
 
+  /**
+   * <P>See alignment in {@link com.jogamp.common.os.MachineDescription}.</p>
+   * 
+   * <P>The code is currently used at compile time {@link JavaEmitter#layoutStruct(CompoundType t)} once,
+   * and code for structs is emitted for generic 32bit and 64bit only {@link JavaEmitter#emitStruct(CompoundType structType, String alternateName)}.</p>
+   */
   public static StructLayout createForCurrentPlatform() {
-    // Note: this code is replicated in (from?) Platform.java
-    String os = System.getProperty("os.name").toLowerCase();
-    String cpu = System.getProperty("os.arch").toLowerCase();
-    if ((os.startsWith("windows") && cpu.equals("x86"))) {
-      // It appears that Windows uses a packing alignment of 4 bytes in 32-bit mode
+    final Platform.OSType osType = Platform.getOSType();
+    final Platform.CPUArch cpuArch = Platform.getCPUArch();
+    
+    if( ( Platform.OSType.WINDOWS == osType && Platform.CPUArch.X86_32 == cpuArch ) || // It appears that Windows uses a packing alignment of 4 bytes in 32-bit mode
+        ( Platform.CPUArch.ARM_32 == cpuArch ) 
+      ) {
       return new StructLayout(0, 4);
-    } else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
-               (os.startsWith("linux") && cpu.equals("i386")) ||
-               (os.startsWith("linux") && cpu.equals("x86")) ||
-               (os.startsWith("linux") && cpu.equals("amd64")) ||
-               (os.startsWith("linux") && cpu.equals("x86_64")) ||
-               (os.startsWith("linux") && cpu.equals("ia64")) ||
-               (os.startsWith("sunos") && cpu.equals("sparc")) ||
-               (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
-               (os.startsWith("sunos") && cpu.equals("x86")) ||
-               (os.startsWith("sunos") && cpu.equals("amd64")) ||
-               (os.startsWith("mac os") && cpu.equals("ppc")) ||
-               (os.startsWith("mac os") && cpu.equals("i386")) ||
-               (os.startsWith("mac os") && cpu.equals("x86_64")) ||
-               (os.startsWith("freebsd") && cpu.equals("i386")) ||
-               (os.startsWith("freebsd") && cpu.equals("amd64")) ||
-               (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))
+    } else if ((Platform.OSType.WINDOWS == osType && Platform.CPUArch.X86_64 == cpuArch) ||
+               (Platform.OSType.LINUX == osType   && Platform.CPUArch.X86_32 == cpuArch) ||
+               (Platform.OSType.LINUX == osType   && Platform.CPUArch.X86_64 == cpuArch) ||
+               (Platform.OSType.LINUX == osType   && Platform.CPUArch.IA64 == cpuArch) ||
+               (Platform.OSType.SUNOS == osType   && Platform.CPUArch.SPARC_32 == cpuArch) ||
+               (Platform.OSType.SUNOS == osType   && Platform.CPUArch.SPARCV9_64 == cpuArch) ||
+               (Platform.OSType.SUNOS == osType   && Platform.CPUArch.X86_32 == cpuArch) ||
+               (Platform.OSType.SUNOS == osType   && Platform.CPUArch.X86_64 == cpuArch) ||
+               (Platform.OSType.MACOS == osType   && Platform.CPUArch.PPC == cpuArch) ||
+               (Platform.OSType.MACOS == osType   && Platform.CPUArch.X86_32 == cpuArch) ||
+               (Platform.OSType.MACOS == osType   && Platform.CPUArch.X86_64 == cpuArch) ||
+               (Platform.OSType.FREEBSD == osType && Platform.CPUArch.X86_32 == cpuArch) ||
+               (Platform.OSType.FREEBSD == osType && Platform.CPUArch.X86_64 == cpuArch) ||
+               (Platform.OSType.HPUX == osType    && Platform.CPUArch.PA_RISC2_0 == cpuArch)
                ) {
-      // FIXME: make struct alignment configurable? May need to change
-      // packing rules on a per-type basis?
       return new StructLayout(0, 8);
     } else {
       // FIXME: add more ports
-      throw new RuntimeException("Please port StructLayout to your OS (" + os + ") and CPU (" + cpu + ")");
+      throw new RuntimeException("Please port StructLayout to your OS (" + osType + ") and CPU (" + cpuArch + ")");
     }
   }
 }
diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g b/src/java/com/jogamp/gluegen/cgram/GnuCParser.g
index 58d3171..e8ca8c5 100644
--- a/src/java/com/jogamp/gluegen/cgram/GnuCParser.g
+++ b/src/java/com/jogamp/gluegen/cgram/GnuCParser.g
@@ -313,6 +313,10 @@ typeSpecifier [int specCount] returns [int retSpecCount]
         |       "double"
         |       "signed"
         |       "unsigned"
+        |       "int8_t"
+        |       "uint8_t"
+        |       "int16_t"
+        |       "uint16_t"
         |       "__int32"
         |       "int32_t"
         |       "wchar_t"
diff --git a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g b/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g
index 1beeb7d..dbe2f98 100644
--- a/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g
+++ b/src/java/com/jogamp/gluegen/cgram/GnuCTreeParser.g
@@ -183,6 +183,10 @@ typeSpecifier
         |       "double"
         |       "signed"
         |       "unsigned"
+        |       "int8_t"
+        |       "uint8_t"
+        |       "int16_t"
+        |       "uint16_t"
         |       "__int32"
         |       "int32_t"
         |       "wchar_t"
diff --git a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
index a0d2a83..79f966f 100644
--- a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
+++ b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
@@ -504,11 +504,15 @@ typeSpecifier[int attributes] returns [Type t] {
         |       "long"      { t = new IntType("long" , SizeThunk.LONG,  unsigned, cvAttrs); }
         |       "float"     { t = new FloatType("float", SizeThunk.FLOAT, cvAttrs); }
         |       "double"    { t = new DoubleType("double", SizeThunk.DOUBLE, cvAttrs); }
-        |       "__int32"   { t = new IntType("__int32", SizeThunk.INT, unsigned, cvAttrs); }
-        |       "int32_t"   { t = new IntType("int32_t", SizeThunk.INT, false, cvAttrs); /* TS: always signed */ }
-        |       "wchar_t"   { t = new IntType("wchar_t", SizeThunk.INT, false, cvAttrs); /* TS: always signed */ }
-        |       "uint32_t"  { t = new IntType("uint32_t", SizeThunk.INT, true, cvAttrs, true); /* TS: always unsigned */ }
+        |       "__int32"   { t = new IntType("__int32", SizeThunk.INT32, unsigned, cvAttrs); }
         |       "__int64"   { t = new IntType("__int64", SizeThunk.INT64, unsigned, cvAttrs); }
+        |       "int8_t"    { t = new IntType("int8_t", SizeThunk.INT8, false, cvAttrs); /* TS: always signed */ }
+        |       "uint8_t"   { t = new IntType("uint8_t", SizeThunk.INT8, true, cvAttrs); /* TS: always unsigned */ }
+        |       "int16_t"   { t = new IntType("int16_t", SizeThunk.INT16, false, cvAttrs); /* TS: always signed */ }
+        |       "uint16_t"  { t = new IntType("uint16_t", SizeThunk.INT16, true, cvAttrs); /* TS: always unsigned */ }
+        |       "int32_t"   { t = new IntType("int32_t", SizeThunk.INT32, false, cvAttrs); /* TS: always signed */ }
+        |       "wchar_t"   { t = new IntType("wchar_t", SizeThunk.INT32, false, cvAttrs); /* TS: always signed */ }
+        |       "uint32_t"  { t = new IntType("uint32_t", SizeThunk.INT32, true, cvAttrs, true); /* TS: always unsigned */ }
         |       "int64_t"   { t = new IntType("int64_t", SizeThunk.INT64, false, cvAttrs); /* TS: always signed */ }
         |       "uint64_t"  { t = new IntType("uint64_t", SizeThunk.INT64, true, cvAttrs, true); /* TS: always unsigned */ }
         |       "ptrdiff_t" { t = new IntType("ptrdiff_t", SizeThunk.POINTER, false, cvAttrs); /* TS: always signed */ }
diff --git a/src/java/com/jogamp/gluegen/cgram/StdCParser.g b/src/java/com/jogamp/gluegen/cgram/StdCParser.g
index 231e371..7b34656 100644
--- a/src/java/com/jogamp/gluegen/cgram/StdCParser.g
+++ b/src/java/com/jogamp/gluegen/cgram/StdCParser.g
@@ -265,6 +265,10 @@ typeSpecifier [int specCount] returns [int retSpecCount]
         |       "double"
         |       "signed"
         |       "unsigned"
+        |       "int8_t"
+        |       "uint8_t"
+        |       "int16_t"
+        |       "uint16_t"
         |       "__int32"
         |       "int32_t"
         |       "wchar_t"
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Field.java b/src/java/com/jogamp/gluegen/cgram/types/Field.java
index 07d90ea..2479e3d 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Field.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/Field.java
@@ -39,6 +39,8 @@
 
 package com.jogamp.gluegen.cgram.types;
 
+import com.jogamp.common.os.MachineDescription;
+
 /** Represents a field in a struct or union. */
 
 public class Field {
diff --git a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription.java b/src/java/com/jogamp/gluegen/cgram/types/MachineDescription.java
deleted file mode 100644
index d2598e0..0000000
--- a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. 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 com.jogamp.gluegen.cgram.types;
-
-public class MachineDescription {
-  private int charSizeInBytes;
-  private int shortSizeInBytes;
-  private int intSizeInBytes;
-  private int longSizeInBytes;
-  private int int64SizeInBytes;
-  private int floatSizeInBytes;
-  private int doubleSizeInBytes;
-  private int pointerSizeInBytes;
-  private int structAlignmentInBytes;
-
-  public MachineDescription(int charSizeInBytes,
-                            int shortSizeInBytes,
-                            int intSizeInBytes,
-                            int longSizeInBytes,
-                            int int64SizeInBytes,
-                            int floatSizeInBytes,
-                            int doubleSizeInBytes,
-                            int pointerSizeInBytes,
-                            int structAlignmentInBytes) {
-    this.charSizeInBytes    = charSizeInBytes;
-    this.shortSizeInBytes   = shortSizeInBytes;
-    this.intSizeInBytes     = intSizeInBytes;
-    this.longSizeInBytes    = longSizeInBytes;
-    this.int64SizeInBytes   = int64SizeInBytes;
-    this.floatSizeInBytes   = floatSizeInBytes;
-    this.doubleSizeInBytes  = doubleSizeInBytes;
-    this.pointerSizeInBytes = pointerSizeInBytes;
-    this.structAlignmentInBytes = structAlignmentInBytes;
-  }
-
-  public int charSizeInBytes()    { return charSizeInBytes;   }
-  public int shortSizeInBytes()   { return shortSizeInBytes;  }
-  public int intSizeInBytes()     { return intSizeInBytes;    }
-  public int longSizeInBytes()    { return longSizeInBytes;   }
-  public int int64SizeInBytes()   { return int64SizeInBytes;  }
-  public int floatSizeInBytes()   { return floatSizeInBytes;  }
-  public int doubleSizeInBytes()  { return doubleSizeInBytes; }
-  public int pointerSizeInBytes() { return pointerSizeInBytes; }
-  public int structAlignmentInBytes() { return structAlignmentInBytes; }
-}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription32Bit.java b/src/java/com/jogamp/gluegen/cgram/types/MachineDescription32Bit.java
deleted file mode 100644
index 6bbb801..0000000
--- a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription32Bit.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. 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 com.jogamp.gluegen.cgram.types;
-
-public class MachineDescription32Bit extends MachineDescription {
-  public MachineDescription32Bit() {
-    super(1, 2, 4, 4, 8, 4, 8, 4, 8);
-  }
-}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription64Bit.java b/src/java/com/jogamp/gluegen/cgram/types/MachineDescription64Bit.java
deleted file mode 100644
index 38328e4..0000000
--- a/src/java/com/jogamp/gluegen/cgram/types/MachineDescription64Bit.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. 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 com.jogamp.gluegen.cgram.types;
-
-public class MachineDescription64Bit extends MachineDescription {
-  public MachineDescription64Bit() {
-    super(1, 2, 4, 8, 8, 4, 8, 8, 16);
-  }
-}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java
index 40ddd57..1584a13 100755
--- a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java
@@ -40,6 +40,8 @@
 
 package com.jogamp.gluegen.cgram.types;
 
+import com.jogamp.common.os.MachineDescription;
+
 /** Provides a level of indirection between the definition of a type's
     size and the absolute value of this size. Necessary when
     generating glue code for two different CPU architectures (e.g.,
@@ -84,6 +86,24 @@ public abstract class SizeThunk implements Cloneable {
       }
     };
 
+  public static final SizeThunk INT8 = new SizeThunk() {
+      public long compute(MachineDescription machDesc) {
+        return machDesc.int8SizeInBytes();
+      }
+    };
+
+  public static final SizeThunk INT16 = new SizeThunk() {
+      public long compute(MachineDescription machDesc) {
+        return machDesc.int16SizeInBytes();
+      }
+    };
+
+  public static final SizeThunk INT32 = new SizeThunk() {
+      public long compute(MachineDescription machDesc) {
+        return machDesc.int32SizeInBytes();
+      }
+    };
+
   public static final SizeThunk INT64 = new SizeThunk() {
       public long compute(MachineDescription machDesc) {
         return machDesc.int64SizeInBytes();
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java
index c58bfae..95afc2c 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Type.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java
@@ -42,6 +42,8 @@ package com.jogamp.gluegen.cgram.types;
 
 import java.util.List;
 
+import com.jogamp.common.os.MachineDescription;
+
 /** Models a C type. Primitive types include int, float, and
     double. All types have an associated name. Structs and unions are
     modeled as "compound" types -- composed of fields of primitive or
diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html
index 2862fe6..f8a2e6d 100644
--- a/src/java/com/jogamp/gluegen/package.html
+++ b/src/java/com/jogamp/gluegen/package.html
@@ -9,32 +9,80 @@
   Gluegen has build-in types (terminal symbols) for:<br/>
   <br/>
   <table border="1">
-    <tr><th>type</th>      <th>java bits</th> <th>native-x32 bits</th><th>native-x64 bits</th><th>type</th>   <th>signed</th>            <th>origin</th</tr>
-    <tr><th>void</th>      <th> 0</th>        <th> 0</th>             <th> 0</th>             <th>void</th>   <th>void</th>              <th>ANSI-C</th></tr>
-    <tr><th>char</th>      <th> 8</th>        <th> 8</th>             <th> 8</th>             <th>integer</th><th>signed or unsigned</th><th>ANSI-C</th></tr>
-    <tr><th>short</th>     <th>16</th>        <th>16</th>             <th>16</th>             <th>integer</th><th>signed or unsigned</th><th>ANSI-C</th></tr>
-    <tr><th>int</th>       <th>32</th>        <th>32</th>             <th>32</th>             <th>integer</th><th>signed or unsigned</th><th>ANSI-C</th></tr>
-    <tr><th>long</th>      <th>64</th>        <th>32</th>             <th>32<sup>1</sup></th> <th>integer</th><th>signed or unsigned</th><th>Windows</th></tr>
-    <tr><th>long</th>      <th>64</th>        <th>32</th>             <th>64</th>             <th>integer</th><th>signed or unsigned</th><th>Unix</th></tr>
-    <tr><th>float</th>     <th>32</th>        <th>32</th>             <th>32</th>             <th>float</th>  <th>signed</th>            <th>ANSI-C</th></tr>
-    <tr><th>double</th>    <th>64</th>        <th>64</th>             <th>64</th>             <th>double</th> <th>signed</th>            <th>ANSI-C</th></tr>
-    <tr><th>__int32</th>   <th>32</th>        <th>32</th>             <th>32</th>             <th>integer</th><th>signed or unsigned</th><th>windows</th></tr>
-    <tr><th>int32_t</th>   <th>32</th>        <th>32</th>             <th>32</th>             <th>integer</th><th>signed</th>            <th>stdint.h</th></tr>
-    <tr><th>wchar_t</th>   <th>32</th>        <th>32</th>             <th>32</th>             <th>integer</th><th>signed</th>            <th>stddef.h</th></tr>
-    <tr><th>uint32_t</th>  <th>32</th>        <th>32</th>             <th>32</th>             <th>integer</th><th>unsigned</th>          <th>stdint.h</th></tr>
-    <tr><th>__int64</th>   <th>64</th>        <th>64</th>             <th>64</th>             <th>integer</th><th>signed or unsigned</th><th>windows</th></tr>
-    <tr><th>int64_t</th>   <th>64</th>        <th>64</th>             <th>64</th>             <th>integer</th><th>signed</th>            <th>stdint.h</th></tr>
-    <tr><th>uint64_t</th>  <th>64</th>        <th>64</th>             <th>64</th>             <th>integer</th><th>unsigned</th>          <th>stdint.h</th></tr>
-    <tr><th>ptrdiff_t</th> <th>64</th>        <th>32</th>             <th>64</th>             <th>integer</th><th>signed</th>            <th>stddef.h</th></tr>
-    <tr><th>intptr_t</th>  <th>64</th>        <th>32</th>             <th>64</th>             <th>integer</th><th>signed</th>            <th>stdint.h</th></tr>
-    <tr><th>size_t</th>    <th>64</th>        <th>32</th>             <th>64</th>             <th>integer</th><th>unsigned</th>          <th>stddef.h</th></tr>
-    <tr><th>uintptr_t</th> <th>64</th>        <th>32</th>             <th>64</th>             <th>integer</th><th>unsigned</th>          <th>stdint.h</th></tr>
+    <tr><th>type</th>      <th>java bits</th> <th colspan="2">native bits</th>                <th>type</th>   <th>signed</th>            <th>origin</th></tr>
+    <tr><th></th>          <th></th>          <th>x32</th>            <th>x64</th>            <th></th>       <th></th>                  <th></th></tr>
+    <tr><td>void</td>      <td> 0</td>        <td> 0</td>             <td> 0</td>             <td>void</td>   <td>void</td>              <td>ANSI-C</td></tr>
+    <tr><td>char</td>      <td> 8</td>        <td> 8</td>             <td> 8</td>             <td>integer</td><td>any</td>               <td>ANSI-C</td></tr>
+    <tr><td>short</td>     <td>16</td>        <td>16</td>             <td>16</td>             <td>integer</td><td>any</td>               <td>ANSI-C</td></tr>
+    <tr><td>int</td>       <td>32</td>        <td>32</td>             <td>32</td>             <td>integer</td><td>any</td>               <td>ANSI-C</td></tr>
+    <tr><td>long</td>      <td>64</td>        <td>32</td>             <td><b>32<sup>1</sup></b></td> <td>integer</td><td>any</td>               <td>ANSI-C - Windows</td></tr>
+    <tr><td>long</td>      <td>64</td>        <td>32</td>             <td><b>64</b></td>      <td>integer</td><td>any</td>               <td>ANSI-C - Unix</td></tr>
+    <tr><td>float</td>     <td>32</td>        <td>32</td>             <td>32</td>             <td>float</td>  <td>signed</td>            <td>ANSI-C</td></tr>
+    <tr><td>double</td>    <td>64</td>        <td>64</td>             <td>64</td>             <td>double</td> <td>signed</td>            <td>ANSI-C</td></tr>
+    <tr><td>__int32</td>   <td>32</td>        <td>32</td>             <td>32</td>             <td>integer</td><td>any</td>               <td>windows</td></tr>
+    <tr><td>__int64</td>   <td>64</td>        <td>64</td>             <td>64</td>             <td>integer</td><td>any</td>               <td>windows</td></tr>
+    <tr><td>int8_t</td>    <td> 8</td>        <td> 8</td>             <td> 8</td>             <td>integer</td><td>signed</td>            <td>stdint.h</td></tr>
+    <tr><td>uint8_t</td>   <td> 8</td>        <td> 8</td>             <td> 8</td>             <td>integer</td><td>unsigned</td>          <td>stdint.h</td></tr>
+    <tr><td>int16_t</td>   <td>16</td>        <td>16</td>             <td>16</td>             <td>integer</td><td>signed</td>            <td>stdint.h</td></tr>
+    <tr><td>uint16_t</td>  <td>16</td>        <td>16</td>             <td>16</td>             <td>integer</td><td>unsigned</td>          <td>stdint.h</td></tr>
+    <tr><td>int32_t</td>   <td>32</td>        <td>32</td>             <td>32</td>             <td>integer</td><td>signed</td>            <td>stdint.h</td></tr>
+    <tr><td>uint32_t</td>  <td>32</td>        <td>32</td>             <td>32</td>             <td>integer</td><td>unsigned</td>          <td>stdint.h</td></tr>
+    <tr><td>int64_t</td>   <td>64</td>        <td>64</td>             <td>64</td>             <td>integer</td><td>signed</td>            <td>stdint.h</td></tr>
+    <tr><td>uint64_t</td>  <td>64</td>        <td>64</td>             <td>64</td>             <td>integer</td><td>unsigned</td>          <td>stdint.h</td></tr>
+    <tr><td>intptr_t</td>  <td>64</td>        <td>32</td>             <td>64</td>             <td>integer</td><td>signed</td>            <td>stdint.h</td></tr>
+    <tr><td>uintptr_t</td> <td>64</td>        <td>32</td>             <td>64</td>             <td>integer</td><td>unsigned</td>          <td>stdint.h</td></tr>
+    <tr><td>ptrdiff_t</td> <td>64</td>        <td>32</td>             <td>64</td>             <td>integer</td><td>signed</td>            <td>stddef.h</td></tr>
+    <tr><td>size_t</td>    <td>64</td>        <td>32</td>             <td>64</td>             <td>integer</td><td>unsigned</td>          <td>stddef.h</td></tr>
+    <tr><td>wchar_t</td>   <td>32</td>        <td>32</td>             <td>32</td>             <td>integer</td><td>signed</td>            <td>stddef.h</td></tr>
   </table>
   <p>
   <b>Warning:</b> Try to avoid unspecified bit sized types, especially <b>long</b>, since it differs on Unix and Windows!<br/>
   <b>Note 1:</b>  Type <b>long</b> will result in broken code on Windows, since we don't differentiate the OS and it's bit size is ambiguous.
   </p>
-  <p>
+  
+  <h4>GlueGen Internal Alignment for Compound Data</h4>
+  In general, depending on CPU and it's configuration (OS), alignment is set up 
+  for each type (char, short, int, long, ..),<br>
+  where structures are aligned naturally, i.e. their inner components are aligned.<br>
+  See:<br>
+  <ul>
+   <li><a href="http://en.wikipedia.org/wiki/Data_structure_alignment">Wikipedia Data Structure Alignment</a></li>
+   <li><a href="http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding">Wikipedia Data Structure Alignment - Padding</a></li>
+   <li><a href="http://www.viva64.com/en/l/0021/">Viva64 Data Alignment</a></li>
+   <li><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-CH207-SW1">Apple: Darwin 64bit Porting - Data Type Size &amp; Alignment</a></li>
+  </ul>
+  
+  <h5>Type Size &amp; Alignment for x86, x86_64, armv7l-32bit-eabi and Window(mingw/mingw64)</h5>
+  Runtime query is implemented as follows: 
+  <pre>
+   typedef struct {
+     _TYPE_ s0;    // ensures start address alignment
+     char   fill;  // nibble one byte
+                   // padding to align s1 
+     _TYPE_ s1;    // 
+   } type_t;
+  
+     padding = sizeof(type_t) - 2 * sizeof(_TYPE_) - sizeof(char);
+   alignment = sizeof(type_t) - 2 * sizeof(_TYPE_) ;
+  </pre>
+  <table border="1">
+    <tr><th>type</th>      <th colspan="2">32 bits</th><th colspan="2">64 bits</th></tr>
+    <tr><th></th>          <th>size</th><th>alignment</th><th>size</th><th>alignment</th></tr>
+    <tr><td>char</td>      <td> 1</td>        <td>  1</td>    <td> 1</td> <td> 1</td></tr>
+    <tr><td>short</td>     <td> 2</td>        <td>  2</td>    <td> 2</td> <td> 2</td></tr>
+    <tr><td>int</td>       <td> 4</td>        <td>  4</td>    <td> 4</td> <td> 4</td></tr>
+    <tr><td>float</td>     <td> 4</td>        <td>  4</td>    <td> 4</td> <td> 4</td></tr>
+    <tr><td>long</td>      <td> 4</td>        <td>  4</td>    <td> 8<sup>&dagger;</sup>,4<sup>&lowast;</sup></td> <td> 8<sup>&dagger;</sup>,4<sup>&lowast;</sup></td></tr>
+    <tr><td>pointer</td>   <td> 4</td>        <td>  4</td>    <td> 8</td> <td> 8</td></tr>
+    <tr><td>long long</td> <td> 8</td> <td>4<sup>&dagger;</sup>,8<sup>&lowast;</sup><sup>+</sup></td>    <td> 8</td> <td> 8</td></tr>
+    <tr><td>double</td>    <td> 8</td> <td>4<sup>&dagger;</sup>,8<sup>&lowast;</sup><sup>+</sup></td>    <td> 8</td> <td> 8</td></tr>
+    <tr><td>long double</td><td>12<sup>&dagger;</sup><sup>&lowast;</sup>,8<sup>+</sup></td> <td>4<sup>&dagger;</sup><sup>&lowast;</sup>,8<sup>+</sup></td>    <td> 16</td> <td>16</td></tr>
+  </table><br>
+  <sup>&dagger;</sup> Linux, Darwin<br>
+  <sup>+</sup>armv7l-32bit-eabi (linux)<br>
+  <sup>&lowast;</sup> Windows<br>
+  </P>
+ 
   <h4>GlueGen Platform Header Files</h4>
   GlueGen provides convenient platform headers,<br/>
   which can be included in your C header files for native compilation and GlueGen code generation.<br/>
diff --git a/src/java/jogamp/common/os/MachineDescription32Bit.java b/src/java/jogamp/common/os/MachineDescription32Bit.java
new file mode 100644
index 0000000..ec2bb4c
--- /dev/null
+++ b/src/java/jogamp/common/os/MachineDescription32Bit.java
@@ -0,0 +1,61 @@
+/*
+ * 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:      char, short, int, long, float, double, pointer, pageSize
+    // alignment: int8, int16, int32, int64, char, short, int, long, float, double, pointer
+    super( false /* runtime validated */, true /* little endian */,
+           /* size */ 1, 2, 4, 4, 4, 8, 4, 4096,
+           /*align */ 1, 2, 4, 8, 1, 2, 4, 4, 4, 8, 4);
+    
+  }
+}
diff --git a/src/java/jogamp/common/os/MachineDescription64Bit.java b/src/java/jogamp/common/os/MachineDescription64Bit.java
new file mode 100644
index 0000000..254ba30
--- /dev/null
+++ b/src/java/jogamp/common/os/MachineDescription64Bit.java
@@ -0,0 +1,61 @@
+/*
+ * 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:      char, short, int, long, float, double, pointer, pageSize
+    // alignment: int8, int16, int32, int64, char, short, int, long, float, double, pointer
+    super( false /* runtime validated */, true /* little endian */, 
+           /* size */ 1, 2, 4, 8 /* on win, long is 4 !!! */, 4, 8, 8, 4096,
+           /*align */ 1, 2, 4, 8, 1, 2, 4, 8, 4, 8, 8);
+  }
+}
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);
     }
 
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 c57a288..df3df83 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java
@@ -532,5 +532,80 @@ public class BaseClass {
           i = binding.intArrayRead(iarray, 0, 3);
           Assert.assertTrue("Wrong result: "+i, 6==i);
     }
+    
+    void assertAPTR(final long expected, final long actual) {
+        System.err.println("0x"+Long.toHexString(expected)+" == 0x"+Long.toHexString(actual));
+        if (Platform.is32Bit()) {
+            int exp32;
+            int act32;
+            // if(Platform.isLittleEndian()) {
+                exp32 = (int) ( expected ) ;
+                act32 = (int) ( actual ) ;                
+            /* } else {
+                exp32 = (int) ( expected >> 32 ) ;
+                act32 = (int) ( actual >> 32 ) ;
+            } */
+            System.err.println("0x"+Integer.toHexString(exp32)+" == 0x"+Integer.toHexString(act32));
+            Assert.assertEquals(exp32, act32);
+        } else {
+            Assert.assertEquals(expected, actual);
+        }        
+    }
+    
+    public void chapter09TestCompoundAndAlignment(Bindingtest1 binding) throws Exception {
+        TK_ComplicatedSuperSet cs =  binding.createComplicatedSuperSet();
+        Assert.assertEquals((byte)0xA0, cs.getBits1());
+        
+        TK_ComplicatedSubSet sub1 =  cs.getSub1();
+        Assert.assertEquals((byte)0xA1, sub1.getBits1());
+        Assert.assertEquals(0x12345678, sub1.getId());
+        Assert.assertEquals((byte)0xA2, sub1.getBits2());
+        Assert.assertEquals(0x123456789abcdef0L, sub1.getLong0());
+        Assert.assertEquals((byte)0xA3, sub1.getBits3());
+        Assert.assertEquals(3.1415926535897932384626433832795, sub1.getReal0(), 0.0);
+        Assert.assertEquals((byte)0xA4, sub1.getBits4());
+
+        Assert.assertEquals((byte)0xB0, cs.getBits2());
+        
+        TK_ComplicatedSubSet sub2 =  cs.getSub2();
+        Assert.assertEquals((byte)0xB1, sub2.getBits1());
+        Assert.assertEquals(0x12345678, sub2.getId());
+        Assert.assertEquals((byte)0xB2, sub2.getBits2());
+        Assert.assertEquals(0x123456789abcdef0L, sub2.getLong0());
+        Assert.assertEquals((byte)0xB3, sub2.getBits3());
+        Assert.assertEquals(3.1415926535897932384626433832795, sub2.getReal0(), 0.0);
+        Assert.assertEquals((byte)0xB4, sub2.getBits4());
+        
+        Assert.assertEquals((byte)0xC0, cs.getBits3());
+        
+        binding.destroyComplicatedSuperSet(cs);
+        
+        /********************************************************************************/
+        
+        TK_Surface surface = binding.createSurface();
+        
+        assertAPTR(0x123456789abcdef0L, surface.getCtx());
+        
+        TK_Engine engine = surface.getEngine();
+        assertAPTR(0x123456789abcdef0L, engine.getCtx());
+        Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001));
+        
+        TK_Dimension dimension = surface.getBounds();
+        Assert.assertEquals(0x11111111, dimension.getX());
+        Assert.assertEquals(0x22222222, dimension.getY());
+        Assert.assertEquals(0x33333333, dimension.getWidth());
+        Assert.assertEquals(0x44444444, dimension.getHeight());
+
+        Assert.assertEquals(2, surface.getClipSize());
+        
+        for(int i=0; i<surface.getClipSize(); i++) {
+            TK_Dimension clip = surface.getClip(i);
+            Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip.getX());
+            Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip.getY());
+            Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, clip.getWidth());
+            Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, clip.getHeight());
+        }
+        binding.destroySurface(surface);
+    }
 
 }
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java
index 73950eb..3b883aa 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java
@@ -31,6 +31,8 @@ package com.jogamp.gluegen.test.junit.generation;
 import java.io.File;
 import java.net.URISyntaxException;
 
+import com.jogamp.common.util.VersionUtil;
+
 import static java.lang.System.*;
 
 /**
@@ -46,7 +48,7 @@ public final class BuildEnvironment {
     static {
 
         out.println(" - - - System info - - - ");
-        out.println("OS: " + System.getProperty("os.name"));
+        out.println(VersionUtil.getPlatformInfo());
         out.println("VM: " + System.getProperty("java.vm.name"));
 
         String rootrel_build_tmp = System.getProperty("rootrel.build");
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
index 83faa9b..35907de 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java
@@ -105,6 +105,14 @@ public class Test1p1JavaEmitter extends BaseClass {
         chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p1Impl());
     }
 
+    /**
+     * This covers compounds (structs) and data alignment
+     */
+    @Test
+    public void chapter09TestCompoundAndAlignment() throws Exception {
+        chapter09TestCompoundAndAlignment(new Bindingtest1p1Impl());
+    }
+
     public static void main(String args[]) throws IOException {
         String tstname = Test1p1JavaEmitter.class.getName();
         org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
index 8fe4f86..cd6e85d 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java
@@ -115,6 +115,14 @@ public class Test1p2ProcAddressEmitter extends BaseClass {
         chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p2Impl());
     }
 
+    /**
+     * This covers compounds (structs) and data alignment
+     */
+    @Test
+    public void chapter09TestCompoundAndAlignment() throws Exception {
+        chapter09TestCompoundAndAlignment(new Bindingtest1p1Impl());
+    }
+    
     public static void main(String args[]) throws IOException {
         String tstname = Test1p2ProcAddressEmitter.class.getName();
         org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
index 30cdd96..c6e5415 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-common.cfg
@@ -25,11 +25,31 @@ Opaque long MYAPIConfig
 
 CustomCCode #include "test1.h"
 
+Opaque long TK_Context
+
+StructPackage TK_Surface com.jogamp.gluegen.test.junit.generation
+EmitStruct TK_Surface
+# Implements TK_Surface TḴ_???
+
+StructPackage TK_ComplicatedSuperSet com.jogamp.gluegen.test.junit.generation
+EmitStruct TK_ComplicatedSuperSet
+# Implements TK_ComplicatedSuperSet TḴ_???
+
+ReturnValueCapacity createSurface sizeof(TK_Surface)
+ReturnValueCapacity getClip sizeof(TK_Dimension)
+
+ReturnValueCapacity createComplicatedSuperSet sizeof(TK_ComplicatedSuperSet)
+
 # Imports needed by all glue code
 Import java.nio.*
 Import java.util.*
 Import com.jogamp.common.os.*
 Import com.jogamp.common.nio.*
+Import com.jogamp.gluegen.test.junit.generation.TK_Surface
+Import com.jogamp.gluegen.test.junit.generation.TK_Dimension
+Import com.jogamp.gluegen.test.junit.generation.TK_Engine
+Import com.jogamp.gluegen.test.junit.generation.TK_ComplicatedSuperSet
+Import com.jogamp.gluegen.test.junit.generation.TK_ComplicatedSubSet
 
 
 
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg
index 197b081..bb5eb80 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1-gluegen.cfg
@@ -3,6 +3,7 @@ Style AllStatic
 JavaClass Bindingtest1
 Style InterfaceOnly
 JavaOutputDir classes
+NativeOutputDir native
 
 Include test1-common.cfg
 
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
index 05a9889..0876403 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.c
@@ -234,4 +234,85 @@ MYAPI uintptr_t MYAPIENTRY typeTestUIntPtrT(const uintptr_t ptr1, uintptr_t ptr2
     return ptr1 + ptr2;
 }
 
+static TK_Dimension * _TK_getClip(TK_Surface * surface, int idx) {
+    return & ( surface->clips[idx] ) ;
+}
+
+static int32_t _TK_render (int x, int y, int ps) {
+    return x + y + ps ;
+}
+
+MYAPI TK_Surface * MYAPIENTRY createSurface() {
+    TK_Surface * s = calloc(1, sizeof(TK_Surface));
+
+    s->getClip = _TK_getClip;
+
+    s->ctx = (void *) 0x123456789abcdef0UL;
+    //s->engine = (TK_Engine *) calloc(1, sizeof(TK_Engine));
+    //s->engine->ctx    = (void *) 0x123456789abcdef0UL;
+    //s->engine->render = _TK_render;
+    s->engine.ctx    = (void *) 0x123456789abcdef0UL;
+    s->engine.render = _TK_render;
+
+    s->bounds.x      = 0x11111111U;
+    s->bounds.y      = 0x22222222U;
+    s->bounds.width  = 0x33333333U;
+    s->bounds.height = 0x44444444U;
+
+    s->clipSize = 2;
+    s->clips = (TK_Dimension *) calloc(2, sizeof(TK_Dimension));
+    s->clips[0].x      = 0x55555555U;
+    s->clips[0].y      = 0x66666666U;
+    s->clips[0].width  = 0x77777777U;
+    s->clips[0].height = 0x88888888U;
+    s->clips[1].x      = 0x99999999U;
+    s->clips[1].y      = 0xaaaaaaaaU;
+    s->clips[1].width  = 0xbbbbbbbbU;
+    s->clips[1].height = 0xccccccccU;
+
+    return s;
+}
+
+MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface) {
+    free(surface->clips);
+    // free(surface->engine);
+    free(surface);
+}
+
+MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet() {
+    TK_ComplicatedSuperSet * s = calloc(1, sizeof(TK_ComplicatedSuperSet));
+
+    s->bits1 = 0xA0U;
+    s->sub1.bits1 = 0xA1U;
+    s->sub1.id = 0x12345678U;
+    s->sub1.bits2 = 0xA2U;
+    s->sub1.long0 = 0x123456789abcdef0UL;
+    s->sub1.bits3 = 0xA3U;
+    s->sub1.real0 = 3.1415926535897932384626433832795L;
+    s->sub1.bits4 = 0xA4U;
+    s->bits2 = 0xB0U;
+    s->sub2.bits1 = 0xB1U;
+    s->sub2.id = 0x12345678U;
+    s->sub2.bits2 = 0xB2U;
+    s->sub2.long0 = 0x123456789abcdef0UL;
+    s->sub2.bits3 = 0xB3U;
+    s->sub2.real0 = 3.1415926535897932384626433832795L;
+    s->sub2.bits4 = 0xB4U;
+    s->bits3 = 0xC0U;
+
+    fprintf(stderr, "TK_ComplicatedSubSet: sizeof(): %ld\n", (long) sizeof(TK_ComplicatedSubSet));
+    fprintf(stderr, "TK_ComplicatedSubSet: bits2-s offset: %ld\n", (long) ((void *)(&s->sub1.bits2) - (void *)(&s->sub1)) );
+    fprintf(stderr, "TK_ComplicatedSubSet: bits3-s offset: %ld\n", (long) ((void *)(&s->sub1.bits3) - (void *)(&s->sub1)) );
+    fprintf(stderr, "TK_ComplicatedSubSet: bits4-s offset: %ld\n", (long) ((void *)(&s->sub1.bits4) - (void *)(&s->sub1)) );
+
+    fprintf(stderr, "TK_ComplicatedSuperSet: sizeof(): %ld\n", (long) sizeof(TK_ComplicatedSuperSet));
+    fprintf(stderr, "TK_ComplicatedSuperSet: bits2-s offset: %ld\n", (long) ((void *)(&s->bits2) - (void *)(s)) );
+    fprintf(stderr, "TK_ComplicatedSuperSet: bits3-s offset: %ld\n", (long) ((void *)(&s->bits3) - (void *)(s)) );
+
+    return s;
+}
+
+MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s) {
+    free(s);
+}
 
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index 5b1c241..041a8d2 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -125,3 +125,65 @@ MYAPI uintptr_t MYAPIENTRY typeTestUIntPtrT(const uintptr_t ptr1, uintptr_t ptr2
     #warning "Hello Native Compiler"
 #endif
 
+typedef struct {
+    int32_t x;
+    int32_t y;
+    int32_t width;
+    int32_t height;
+} TK_Dimension;
+
+typedef struct _TK_Context * TK_Context; // anonymous
+
+typedef struct {
+    TK_Context ctx;
+    int32_t (MYAPIENTRY *render) (int x, int y, int ps);
+} TK_Engine;
+
+typedef struct tk_Surface {
+    TK_Context ctx;
+    // const TK_Engine * engine;
+    TK_Engine engine;
+    TK_Dimension bounds;
+    int32_t clipSize;
+    TK_Dimension * clips;
+    TK_Dimension * (MYAPIENTRY *getClip) (struct tk_Surface * ds, int idx);
+} TK_Surface;
+
+typedef struct {
+    int8_t bits1;  // +1
+                   // +3 (p64)
+    int32_t id;    // +4
+    int8_t bits2;  // +1
+                   // +7 (p64)
+    int64_t long0; // +8
+    int8_t bits3;  // +1
+                   // +7 (p64)
+    double real0;  // +8
+    int8_t bits4;  // +1
+                   // +7 (p64) (for next struct ..)
+
+                   // 24 net 
+
+                   // 48 gross 64bit/linux 
+} TK_ComplicatedSubSet;
+
+typedef struct {
+    int8_t bits1;              // + 1
+                               // + 7 (p64)
+    TK_ComplicatedSubSet sub1; // +48 (64bit)
+    int8_t bits2;              // + 1
+                               // + 7 (p64)
+    TK_ComplicatedSubSet sub2; // +48 (64bit)
+    int8_t bits3;              // + 1
+                               // + 7 (p64)
+
+                               //  51 net
+
+                               // 120 gross 64bit/linux 
+} TK_ComplicatedSuperSet;
+
+MYAPI TK_Surface * MYAPIENTRY createSurface();
+MYAPI void MYAPIENTRY destroySurface(TK_Surface * surface);
+
+MYAPI TK_ComplicatedSuperSet * MYAPIENTRY createComplicatedSuperSet();
+MYAPI void MYAPIENTRY destroyComplicatedSuperSet(TK_ComplicatedSuperSet * s);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
index 649499d..708bd26 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1p2-gluegen.cfg
@@ -22,7 +22,6 @@ ForceProcAddressGen __ALL__
 LocalProcAddressCallingConvention __ALL__ MYAPIENTRY
 
 Include test1-common.cfg
-Include ../../../../../../../../make/config/intptr.cfg
 
 Import com.jogamp.gluegen.test.junit.generation.Bindingtest1
 Import com.jogamp.gluegen.test.junit.generation.Bindingtest1p2
diff --git a/src/native/common/MachineDescriptionRuntime.c b/src/native/common/MachineDescriptionRuntime.c
new file mode 100644
index 0000000..4cd6088
--- /dev/null
+++ b/src/native/common/MachineDescriptionRuntime.c
@@ -0,0 +1,174 @@
+
+#include <jni.h>
+
+#include <assert.h>
+
+#include "jogamp_common_os_MachineDescriptionRuntime.h"
+
+#if defined(_WIN32)
+    #include <windows.h>
+#else /* assume POSIX sysconf() availability */
+    #include <unistd.h>
+#endif
+
+#include <gluegen_stdint.h>
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getPointerSizeInBytesImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(void *);
+}
+
+JNIEXPORT jlong JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getPageSizeInBytesImpl(JNIEnv *env, jclass _unused) {
+#if defined(_WIN32)
+    SYSTEM_INFO si;
+    GetSystemInfo(&si);
+    return (jlong) si.dwPageSize;
+#else
+    return (jlong) sysconf(_SC_PAGESIZE);
+#endif
+}
+
+typedef struct { 
+    int8_t      c1;
+    int8_t      v;
+} struct_alignment_int8;
+
+typedef struct { 
+    int8_t      c1;
+    int16_t     v;
+} struct_alignment_int16;
+
+typedef struct { 
+    int8_t      c1;
+    int32_t      v;
+} struct_alignment_int32;
+
+typedef struct { 
+    int8_t      c1;
+    int64_t      v;
+} struct_alignment_int64;
+
+typedef struct { 
+    int8_t      c1;
+    char        v;
+} struct_alignment_char;
+
+typedef struct { 
+    int8_t      c1;
+    short        v;
+} struct_alignment_short;
+
+typedef struct { 
+    int8_t      c1;
+    int         v;
+} struct_alignment_int;
+
+typedef struct { 
+    int8_t      c1;
+    long        v;
+} struct_alignment_long;
+
+typedef struct { 
+    int8_t      c1;
+    void *     v;
+} struct_alignment_pointer;
+
+typedef struct { 
+    int8_t      c1;
+    float     v;
+} struct_alignment_float;
+
+typedef struct { 
+    int8_t      c1;
+    double     v;
+} struct_alignment_double;
+
+// 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; }
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_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) {
+    return alignment(sizeof( struct_alignment_int16 ), sizeof(int16_t));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_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) {
+    return alignment(sizeof( struct_alignment_int64 ), sizeof(int64_t));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentCharImpl(JNIEnv *env, jclass _unused) {
+    return alignment(sizeof( struct_alignment_char ), sizeof(char));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentShortImpl(JNIEnv *env, jclass _unused) {
+    return alignment(sizeof( struct_alignment_short ), sizeof(short));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_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) {
+    return alignment(sizeof( struct_alignment_long ), sizeof(long));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_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) {
+    return alignment(sizeof( struct_alignment_float ), sizeof(float));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getAlignmentDoubleImpl(JNIEnv *env, jclass _unused) {
+    return alignment(sizeof( struct_alignment_double ), sizeof(double));
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfCharImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(char);
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfShortImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(short);
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfIntImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(int);
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfLongImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(long);
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfFloatImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(float);
+}
+
+JNIEXPORT jint JNICALL 
+Java_jogamp_common_os_MachineDescriptionRuntime_getSizeOfDoubleImpl(JNIEnv *env, jclass _unused) {
+    return sizeof(double);
+}
+
diff --git a/src/native/common/Platform.c b/src/native/common/Platform.c
deleted file mode 100644
index c385e12..0000000
--- a/src/native/common/Platform.c
+++ /dev/null
@@ -1,29 +0,0 @@
-
-#include <jni.h>
-
-#include <assert.h>
-
-#include "com_jogamp_common_os_Platform.h"
-
-#if defined(_WIN32)
-    #include <windows.h>
-#else /* assume POSIX sysconf() availability */
-    #include <unistd.h>
-#endif
-
-JNIEXPORT jint JNICALL 
-Java_com_jogamp_common_os_Platform_getPointerSizeInBitsImpl(JNIEnv *env, jclass _unused) {
-    return sizeof(void *) * 8;
-}
-
-JNIEXPORT jlong JNICALL 
-Java_com_jogamp_common_os_Platform_getPageSizeImpl(JNIEnv *env, jclass _unused) {
-#if defined(_WIN32)
-    SYSTEM_INFO si;
-    GetSystemInfo(&si);
-    return (jlong) si.dwPageSize;
-#else
-    return (jlong) sysconf(_SC_PAGESIZE);
-#endif
-}
-
-- 
cgit v1.2.3