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/25 09:10:17 UTC

svn commit: r1096421 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/platform/unix/ native/ native/os/unix/ native/os/win32/

Author: mturk
Date: Mon Apr 25 07:10:17 2011
New Revision: 1096421

URL: http://svn.apache.org/viewvc?rev=1096421&view=rev
Log:
PosixShm is actually SysVShm

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java
      - copied, changed from r1095928, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
Removed:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java
    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/PosixSemaphore.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShmImpl.java
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/shmem.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/config.hw

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java Mon Apr 25 07:10:17 2011
@@ -185,18 +185,4 @@ public final class Status
      */
     public static native String describe(int s);
 
-    /** Return the calling thread's last-error code value.
-     *
-     * The last-error code is maintained on a per-thread basis.
-     * Multiple threads do not overwrite each others's last-error code.
-     * Commons runtime uses it's own per-thread storage for
-     * last-error code.
-     */
-    public static native int errno();
-
-    /** Return the calling thread's last-error message.
-     *
-     */
-    public static native String msg();
-    
 }

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=1096421&r1=1096420&r2=1096421&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 Mon Apr 25 07:10:17 2011
@@ -38,15 +38,14 @@ final class Posix
     }
 
     /* open flags       */
-    public static final int O_APPEND            = 0x0001;
-    public static final int O_CREAT             = 0x0002;
-    public static final int O_EXCL              = 0x0004;
-    public static final int O_TRUNC             = 0x0008;
-    public static final int O_RDONLY            = 0x0010;
-    public static final int O_WRONLY            = 0x0020;
-    public static final int O_RDWR              = 0x0040;
-    public static final int O_ASYNC             = 0x0100;
-    public static final int O_SYNC              = 0x0200;
+    public static final int O_RDONLY            = 0;
+    public static final int O_WRONLY            = 1;
+    public static final int O_RDWR              = 2;
+
+    public static final int O_CREAT             = 0x0010;
+    public static final int O_EXCL              = 0x0020;
+    public static final int O_TRUNC             = 0x0040;
+    public static final int O_APPEND            = 0x0080;
 
     /* mmap prot        */
     public static final int PROT_EXEC           = 0x0001;
@@ -65,6 +64,31 @@ final class Posix
     public static final int MS_SYNC             = 0x0002;
     public static final int MS_INVALIDATE       = 0x0004;
 
+    public static final int S_IFMT              = 0170000; /** bit mask for the file type bit fields */
+    public static final int S_IFSOCK            = 0140000; /** socket */
+    public static final int S_IFLNK             = 0120000; /** symbolic link */
+    public static final int S_IFREG             = 0100000; /** regular file */
+    public static final int S_IFBLK             = 0060000; /** block device */
+    public static final int S_IFDIR             = 0040000; /** directory */
+    public static final int S_IFCHR             = 0020000; /** character device */
+    public static final int S_IFIFO             = 0010000; /** FIFO */
+    public static final int S_ISUID             = 0004000; /** set UID bit */
+    public static final int S_ISGID             = 0002000; /** set-group-ID bit (see below) */
+    public static final int S_ISVTX             = 0001000; /** sticky bit (see below) */
+    
+    public static final int S_IRWXU             = 00700;   /** mask for file owner permissions */
+    public static final int S_IRUSR             = 00400;   /** owner has read permission */
+    public static final int S_IWUSR             = 00200;   /** owner has write permission */
+    public static final int S_IXUSR             = 00100;   /** owner has execute permission */
+    public static final int S_IRWXG             = 00070;   /** mask for group permissions */
+    public static final int S_IRGRP             = 00040;   /** group has read permission */
+    public static final int S_IWGRP             = 00020;   /** group has write permission */
+    public static final int S_IXGRP             = 00010;   /** group has execute permission */
+    public static final int S_IRWXO             = 00007;   /** mask for permissions for others (not in group) */
+    public static final int S_IROTH             = 00004;   /** others have read permission */
+    public static final int S_IWOTH             = 00002;   /** others have write permission */
+    public static final int S_IXOTH             = 00001;   /** others have execute permission */
+    
     
     public static native int            open(String name, int flags, int mode);
     public static native int            close(int fd);
