From 2bf03e9814477b412f9533d3ba3f4c597892501e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Jul 2011 19:21:11 +0200 Subject: Clarify aligment doc --- src/java/com/jogamp/gluegen/package.html | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/java') diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html index 449eb31..5e86aad 100644 --- a/src/java/com/jogamp/gluegen/package.html +++ b/src/java/com/jogamp/gluegen/package.html @@ -42,8 +42,9 @@

GlueGen Internal Alignment for Compound Data

In general, depending on CPU and it's configuration (OS), alignment is set up - for each type (char, short, int, long, ..),
- where structures are aligned naturally, i.e. their inner components are aligned.
+ for each type (char, short, int, long, ..). +

Compounds (structures) are aligned naturally, i.e. their inner components are aligned
+ and are itself aligned to it's largest element.

See:
+
Simple alignment arithmetic
+
remainder = net_size % alignment
+ since alignment is a multiple of 2 -> x % 2n == x & (2n - 1)
+
remainder = net_size & ( alignment - 1 )
+
+ padding = alignment - remainder ;
+ aligned_size = net_size + padding ; +
+
Type Size & Alignment for x86, x86_64, armv7l-32bit-eabi and Window(mingw/mingw64)
Runtime query is implemented as follows:
    typedef struct {
      char   fill;  // nibble one byte
-                   // padding to align s1 
-     _TYPE_ s1;    // 
-   } type_t;
+                   // padding to align s1: padding_0 
+     type_t s1;    // 
+   } test_struct_type_t;
   
-     padding = sizeof(type_t) - sizeof(_TYPE_) - sizeof(char);
-   alignment = sizeof(type_t) - sizeof(_TYPE_) ;
+             padding_0 = sizeof(test_struct_type_t) - sizeof(type_t) - sizeof(char) ;
+   alignmentOf(type_t) = sizeof(test_struct_type_t) - sizeof(type_t) ;
   
+ -- cgit v1.2.3
type 32 bits64 bits
sizealignmentsizealignment