Permalink
Browse files

Fixed bug with typesetting of the native args by wrapping it into a

native wrapper
  • Loading branch information...
1 parent 220c5f1 commit 2f5e7763c3784443d656c14ff597ccc443bafb45 @abh1nay abh1nay committed Nov 27, 2012
View
2 src/java/voldemort/store/readonly/io/MemLock.java
@@ -42,7 +42,7 @@ public MemLock(File file, FileDescriptor descriptor, long offset, long length)
int fd = voldemort.store.readonly.io.Native.getFd(descriptor);
- pa = mman.mmap(length, mman.PROT_READ, mman.MAP_SHARED, fd, offset);
+ pa = mman.mmap(length, mman.PROT_READ, mman.MAP_SHARED | mman.MAP_ALIGN, fd, offset);
// even though technically we have specified MAP_LOCKED this isn't
// supported on OpenSolaris or older Linux kernels (or OS X).
View
24 src/java/voldemort/store/readonly/io/jna/mman.java
@@ -7,6 +7,7 @@
import org.apache.log4j.Logger;
import com.sun.jna.Native;
+import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
public class mman {
@@ -37,7 +38,12 @@ public static Pointer mmap(long len, int prot, int flags, int fildes, long off)
// we don't really have a need to change the recommended pointer.
Pointer addr = new Pointer(0);
- Pointer result = Delegate.mmap(addr, len, prot, flags, fildes, off);
+ Pointer result = Delegate.mmap(addr,
+ new NativeLong(len),
+ prot,
+ flags,
+ fildes,
+ new NativeLong(off));
if(Pointer.nativeValue(result) == -1) {
@@ -50,7 +56,7 @@ public static Pointer mmap(long len, int prot, int flags, int fildes, long off)
public static int munmap(Pointer addr, long len) throws IOException {
- int result = Delegate.munmap(addr, len);
+ int result = Delegate.munmap(addr, new NativeLong(len));
if(result != 0) {
logger.warn(errno.strerror());
@@ -62,7 +68,7 @@ public static int munmap(Pointer addr, long len) throws IOException {
public static void mlock(Pointer addr, long len) throws IOException {
- int res = Delegate.mlock(addr, len);
+ int res = Delegate.mlock(addr, new NativeLong(len));
if(res != 0) {
String error = errno.strerror();
logger.warn("Mlock failed probably because of insufficient privileges");
@@ -80,7 +86,7 @@ public static void mlock(Pointer addr, long len) throws IOException {
*/
public static void munlock(Pointer addr, long len) throws IOException {
- if(Delegate.munlock(addr, len) != 0) {
+ if(Delegate.munlock(addr, new NativeLong(len)) != 0) {
logger.warn(errno.strerror());
} else {
logger.info("munlocking region");
@@ -91,17 +97,17 @@ public static void munlock(Pointer addr, long len) throws IOException {
static class Delegate {
public static native Pointer mmap(Pointer addr,
- long len,
+ NativeLong len,
int prot,
int flags,
int fildes,
- long off);
+ NativeLong off);
- public static native int munmap(Pointer addr, long len);
+ public static native int munmap(Pointer addr, NativeLong len);
- public static native int mlock(Pointer addr, long len);
+ public static native int mlock(Pointer addr, NativeLong len);
- public static native int munlock(Pointer addr, long len);
+ public static native int munlock(Pointer addr, NativeLong len);
static {
Native.register("c");

0 comments on commit 2f5e776

Please sign in to comment.