[jffi-next] 03/49: Re-do address masking mods in a more backwards compatible way.
Tim Potter
tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:08 UTC 2015
This is an automated email from the git hooks/post-receive script.
tpot-guest pushed a commit to annotated tag upstream/1.0.10
in repository jffi-next.
commit f320be0eb41c8df320e85a955cf3062cc7980e97
Author: Wayne Meissner <wmeissner at gmail.com>
Date: Thu Mar 18 13:23:01 2010 +1000
Re-do address masking mods in a more backwards compatible way.
---
src/com/kenai/jffi/DirectClosureBuffer.java | 3 +--
src/com/kenai/jffi/MemoryIO.java | 18 +++++++++---------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/com/kenai/jffi/DirectClosureBuffer.java b/src/com/kenai/jffi/DirectClosureBuffer.java
index a587874..281f8e2 100644
--- a/src/com/kenai/jffi/DirectClosureBuffer.java
+++ b/src/com/kenai/jffi/DirectClosureBuffer.java
@@ -25,7 +25,6 @@ package com.kenai.jffi;
final class DirectClosureBuffer implements Closure.Buffer {
private static final MemoryIO IO = MemoryIO.getInstance();
- private static final long ADDRESS_MASK = Platform.getPlatform().addressMask();
private static final NativeWordIO WordIO = NativeWordIO.getInstance();
private static final long PARAM_SIZE = Platform.getPlatform().addressSize() / 8;
private final long retval;
@@ -65,7 +64,7 @@ final class DirectClosureBuffer implements Closure.Buffer {
}
public final long getAddress(int index) {
- return IO.getAddress(IO.getAddress(parameters + (index * PARAM_SIZE))) & ADDRESS_MASK;
+ return IO.getAddress(IO.getAddress(parameters + (index * PARAM_SIZE)));
}
public final long getStruct(int index) {
diff --git a/src/com/kenai/jffi/MemoryIO.java b/src/com/kenai/jffi/MemoryIO.java
index 18336e2..33b64cf 100644
--- a/src/com/kenai/jffi/MemoryIO.java
+++ b/src/com/kenai/jffi/MemoryIO.java
@@ -470,7 +470,7 @@ public abstract class MemoryIO {
* @return The native address of the allocated memory.
*/
public final long allocateMemory(long size, boolean clear) {
- return foreign.allocateMemory(size, clear);
+ return foreign.allocateMemory(size, clear) & ADDRESS_MASK;
}
/**
@@ -641,10 +641,10 @@ public abstract class MemoryIO {
private static final class NativeImpl32 extends NativeImpl {
public final long getAddress(long address) {
// Mask with ADDRESS_MASK to cancel out any sign extension
- return foreign.getAddress(address) & ADDRESS_MASK;
+ return ((long) foreign.getInt(address)) & ADDRESS_MASK;
}
public final void putAddress(long address, long value) {
- foreign.putAddress(address, value & ADDRESS_MASK);
+ foreign.putInt(address, (int) value);
}
}
@@ -653,10 +653,10 @@ public abstract class MemoryIO {
*/
private static final class NativeImpl64 extends NativeImpl {
public final long getAddress(long address) {
- return foreign.getAddress(address);
+ return foreign.getLong(address);
}
public final void putAddress(long address, long value) {
- foreign.putAddress(address, value);
+ foreign.putLong(address, value);
}
}
@@ -724,10 +724,10 @@ public abstract class MemoryIO {
*/
private static final class UnsafeImpl32 extends UnsafeImpl {
public final long getAddress(long address) {
- return unsafe.getAddress(address) & ADDRESS_MASK;
+ return ((long) unsafe.getInt(address)) & ADDRESS_MASK;
}
public final void putAddress(long address, long value) {
- unsafe.putAddress(address, value & ADDRESS_MASK);
+ unsafe.putInt(address, (int) value);
}
}
@@ -736,10 +736,10 @@ public abstract class MemoryIO {
*/
private static final class UnsafeImpl64 extends UnsafeImpl {
public final long getAddress(long address) {
- return unsafe.getAddress(address);
+ return unsafe.getLong(address);
}
public final void putAddress(long address, long value) {
- unsafe.putAddress(address, value);
+ unsafe.putLong(address, value);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git
More information about the pkg-java-commits
mailing list