@@ -73,6 +97,10 @@ final class Posix
     public static native int            chown(String name, int uid, int gid);
     public static native int            fchmod(int fd, int mode);
     public static native int            fchown(int fd, int uid, int gid);
+    public static native int            ftruncate(int fd, long length);
+    public static native int            fstat(int fd, long[] sbuf);
+    public static native int            stat(String name, long[] sbuf);
+    public static native int            lstat(String name, long[] sbuf);
     public static native int            chdir(String path);
     public static native int            fchdir(int fd);
     public static native String         getcwd();

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java Mon Apr 25 07:10:17 2011
@@ -15,6 +15,7 @@
  */
 package org.apache.commons.runtime.platform.unix;
 
+import org.apache.commons.runtime.Errno;
 import org.apache.commons.runtime.Semaphore;
 import org.apache.commons.runtime.Status;
 import org.apache.commons.runtime.AlreadyExistsException;
@@ -57,6 +58,14 @@ final class PosixSemaphore extends Semap
     // OS semaphore handle (sem_t)
     private long    sd;
 
+    private static String posixObjectName(final String name)
+    {
+        if (name.charAt(0) == '/')
+            return "/" + name.substring(1).replace('/', '_');
+        else
+            return "/" + name.replace('/', '_');
+    }
+    
     public PosixSemaphore(final String name, int value)
         throws IllegalAccessException,
                IllegalArgumentException,
