fix alignment on osx/ppc

Esse commit está contido em:
Timothy Wall
2013-06-06 21:49:14 -04:00
commit 2d7971a429
3 arquivos alterados com 8 adições e 5 exclusões
+6 -3
Ver Arquivo
@@ -124,6 +124,7 @@ public final class Native implements Version {
private static final int TYPE_WCHAR_T = 2;
private static final int TYPE_SIZE_T = 3;
static final int MAX_ALIGNMENT;
static final int MAX_PADDING;
static {
@@ -153,10 +154,12 @@ public final class Native implements Version {
+ " - set jna.boot.library.path to include the path to the version of the " + LS
+ " jnidispatch library included with the JNA jar file you are using" + LS);
}
MAX_PADDING = Platform.isSPARC() || Platform.isWindows() || Platform.isARM()
|| Platform.isAIX() || Platform.isAndroid()
|| Platform.isPPC()
MAX_ALIGNMENT = Platform.isSPARC() || Platform.isWindows()
|| (Platform.isLinux() && (Platform.isARM() || Platform.isPPC()))
|| Platform.isAIX()
|| Platform.isAndroid()
? 8 : LONG_SIZE;
MAX_PADDING = (Platform.isMac() && Platform.isPPC()) ? 8 : MAX_ALIGNMENT;
}
/** Force a dispose when this class is GC'd. */
+1 -1
Ver Arquivo
@@ -1301,7 +1301,7 @@ public abstract class Structure {
// NOTE this is published ABI for 32-bit gcc/linux/x86, osx/x86,
// and osx/ppc. osx/ppc special-cases the first element
if (!isFirstElement || !(Platform.isMac() && Platform.isPPC())) {
alignment = Math.min(Native.MAX_PADDING, alignment);
alignment = Math.min(Native.MAX_ALIGNMENT, alignment);
}
if (!isFirstElement && Platform.isAIX() && (type == double.class || type == Double.class)) {
alignment = 4;
+1 -1
Ver Arquivo
@@ -158,7 +158,7 @@ public class StructureTest extends TestCase {
}
Structure s = new TestStructure();
s.setAlignType(Structure.ALIGN_GNUC);
final int SIZE = Native.MAX_PADDING == 8 ? 32 : 28;
final int SIZE = Native.MAX_ALIGNMENT == 8 ? 32 : 28;
assertEquals("Wrong structure size", SIZE, s.size());
}