summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen')
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Buffers.java13
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/CPU.java100
-rw-r--r--src/java/com/jogamp/gluegen/runtime/Int64Buffer.java169
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java94
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/Int64BufferSE.java80
-rw-r--r--src/java/com/jogamp/gluegen/runtime/Platform.java67
-rw-r--r--src/java/com/jogamp/gluegen/runtime/PointerBuffer.java22
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java4
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/PointerBufferSE.java6
9 files changed, 442 insertions, 113 deletions
diff --git a/src/java/com/jogamp/gluegen/runtime/Buffers.java b/src/java/com/jogamp/gluegen/runtime/Buffers.java
index 11b2739..49f6e8b 100755
--- a/src/java/com/jogamp/gluegen/runtime/Buffers.java
+++ b/src/java/com/jogamp/gluegen/runtime/Buffers.java
@@ -263,6 +263,8 @@ public class Buffers {
return ((IntBuffer) buf).isDirect();
} else if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).isDirect();
+ } else if (buf instanceof Int64Buffer) {
+ return ((Int64Buffer) buf).isDirect();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).isDirect();
} else if (Platform.isJavaSE()) {
@@ -305,6 +307,9 @@ public class Buffers {
return pos * SIZEOF_CHAR;
}
}
+ } else if (buf instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buf;
+ return int64Buffer.position() * Int64Buffer.elementSize();
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return pointerBuffer.position() * PointerBuffer.elementSize();
@@ -329,6 +334,8 @@ public class Buffers {
return ((IntBuffer) buf).array();
} else if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).array();
+ } else if (buf instanceof Int64Buffer) {
+ return ((Int64Buffer) buf).array();
} else if (buf instanceof PointerBuffer) {
return ((PointerBuffer) buf).array();
}else if(Platform.isJavaSE()) {
@@ -373,6 +380,9 @@ public class Buffers {
return (SIZEOF_CHAR * (((CharBuffer) buf).arrayOffset() + pos));
}
}
+ } else if (buf instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buf;
+ return Int64Buffer.elementSize() * (int64Buffer.arrayOffset() + int64Buffer.position());
} else if (buf instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buf;
return PointerBuffer.elementSize() * (pointerBuffer.arrayOffset() + pointerBuffer.position());
@@ -681,6 +691,9 @@ public class Buffers {
bytesRemaining = elementsRemaining * SIZEOF_CHAR;
}
}
+ } else if (buffer instanceof Int64Buffer) {
+ Int64Buffer int64Buffer = (Int64Buffer) buffer;
+ bytesRemaining = int64Buffer.remaining() * Int64Buffer.elementSize();
} else if (buffer instanceof PointerBuffer) {
PointerBuffer pointerBuffer = (PointerBuffer) buffer;
bytesRemaining = pointerBuffer.remaining() * PointerBuffer.elementSize();
diff --git a/src/java/com/jogamp/gluegen/runtime/CPU.java b/src/java/com/jogamp/gluegen/runtime/CPU.java
deleted file mode 100755
index 9c2f81e..0000000
--- a/src/java/com/jogamp/gluegen/runtime/CPU.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2005 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.runtime;
-
-/** Provides information to autogenerated struct accessors about what
- kind of data model (32- or 64-bit) is being used by the currently
- running process. */
-
-public class CPU {
-
- private final static boolean is32Bit;
-
- static {
-
- NativeLibrary.ensureNativeLibLoaded();
-
- // Try to use Sun's sun.arch.data.model first ..
- int bits = getPointerSizeInBits();
- if ( 32 == bits || 64 == bits ) {
- is32Bit = ( 32 == bits );
- }else {
- // We don't seem to need an AccessController.doPrivileged() block
- // here as these system properties are visible even to unsigned
- // applets
- // Note: this code is replicated in StructLayout.java
- String os = Platform.getOS().toLowerCase();
- String cpu = Platform.getArch().toLowerCase();
-
- if ((os.startsWith("windows") && cpu.equals("x86")) ||
- (os.startsWith("windows") && cpu.equals("arm")) ||
- (os.startsWith("linux") && cpu.equals("i386")) ||
- (os.startsWith("linux") && cpu.equals("x86")) ||
- (os.startsWith("mac os") && cpu.equals("ppc")) ||
- (os.startsWith("mac os") && cpu.equals("i386")) ||
- (os.startsWith("darwin") && cpu.equals("ppc")) ||
- (os.startsWith("darwin") && cpu.equals("i386")) ||
- (os.startsWith("sunos") && cpu.equals("sparc")) ||
- (os.startsWith("sunos") && cpu.equals("x86")) ||
- (os.startsWith("freebsd") && cpu.equals("i386")) ||
- (os.startsWith("hp-ux") && cpu.equals("pa_risc2.0"))) {
- is32Bit = true;
- }else if ((os.startsWith("windows") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("amd64")) ||
- (os.startsWith("linux") && cpu.equals("x86_64")) ||
- (os.startsWith("linux") && cpu.equals("ia64")) ||
- (os.startsWith("mac os") && cpu.equals("x86_64")) ||
- (os.startsWith("darwin") && cpu.equals("x86_64")) ||
- (os.startsWith("sunos") && cpu.equals("sparcv9")) ||
- (os.startsWith("sunos") && cpu.equals("amd64"))) {
- is32Bit = false;
- }else{
- throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os + "/" + cpu + ")");
- }
- }
- }
-
- public static boolean is32Bit() {
- return is32Bit;
- }
-
- public static native int getPointerSizeInBits();
-
-}
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java
new file mode 100644
index 0000000..98d0834
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64Buffer.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2010, Michael Bien
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions 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 Michael Bien nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Michael Bien BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.gluegen.runtime;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Hardware independent container for native int64_t arrays.
+ *
+ * The native values (NIO direct ByteBuffer) are always 64bit wide.
+ *
+ * @author Michael Bien
+ * @author Sven Gothel
+ */
+public abstract class Int64Buffer {
+
+ protected final ByteBuffer bb;
+ protected int capacity;
+ protected int position;
+ protected long[] backup;
+
+ protected Int64Buffer(ByteBuffer bb) {
+ this.bb = bb;
+ }
+
+ public static Int64Buffer allocate(int size) {
+ if (Platform.isJavaSE()) {
+ return new Int64BufferSE(ByteBuffer.wrap(new byte[elementSize() * size]));
+ } else {
+ return new Int64BufferME_CDC_FP(ByteBuffer.wrap(new byte[elementSize() * size]));
+ }
+ }
+
+ public static Int64Buffer allocateDirect(int size) {
+ if (Platform.isJavaSE()) {
+ return new Int64BufferSE(Buffers.newDirectByteBuffer(elementSize() * size));
+ } else {
+ return new Int64BufferME_CDC_FP(Buffers.newDirectByteBuffer(elementSize() * size));
+ }
+ }
+
+ public static Int64Buffer wrap(ByteBuffer src) {
+ Int64Buffer res;
+ if (Platform.isJavaSE()) {
+ res = new Int64BufferSE(src);
+ } else {
+ res = new Int64BufferME_CDC_FP(src);
+ }
+ res.updateBackup();
+ return res;
+
+ }
+
+ void updateBackup() {
+ for (int i = 0; i < capacity; i++) {
+ backup[i] = get(i);
+ }
+ }
+
+ int arrayOffset() {
+ return 0;
+ }
+
+ public static int elementSize() {
+ return Buffers.SIZEOF_LONG;
+ }
+
+ public int limit() {
+ return capacity;
+ }
+
+ public int capacity() {
+ return capacity;
+ }
+
+ public int position() {
+ return position;
+ }
+
+ public Int64Buffer position(int newPos) {
+ if (0 > newPos || newPos >= capacity) {
+ throw new IndexOutOfBoundsException("Sorry to interrupt, but the position "+newPos+" was out of bounds. " +
+ "My capacity is "+capacity()+".");
+ }
+ position = newPos;
+ return this;
+ }
+
+ public int remaining() {
+ return capacity - position;
+ }
+
+ public boolean hasRemaining() {
+ return position < capacity;
+ }
+
+ public Int64Buffer rewind() {
+ position = 0;
+ return this;
+ }
+
+ boolean hasArray() {
+ return true;
+ }
+
+ public long[] array() {
+ return backup;
+ }
+
+ public ByteBuffer getBuffer() {
+ return bb;
+ }
+
+ public boolean isDirect() {
+ return bb.isDirect();
+ }
+
+ public long get() {
+ long r = get(position);
+ position++;
+ return r;
+ }
+
+ public abstract long get(int idx);
+
+ public abstract Int64Buffer put(int index, long value);
+
+ public abstract Int64Buffer put(long value);
+
+ public Int64Buffer put(Int64Buffer src) {
+ if (remaining() < src.remaining()) {
+ throw new IndexOutOfBoundsException();
+ }
+ while (src.hasRemaining()) {
+ put(src.get());
+ }
+ return this;
+ }
+
+ public String toString() {
+ return "Int64Buffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]";
+ }
+
+}
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java b/src/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java
new file mode 100755
index 0000000..cedb737
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64BufferME_CDC_FP.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package com.jogamp.gluegen.runtime;
+
+import java.nio.*;
+
+/**
+ * @author Sven Gothel
+ * @author Michael Bien
+ */
+final class Int64BufferME_CDC_FP extends Int64Buffer {
+
+ private IntBuffer pb;
+
+ Int64BufferME_CDC_FP(ByteBuffer bb) {
+ super(bb);
+ this.pb = bb.asIntBuffer();
+
+ capacity = bb.capacity() / elementSize();
+
+ position = 0;
+ backup = new long[capacity];
+ }
+
+ public long get(int idx) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ idx = idx << 1; // 8-byte to 4-byte offset
+ long lo = 0x00000000FFFFFFFFL & ((long) pb.get(idx));
+ long hi = 0x00000000FFFFFFFFL & ((long) pb.get(idx + 1));
+ if (Platform.isLittleEndian()) {
+ return hi << 32 | lo;
+ }
+ return lo << 32 | hi;
+ }
+
+ public Int64Buffer put(int idx, long v) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ backup[idx] = v;
+ idx = idx << 1; // 8-byte to 4-byte offset
+ int lo = (int) ((v) & 0x00000000FFFFFFFFL);
+ int hi = (int) ((v >> 32) & 0x00000000FFFFFFFFL);
+ if (Platform.isLittleEndian()) {
+ pb.put(idx, lo);
+ pb.put(idx + 1, hi);
+ } else {
+ pb.put(idx, hi);
+ pb.put(idx + 1, lo);
+ }
+ return this;
+ }
+
+ public Int64Buffer put(long v) {
+ put(position, v);
+ position++;
+ return this;
+ }
+}
diff --git a/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java b/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java
new file mode 100755
index 0000000..166d0c6
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/Int64BufferSE.java
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+package com.jogamp.gluegen.runtime;
+
+import java.nio.*;
+
+/**
+ * @author Sven Gothel
+ * @author Michael Bien
+ */
+final class Int64BufferSE extends Int64Buffer {
+
+ private LongBuffer pb;
+
+ Int64BufferSE(ByteBuffer bb) {
+ super(bb);
+
+ this.pb = bb.asLongBuffer();
+
+ capacity = bb.capacity() / elementSize();
+
+ position = 0;
+ backup = new long[capacity];
+ }
+
+ public long get(int idx) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ return pb.get(idx);
+ }
+
+ public Int64Buffer put(int idx, long v) {
+ if (0 > idx || idx >= capacity) {
+ throw new IndexOutOfBoundsException();
+ }
+ backup[idx] = v;
+ pb.put(idx, v);
+ return this;
+ }
+
+ public Int64Buffer put(long v) {
+ put(position, v);
+ position++;
+ return this;
+ }
+}
diff --git a/src/java/com/jogamp/gluegen/runtime/Platform.java b/src/java/com/jogamp/gluegen/runtime/Platform.java
index 8245b51..a621279 100644
--- a/src/java/com/jogamp/gluegen/runtime/Platform.java
+++ b/src/java/com/jogamp/gluegen/runtime/Platform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Michael Bien
+ * Copyright (c) 2010, Michael Bien, Sven Gothel
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,15 +36,62 @@ import java.nio.ShortBuffer;
/**
* Utility class for querying platform specific properties.
- * @author Michael Bien
+ * @author Michael Bien, Sven Gothel
*/
public class Platform {
public static final boolean JAVA_SE;
public static final boolean LITTLE_ENDIAN;
+ private final static boolean is32Bit;
+ private final static int pointerSizeInBits;
+ private final static String os, arch;
+
static {
- // platform
+ NativeLibrary.ensureNativeLibLoaded();
+
+ // 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");
+ arch = System.getProperty("os.arch");
+
+ pointerSizeInBits = getPointerSizeInBitsImpl();
+
+ // Try to use Sun's sun.arch.data.model first ..
+ if ( 32 == pointerSizeInBits || 64 == pointerSizeInBits ) {
+ is32Bit = ( 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_lc") && arch_lc.equals("ppc")) ||
+ (os_lc.startsWith("mac os_lc") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("ppc")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("sparc")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("x86")) ||
+ (os_lc.startsWith("freebsd") && arch_lc.equals("i386")) ||
+ (os_lc.startsWith("hp-ux") && arch_lc.equals("pa_risc2.0"))) {
+ is32Bit = 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_lc") && arch_lc.equals("x86_64")) ||
+ (os_lc.startsWith("darwin") && arch_lc.equals("x86_64")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("sparcv9")) ||
+ (os_lc.startsWith("sunos_lc") && arch_lc.equals("amd64"))) {
+ is32Bit = false;
+ }else{
+ throw new RuntimeException("Please port CPU detection (32/64 bit) to your platform (" + os_lc + "/" + arch_lc + ")");
+ }
+ }
+
// fast path
boolean se = System.getProperty("java.runtime.name").indexOf("Java SE") != -1;
@@ -69,6 +116,8 @@ public class Platform {
private Platform() {}
+ private static native int getPointerSizeInBitsImpl();
+
/**
* Returns true only if this program is running on the Java Standard Edition.
*/
@@ -87,21 +136,27 @@ public class Platform {
* Returns the OS name.
*/
public static String getOS() {
- return System.getProperty("os.name");
+ return os;
}
/**
* Returns the CPU architecture String.
*/
public static String getArch() {
- return System.getProperty("os.arch");
+ return arch;
}
/**
* Returns true if this JVM is a 32bit JVM.
*/
public static boolean is32Bit() {
- return CPU.is32Bit();
+ return is32Bit;
+ }
+
+ public static int getPointerSizeInBits() {
+ return pointerSizeInBits;
}
}
+
+
diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
index ff1bc2e..0adbb36 100644
--- a/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBuffer.java
@@ -33,7 +33,11 @@ package com.jogamp.gluegen.runtime;
import java.nio.ByteBuffer;
/**
- * Hardware independent container for native long- and pointer arrays.
+ * Hardware independent container for native pointer arrays.
+ *
+ * The native values (NIO direct ByteBuffer) might be 32bit or 64bit wide,
+ * depending of the CPU pointer width.
+ *
* @author Michael Bien
* @author Sven Gothel
*/
@@ -87,7 +91,7 @@ public abstract class PointerBuffer {
}
public static int elementSize() {
- return CPU.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG;
+ return Platform.is32Bit() ? Buffers.SIZEOF_INT : Buffers.SIZEOF_LONG;
}
public int limit() {
@@ -152,4 +156,18 @@ public abstract class PointerBuffer {
public abstract PointerBuffer put(long value);
+ public PointerBuffer put(PointerBuffer src) {
+ if (remaining() < src.remaining()) {
+ throw new IndexOutOfBoundsException();
+ }
+ while (src.hasRemaining()) {
+ put(src.get());
+ }
+ return this;
+ }
+
+ public String toString() {
+ return "PointerBuffer[capacity "+capacity+", position "+position+", elementSize "+elementSize()+", ByteBuffer.capacity "+bb.capacity()+"]";
+ }
+
}
diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java b/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
index 0ffd974..1134ee7 100755
--- a/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBufferME_CDC_FP.java
@@ -59,7 +59,7 @@ final class PointerBufferME_CDC_FP extends PointerBuffer {
if (0 > idx || idx >= capacity) {
throw new IndexOutOfBoundsException();
}
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
return pb.get(idx);
} else {
idx = idx << 1; // 8-byte to 4-byte offset
@@ -77,7 +77,7 @@ final class PointerBufferME_CDC_FP extends PointerBuffer {
throw new IndexOutOfBoundsException();
}
backup[idx] = v;
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
pb.put(idx, (int) v);
} else {
idx = idx << 1; // 8-byte to 4-byte offset
diff --git a/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java b/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
index 9c67dda..6f131a9 100755
--- a/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
+++ b/src/java/com/jogamp/gluegen/runtime/PointerBufferSE.java
@@ -48,7 +48,7 @@ final class PointerBufferSE extends PointerBuffer {
PointerBufferSE(ByteBuffer bb) {
super(bb);
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
this.pb = bb.asIntBuffer();
} else {
this.pb = bb.asLongBuffer();
@@ -64,7 +64,7 @@ final class PointerBufferSE extends PointerBuffer {
if (0 > idx || idx >= capacity) {
throw new IndexOutOfBoundsException();
}
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
return ((IntBuffer) pb).get(idx);
} else {
return ((LongBuffer) pb).get(idx);
@@ -76,7 +76,7 @@ final class PointerBufferSE extends PointerBuffer {
throw new IndexOutOfBoundsException();
}
backup[idx] = v;
- if (CPU.is32Bit()) {
+ if (Platform.is32Bit()) {
((IntBuffer) pb).put(idx, (int) v);
} else {
((LongBuffer) pb).put(idx, v);