@@ -65,7 +74,7 @@ final class PosixSemaphore extends Semap
     {
         if (name == null)
             throw new NullPointerException();
-        this.name = "/" + name.replace('/', '_');
+        this.name = posixObjectName(name);
 
         while (true) {
             try {
@@ -92,7 +101,7 @@ final class PosixSemaphore extends Semap
     {
         if (name == null)
             throw new NullPointerException();
-        this.name = "/" + name.replace('/', '_');
+        this.name = posixObjectName(name);
 
         sd = open0(this.name);
         owner = false;
@@ -116,7 +125,7 @@ final class PosixSemaphore extends Semap
         int rc = try0(sd);
         if (rc == 0)
             return true;
-        if (Status.IS_EBUSY(rc))
+        else if (rc == Errno.EBUSY)
             return false;
         throw new SystemException(Status.describe(rc));        
     }

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=1096421&r1=1096420&r2=1096421&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 Mon Apr 25 07:10:17 2011
@@ -45,7 +45,7 @@ final class PosixShmImpl extends ShmImpl
     {
         if (size < Limits.SHMMIN || size > Limits.SHMMAX)
             throw new IllegalArgumentException("Shared memory size is outside the limits.");
-        return new PosixShm(name, size);
+        return new SysVShm(name, size);
     }
 
     public Shm open(String name)
@@ -54,7 +54,7 @@ final class PosixShmImpl extends ShmImpl
                NoSuchObjectException,
                SystemException
     {
-        return new PosixShm(name);
+        return new SysVShm(name);
     }
 
 }

Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java (from r1095928, 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/SysVShm.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java&r1=1095928&r2=1096421&rev=1096421&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/SysVShm.java Mon Apr 25 07:10:17 2011
@@ -25,16 +25,16 @@ import org.apache.commons.runtime.System
 import org.apache.commons.runtime.io.Syncable;
 
 /**
- * PosixShm class.
+ * SysVShm class.
  * <p>
  * </p>
  *
  * @since Runtime 1.0
  */
-final class PosixShm extends Shm
+final class SysVShm extends Shm
 {
 
-    private PosixShm()
+    private SysVShm()
     {
         // No Instance
     }
@@ -60,7 +60,7 @@ final class PosixShm extends Shm
     private long    base;
     private Pointer bptr;
 
-    public PosixShm(final String name, long size)
+    public SysVShm(final String name, long size)
         throws IllegalAccessException,
                IllegalArgumentException,
                AlreadyExistsException,
@@ -74,7 +74,7 @@ final class PosixShm extends Shm
         owner = true;
     }
 
-    public PosixShm(final String name)
+    public SysVShm(final String name)
         throws IllegalAccessException,
                IllegalArgumentException,
                NoSuchObjectException,

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Mon Apr 25 07:10:17 2011
@@ -1338,6 +1338,7 @@ extern "C" {
 #define HAVE_STRTOLL            `have_function x strtoll`
 #define HAVE_STRTOULL           `have_function x strtoull`
 #define HAVE_STRTONUM           `have_function x strtonum`
+#define HAVE_SHM_OPEN           `have_function x shm_open`
 #define HAVE_SOCK_CLOEXEC       `have_defined SOCK_CLOEXEC`
 #define HAVE_FILE_CLOEXEC       `have_defined O_CLOEXEC`
 #define HAVE_TM_TM_GMTOFF       `have_strcut_member time 'struct tm' tm_gmtoff`

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c Mon Apr 25 07:10:17 2011
@@ -26,28 +26,29 @@ ACR_UNX_EXPORT(jint, Posix, open)(JNI_ST
 {
     int fd = -1;
     int oflags = 0;
+    int aflags = 0;
 
-    if (flags & 0x0001)
-        oflags |= O_APPEND;
-    if (flags & 0x0002)
-        oflags |= O_CREAT;
-    if (flags & 0x0004)
-        oflags |= O_EXCL;
-    if (flags & 0x0008)
-        oflags |= O_TRUNC;
+    aflags = flags & 0x0003;
+    if (aflags == 0)
+        oflags = O_RDONLY;
+    else if (aflags == 1)
+        oflags = O_WRONLY;
+    else if (aflags == 2)
+        oflags = O_RDWR;
+    else {
+        ACR_SAVE_ERROR(ACR_EINVAL);
+        return -1;
+    }
     if (flags & 0x0010)
-        oflags |= O_RDONLY;
+        oflags |= O_CREAT;
     if (flags & 0x0020)
-        oflags |= O_WRONLY;
+        oflags |= O_EXCL;
     if (flags & 0x0040)
-        oflags |= O_RDWR;
-    if (flags & 0x0100)
-        oflags |= O_ASYNC;
-    if (flags & 0x0200)
-        oflags |= O_SYNC;
-    
+        oflags |= O_TRUNC;
+    if (flags & 0x0080)
+        oflags |= O_APPEND;
     WITH_CSTR(name) {
-        fd = open(J2S(name), oflags, mode);
+        fd = open(J2S(name), oflags, (mode_t)mode);
         if (fd == -1)
             ACR_SAVE_OS_ERROR();
     } DONE_WITH_STR(name);
@@ -143,6 +144,14 @@ ACR_UNX_EXPORT(jint, Posix, fchmod)(JNI_
         return errno;
 }
 
+ACR_UNX_EXPORT(jint, Posix, ftruncate)(JNI_STDARGS, jint fd, jlong length)
+{
+    if (ftruncate(fd, (off_t)length) == 0)
+        return 0;
+    else
+        return errno;
+}
+
 ACR_UNX_EXPORT(jstring, Posix, getcwd)(JNI_STDARGS)
 {
     char path[ACR_PATH_MAX];
@@ -158,7 +167,7 @@ ACR_UNX_EXPORT(jstring, Posix, getcwd)(J
 ACR_UNX_EXPORT(jlong, Posix,  mmap)(JNI_STDARGS, jlong addr, jlong size,
                                     jint prot, jint flags, jint fd, jlong offset)
 {
-    void *base = 0;
+    void *base;
     int mflags = 0;
     int mmprot = 0;
 
@@ -221,3 +230,65 @@ ACR_UNX_EXPORT(jint, Posix,  msync)(JNI_
     else
         return ACR_GET_OS_ERROR();
 }
+
+#define STRUCT_STAT_TO_ARRAY(_a, _s)      \
+    _a[0]  = _s.st_dev;                   \
+    _a[1]  = _s.st_ino;                   \
+    _a[2]  = _s.st_mode;                  \
+    _a[3]  = _s.st_nlink;                 \
+    _a[4]  = _s.st_uid;                   \
+    _a[5]  = _s.st_gid;                   \
+    _a[6]  = _s.st_size;                  \
+    _a[7]  = _s.st_atime;                 \
+    _a[8]  = _s.st_mtime;                 \
+    _a[9]  = _s.st_ctime
+
+ACR_UNX_EXPORT(jint, Posix,  fstat)(JNI_STDARGS, jint fd, jlongArray buf)
+{
+    struct_stat_t sb;
+    jlong *ja;
+
+    if (fstat(fd, &sb) == -1)
+        return ACR_GET_OS_ERROR();
+    ja = (*env)->GetPrimitiveArrayCritical(env, buf, 0);
+    STRUCT_STAT_TO_ARRAY(ja, sb);  
+    (*env)->ReleasePrimitiveArrayCritical(env, buf, ja, 0);
+
+    return 0;
+}
+
+ACR_UNX_EXPORT(jint, Posix,  stat)(JNI_STDARGS, jstring name, jlongArray buf)
+{
+    int rc = 0;
+
+    WITH_CSTR(name) {
+        struct_stat_t sb;
+        if (stat(J2S(name), &sb) == -1) {
+            rc = ACR_GET_OS_ERROR();
+        }
+        else {
+            jlong *ja = (*env)->GetPrimitiveArrayCritical(env, buf, 0);
+            STRUCT_STAT_TO_ARRAY(ja, sb);
+            (*env)->ReleasePrimitiveArrayCritical(env, buf, ja, 0);
+        }
+    } DONE_WITH_STR(name);
+    return rc;
+}
+
+ACR_UNX_EXPORT(jint, Posix,  lstat)(JNI_STDARGS, jstring name, jlongArray buf)
+{
+    int rc = 0;
+
+    WITH_CSTR(name) {
+        struct_stat_t sb;
+        if (lstat(J2S(name), &sb) == -1) {
+            rc = ACR_GET_OS_ERROR();
+        }
+        else {
+            jlong *ja = (*env)->GetPrimitiveArrayCritical(env, buf, 0);
+            STRUCT_STAT_TO_ARRAY(ja, sb);
+            (*env)->ReleasePrimitiveArrayCritical(env, buf, ja, 0);
+        }
+    } DONE_WITH_STR(name);
+    return rc;
+}

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c Mon Apr 25 07:10:17 2011
@@ -107,10 +107,12 @@ ACR_JNI_EXPORT(jboolean, Mutex, unlink0)
     jboolean rc = JNI_FALSE;
     WITH_CSTR(name) {
 #if _DEFAULT_MUTEX_TYPE == 1        
-        char *p;
         char buf[PATH_MAX] = "/";
+        char *p, *s = J2S(name);
 
-        strlcat(buf, J2S(name), PATH_MAX);
+        if (*s == '/')
+            s++;
+        strlcat(buf, s, PATH_MAX);
         for (p = &buf[1]; *p != '\0'; p++) {
             if (*p == '/')
                 *p = '_';

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c Mon Apr 25 07:10:17 2011
@@ -60,10 +60,12 @@ ACR_JNI_EXPORT(jboolean, Semaphore, unli
 {
     jboolean rc = JNI_FALSE;
     WITH_CSTR(name) {
-        char *p;
         char buf[PATH_MAX] = "/";
+        char *p, *s = J2S(name);
 
-        strlcat(buf, J2S(name), PATH_MAX);
+        if (*s == '/')
+            s++;
+        strlcat(buf, s, PATH_MAX);
         for (p = &buf[1]; *p != '\0'; p++) {
             if (*p == '/')
                 *p = '_';

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=1096421&r1=1096420&r2=1096421&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 Mon Apr 25 07:10:17 2011
@@ -57,7 +57,7 @@ ACR_JNI_EXPORT(jobject, ShmImpl, init0)(
     if (_clazzn.u == 1)
         return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
     if (AcrLoadClass(env, &_clazzn, 0) != 0) {
-        ACR_THROW_MSG(ACR_EX_EINSTANCE, "PosixShmemImpl not initialized");
+        ACR_THROW_MSG(ACR_EX_EINSTANCE, "PosixShmImpl not initialized");
         return 0;
     }
     R_LOAD_METHOD(0000, 0);
@@ -65,7 +65,7 @@ ACR_JNI_EXPORT(jobject, ShmImpl, init0)(
     return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
 }
 
-ACR_UNX_EXPORT(jint, PosixShm, create0)(JNI_STDARGS, jstring name, jlong size)
+ACR_UNX_EXPORT(jint, SysVShm, create0)(JNI_STDARGS, jstring name, jlong size)
 {
     int sd = -1;
     key_t skey;
@@ -113,7 +113,7 @@ cleanup:
     return sd;
 }
 
-ACR_UNX_EXPORT(jint, PosixShm, open0)(JNI_STDARGS, jstring name, jlongArray rs)
+ACR_UNX_EXPORT(jint, SysVShm, open0)(JNI_STDARGS, jstring name, jlongArray rs)
 {
     int sd = -1;
     key_t skey;
@@ -163,8 +163,8 @@ cleanup:
     return sd;
 }
 
-ACR_UNX_EXPORT(jlong, PosixShm, shmat0)(JNI_STDARGS, jlong addr, jint fd,
-                                        jboolean ro)
+ACR_UNX_EXPORT(jlong, SysVShm, shmat0)(JNI_STDARGS, jlong addr, jint fd,
+                                       jboolean ro)
 {
     void   *sa = J2V(addr);
     void   *sm;
@@ -177,7 +177,7 @@ ACR_UNX_EXPORT(jlong, PosixShm, shmat0)(
     return P2J(sm);
 }
 
-ACR_UNX_EXPORT(jint, PosixShm, shmdt0)(JNI_STDARGS, jlong addr)
+ACR_UNX_EXPORT(jint, SysVShm, shmdt0)(JNI_STDARGS, jlong addr)
 {
     void *sa = J2V(addr);
 
@@ -187,7 +187,7 @@ ACR_UNX_EXPORT(jint, PosixShm, shmdt0)(J
         return errno;
 }
 
-ACR_UNX_EXPORT(jint, PosixShm, unlink0)(JNI_STDARGS, jint fd, jstring name)
+ACR_UNX_EXPORT(jint, SysVShm, unlink0)(JNI_STDARGS, jint fd, jstring name)
 {
     int rc = 0;
 
@@ -200,3 +200,55 @@ ACR_UNX_EXPORT(jint, PosixShm, unlink0)(
 
     return rc;
 }
+
+#if HAVE_SHM_OPEN
+
+ACR_UNX_EXPORT(jint, PosixShm, open0)(JNI_STDARGS, jstring name, jint flags, jint mode)
+{
+    int sd = -1;
+    int oflags = 0;
+    int aflags = 0;
+
+    aflags = flags & 0x0003;
+    if (aflags == 0)
+        oflags = O_RDONLY;
+    else if (aflags == 1)
+        oflags = O_WRONLY;
+    else if (aflags == 2)
+        oflags = O_RDWR;
+    else {
+        ACR_THROW(ACR_EX_EINVAL, 0);
+        return -1;
+    }
+    if (flags & 0x0010)
+        oflags |= O_CREAT;
+    if (flags & 0x0020)
+        oflags |= O_EXCL;
+    if (flags & 0x0040)
+        oflags |= O_TRUNC;
+    if (flags & 0x0080)
+        oflags |= O_APPEND;
+
+    WITH_CSTR(name) {
+        sd = shm_open(J2S(name), oflags, (mode_t)mode);
+        if (sd == -1) {
+            ACR_THROW_SYS_ERROR();
+        }
+    } DONE_WITH_STR(name);
+
+    return sd;
+}
+
+ACR_UNX_EXPORT(jint, PosixShm, unlink0)(JNI_STDARGS, jstring name)
+{
+    int rc = 0;
+
+    WITH_CSTR(name) {
+        if (shm_unlink(J2S(name)) == -1)
+            rc = ACR_GET_OS_ERROR();
+    } DONE_WITH_STR(name);
+
+    return rc;
+}
+
+#endif

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/config.hw
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/config.hw?rev=1096421&r1=1096420&r2=1096421&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/config.hw (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/config.hw Mon Apr 25 07:10:17 2011
@@ -105,6 +105,7 @@
 #define HAVE_STRTOLL            0
 #define HAVE_STRTOULL           0
 #define HAVE_STRTONUM           0
+#define HAVE_SHM_OPEN           0
 #define HAVE_SOCK_CLOEXEC       0
 #define HAVE_FILE_CLOEXEC       0
 #define HAVE_TM_TM_GMTOFF       0