aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/sun/gluegen/runtime/BufferFactory.java.javase')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/BufferFactory.java.javase15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
index a883316..3986bf6 100755
--- a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
+++ b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
@@ -281,4 +281,19 @@ public class BufferFactory {
throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining);
}
}
+
+ public static LongBuffer asPointerBuffer(ByteBuffer src) {
+ if (CPU.is32Bit()) {
+ // Must convert each pointer from 32-bit to 64-bit
+ IntBuffer buf = src.asIntBuffer();
+ int len = buf.capacity();
+ LongBuffer res = LongBuffer.wrap(new long[len]);
+ for (int i = 0; i < len; i++) {
+ res.put(i, buf.get(i));
+ }
+ return res;
+ } else {
+ return src.asLongBuffer();
+ }
+ }
}