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/26 16:41:38 UTC
svn commit: r1096767 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/platform/unix/Posix.java
java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java
native/os/unix/shmem.c
Author: mturk
Date: Tue Apr 26 14:41:37 2011
New Revision: 1096767
URL: http://svn.apache.org/viewvc?rev=1096767&view=rev
Log:
Implement Posix shared memory
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/PosixShmImpl.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=1096767&r1=1096766&r2=1096767&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 Tue Apr 26 14:41:37 2011
@@ -105,7 +105,7 @@ final class Posix
public static native int fchdir(int fd);
public static native String getcwd();
public static native long mmap(long addr, long length, int prot,
- int flags, long offset);
+ int flags, int fd, long offset);
public static native int munmap(long addr, long length);
public static native int msync(long addr, long length, int flags);
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java?rev=1096767&r1=1096766&r2=1096767&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java Tue Apr 26 14:41:37 2011
@@ -33,10 +33,17 @@ import org.apache.commons.runtime.System
final class PosixShmImpl extends ShmImpl
{
- public PosixShmImpl()
+ private PosixShmImpl()
{
// No Instance
}
+
+ public PosixShmImpl(int dt)
+ {
+ defaultType = dt;
+ }
+
+ private static int defaultType = 0;
public Shm create(String name, long size)
throws InvalidArgumentException,
@@ -45,7 +52,10 @@ final class PosixShmImpl extends ShmImpl
{
if (size < Limits.SHMMIN || size > Limits.SHMMAX)
throw new InvalidArgumentException("Shared memory size is outside the limits.");
- return new SysVShm(name, size);
+ if (defaultType == 0)
+ return new SysVShm(name, size);
+ else
+ return new PosixShm(name, size);
}
public Shm open(String name)
@@ -53,7 +63,10 @@ final class PosixShmImpl extends ShmImpl
NoSuchObjectException,
SystemException
{
- return new SysVShm(name);
+ if (defaultType == 0)
+ return new SysVShm(name);
+ else
+ return new PosixShm(name);
}
}
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=1096767&r1=1096766&r2=1096767&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 Tue Apr 26 14:41:37 2011
@@ -32,6 +32,10 @@
#define SHM_W 0200
#endif
+/* XXX: Prefer PosixShm if available?
+ */
+static jint def_shm_type = HAVE_SHM_OPEN;
+
typedef struct shmblock_t {
acr_uint32_t magic; /* Is this our memory */
pid_t creator; /* Creator's process ID */
@@ -49,7 +53,7 @@ J_DECLARE_CLAZZ = {
J_DECLARE_M_ID(0000) = {
0,
"<init>",
- "()V"
+ "(I)V"
};
ACR_JNI_EXPORT(jobject, ShmImpl, init0)(JNI_STDARGS)
@@ -60,7 +64,7 @@ ACR_JNI_EXPORT(jobject, ShmImpl, init0)(
return 0;
R_LOAD_METHOD(0000, 0);
_clazzn.u = 1;
- return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
+ return (*env)->NewObject(env, _clazzn.i, J4MID(0000), def_shm_type);
}
ACR_UNX_EXPORT(jint, SysVShm, create0)(JNI_STDARGS, jstring name, jlong size)