[jffi-next] 02/49: Revert commit 63ca6e9beeecdde3c50e4b4def9243ea69fc3a3f

Tim Potter tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:07 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 8c60da5040fcf2b3018fc9aa0462d0dca87e2c7b
Author: Wayne Meissner <wmeissner at gmail.com>
Date:   Thu Mar 18 04:55:26 2010 +1000

    Revert commit 63ca6e9beeecdde3c50e4b4def9243ea69fc3a3f
---
 src/com/kenai/jffi/DirectClosureBuffer.java |  3 ++-
 src/com/kenai/jffi/Invoker.java             |  5 ++++-
 src/com/kenai/jffi/MemoryIO.java            | 13 ++++++++-----
 test/com/kenai/jffi/UnitHelper.java         |  3 ++-
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/com/kenai/jffi/DirectClosureBuffer.java b/src/com/kenai/jffi/DirectClosureBuffer.java
index 281f8e2..a587874 100644
--- a/src/com/kenai/jffi/DirectClosureBuffer.java
+++ b/src/com/kenai/jffi/DirectClosureBuffer.java
@@ -25,6 +25,7 @@ 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;
@@ -64,7 +65,7 @@ final class DirectClosureBuffer implements Closure.Buffer {
     }
 
     public final long getAddress(int index) {
-        return IO.getAddress(IO.getAddress(parameters + (index * PARAM_SIZE)));
+        return IO.getAddress(IO.getAddress(parameters + (index * PARAM_SIZE))) & ADDRESS_MASK;
     }
 
     public final long getStruct(int index) {
diff --git a/src/com/kenai/jffi/Invoker.java b/src/com/kenai/jffi/Invoker.java
index 00eb09e..4ac009b 100644
--- a/src/com/kenai/jffi/Invoker.java
+++ b/src/com/kenai/jffi/Invoker.java
@@ -25,6 +25,9 @@ public abstract class Invoker {
 
     /** The size in bits of a native memory address */
     private static final long ADDRESS_SIZE = Platform.getPlatform().addressSize();
+
+    /** A mask to apply to native memory addresses to cancel sign extension */
+    private static final long ADDRESS_MASK = Platform.getPlatform().addressMask();
     
     private final Foreign foreign = Foreign.getInstance();
 
@@ -529,7 +532,7 @@ public abstract class Invoker {
         private static final Invoker INSTANCE = new ILP32();
 
         public final long invokeAddress(Function function, HeapInvocationBuffer buffer) {
-            return (long) invokeInt(function, buffer);
+            return ((long)invokeInt(function, buffer)) & ADDRESS_MASK;
         }
     }
 
diff --git a/src/com/kenai/jffi/MemoryIO.java b/src/com/kenai/jffi/MemoryIO.java
index aa8dfe2..18336e2 100644
--- a/src/com/kenai/jffi/MemoryIO.java
+++ b/src/com/kenai/jffi/MemoryIO.java
@@ -28,6 +28,9 @@ public abstract class MemoryIO {
     /** A handle to the JNI accessor */
     private final Foreign foreign = Foreign.getInstance();
 
+    /** The address mask used to truncate 32bit addresses contained in long values */
+    private static final long ADDRESS_MASK = Platform.getPlatform().addressMask();
+
     /** Holds a single instance of <tt>MemoryIO</tt> */
     private static final class SingletonHolder {
         private static final MemoryIO INSTANCE = newMemoryIO();
@@ -637,11 +640,11 @@ public abstract class MemoryIO {
      */
     private static final class NativeImpl32 extends NativeImpl {
         public final long getAddress(long address) {
-            return foreign.getInt(address);
+            // Mask with ADDRESS_MASK to cancel out any sign extension
+            return foreign.getAddress(address) & ADDRESS_MASK;
         }
-
         public final void putAddress(long address, long value) {
-            foreign.putInt(address, (int) value);
+            foreign.putAddress(address, value & ADDRESS_MASK);
         }
     }
 
@@ -721,10 +724,10 @@ public abstract class MemoryIO {
      */
     private static final class UnsafeImpl32 extends UnsafeImpl {
         public final long getAddress(long address) {
-            return unsafe.getInt(address);
+            return unsafe.getAddress(address) & ADDRESS_MASK;
         }
         public final void putAddress(long address, long value) {
-            unsafe.putInt(address, (int) value);
+            unsafe.putAddress(address, value & ADDRESS_MASK);
         }
     }
 
diff --git a/test/com/kenai/jffi/UnitHelper.java b/test/com/kenai/jffi/UnitHelper.java
index 3e7c566..62112e4 100644
--- a/test/com/kenai/jffi/UnitHelper.java
+++ b/test/com/kenai/jffi/UnitHelper.java
@@ -19,11 +19,12 @@ public class UnitHelper {
     public static final class Address extends java.lang.Number {
 
         public final int SIZE = Platform.getPlatform().addressSize();
+        public final long MASK = Platform.getPlatform().addressMask();
 
         public final long address;
 
         public Address(long address) {
-            this.address = address;
+            this.address = address & MASK;
         }
 
         public Address(Closure.Handle closure) {

-- 
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