You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/20 09:29:23 UTC
svn commit: r1095307 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/platform/unix/Posix.java
java/org/apache/commons/runtime/platform/unix/PosixShm.java
native/os/unix/shmem.c
Author: mturk
Date: Wed Apr 20 07:29:23 2011
New Revision: 1095307
URL: http://svn.apache.org/viewvc?rev=1095307&view=rev
Log:
Create Pointer in java code
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/Posix.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/Posix.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/Posix.java?rev=1095307&r1=1095306&r2=1095307&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/Posix.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/Posix.java Wed Apr 20 07:29:23 2011
@@ -81,8 +81,8 @@ final class Posix
public static native int munmap(long addr, long length);
public static native int msync(long addr, long length, int flags);
- public static final int HEAP_PTR = 1;
- public static final int SLICE_PTR = 2;
- public static final int CONST_PTR = 3;
+ public static final int HEAP_POINTER = 1;
+ public static final int SLICE_POINTER = 2;
+ public static final int CONST_POINTER = 3;
public static native Pointer pointer(long addr, long length, int type);
}
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java?rev=1095307&r1=1095306&r2=1095307&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java Wed Apr 20 07:29:23 2011
@@ -49,12 +49,10 @@ final class PosixShm extends Shm
NoSuchObjectException,
SystemException;
- private static native Pointer shmat0(long addr, long size, int fd, int flags)
+ private static native long shmat0(long addr, int fd, boolean ro)
throws SystemException;
- private static native int shmdt0(long addr);
- private static native int unlink0(int fd, String name);
-
- private static final int RDONLY = 1;
+ private static native int shmdt0(long addr);
+ private static native int unlink0(int fd, String name);
// OS shmem descriptor
private int fd;
@@ -99,8 +97,11 @@ final class PosixShm extends Shm
// TODO: Should we throw an exception here
return base;
}
- int flags = readOnly ? RDONLY : 0;
- base = shmat0(addr, size, fd, flags);
+ long badr = shmat0(addr, fd, readOnly);
+ if (readOnly)
+ base = Posix.pointer(badr, size, Posix.CONST_POINTER);
+ else
+ base = Posix.pointer(badr, size, Posix.SLICE_POINTER);
}
return base;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c?rev=1095307&r1=1095306&r2=1095307&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c Wed Apr 20 07:29:23 2011
@@ -17,7 +17,6 @@
#include "acr/string.h"
#include "acr/clazz.h"
#include "acr/jniapi.h"
-#include "acr/pointer.h"
#include "acr/port.h"
#include "arch_opts.h"
@@ -164,25 +163,18 @@ cleanup:
return sd;
}
-ACR_UNX_EXPORT(jobject, PosixShm, shmat0)(JNI_STDARGS, jlong addr, jlong size,
- jint fd, jint flags)
+ACR_UNX_EXPORT(jlong, PosixShm, shmat0)(JNI_STDARGS, jlong addr, jint fd,
+ jboolean ro)
{
void *sa = J2P(addr, void *);
void *sm;
- size_t len = (size_t)size;
+ int flags = ro ? SHM_RDONLY : 0;
- if (flags == 1)
- flags = SHM_RDONLY;
if ((sm = shmat(fd, sa, flags)) == (void *)-1) {
ACR_THROW_SYS_ERROR();
- return 0;
- }
- else {
- if (flags)
- return AcrNewConstPointer(env, sm, len);
- else
- return AcrNewSlicePointer(env, sm, len);
+ sm = 0;
}
+ return P2J(sm);
}
ACR_UNX_EXPORT(jint, PosixShm, shmdt0)(JNI_STDARGS, jlong addr)