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 13:19:19 UTC

svn commit: r1095364 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Limits.java java/org/apache/commons/runtime/Platform.java java/org/apache/commons/runtime/Sizeof.java native/os/unix/platform.c native/os/win32/platform.c

Author: mturk
Date: Wed Apr 20 11:19:19 2011
New Revision: 1095364

URL: http://svn.apache.org/viewvc?rev=1095364&view=rev
Log:
Add Limits class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
    commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java?rev=1095364&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java Wed Apr 20 11:19:19 2011
@@ -0,0 +1,69 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+/**
+ * Primitive native limit info.
+ *
+ * @since Runtime 1.0
+ *
+ */
+public final class Limits
+{
+
+    private Limits()
+    {
+        // No class instance
+    }
+
+
+    static {
+
+        MAX_PATH    = Platform.MAX_PATH;
+        PAGESIZE    = Platform.PAGESIZE;
+        SIZE_T_MAX  = Platform.SIZE_T_MAX;
+        SHMMAX      = Platform.SHMMAX;
+        SHMMIN      = Platform.SHMMIN;
+    }
+
+    /**
+     * Absolute maximum {@code file} path length this platfrom supports.
+     */
+    public static final int     MAX_PATH;
+
+    /**
+     * Size of the {@code memory} page allocation granularity.
+     */
+    public static final int     PAGESIZE;
+
+    /**
+     * Maximum value of native {@code size_t} type.
+     */
+    public static final long    SIZE_T_MAX;
+
+    /**
+     * Minimum size of shared memory.
+     */
+    public static final long    SHMMIN;
+
+    /**
+     * Maximum size of shared memory.
+     */
+    public static final long    SHMMAX;
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Limits.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=1095364&r1=1095363&r2=1095364&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Wed Apr 20 11:19:19 2011
@@ -19,7 +19,7 @@ import java.nio.charset.Charset;
 
 /**
  * Running Platform version info.
- * Package private
+ * Package private.
  *
  * @since Runtime 1.0
  *
@@ -47,7 +47,7 @@ final class Platform
      */
     private static native void init0(int cp);
     private static native void init1(int[] p);
-    private static native long init2();
+    private static native void init2(long[] p);
     private static final int getDefaultCharset()
     {
         int cs;
@@ -73,82 +73,97 @@ final class Platform
     }
 
     static {
-        int [] i = new int[16];
+        int  [] i = new int[16];
+        long [] s = new long[8];
 
         init0(getDefaultCharset());
         init1(i);
+        init2(s);
 
         SIZEOF_INT                      =   i[0];
         SIZEOF_LONG                     =   i[1];
         SIZEOF_SIZE_T                   =   i[2];
         SIZEOF_POINTER                  =   i[3];
-        SIZEOF_WCHAR                    =   i[4];
+        SIZEOF_WCHAR_T                  =   i[4];
         DATA_MODEL                      =   i[5];
         MAX_PATH_ELEMENT                =   i[6];
         MAX_PATH                        =   i[7];
         PAGESIZE                        =   i[8];
         ALLOCTION_GRANULARITY           =   i[9];
-        SIZE_T_MAX                      =   init2();
+        SIZE_T_MAX                      =   s[0];
+        SHMMIN                          =   s[1];
+        SHMMAX                          =   s[2];
     }
 
     /**
      * Size of the native platform {@code int} type in bytes.
      */
-    public static final int SIZEOF_INT;
+    public static final int     SIZEOF_INT;
 
     /**
      * Size of the native platform {@code long} type in bytes.
      */
-    public static final int SIZEOF_LONG;
+    public static final int     SIZEOF_LONG;
 
     /**
      * Size of the native platform {@code size_t} type in bytes.
      */
-    public static final int SIZEOF_SIZE_T;
+    public static final int     SIZEOF_SIZE_T;
 
     /**
      * Size of the native platform {@code pointer} type in bytes.
      */
-    public static final int SIZEOF_POINTER;
+    public static final int     SIZEOF_POINTER;
 
     /**
-     * Size of the native platform {@code size_t} type in bytes.
+     * Size of the native platform {@code wchar_t} type in bytes.
      */
-    public static final int SIZEOF_WCHAR;
+    public static final int     SIZEOF_WCHAR_T;
 
 
     /**
      * Platfrom data model {@code 32} or {@code 64} bits.
      */
-    public static final int DATA_MODEL;
+    public static final int     DATA_MODEL;
 
     /**
      * Maximum {@code file} path length this platfrom supports.
      * On some platforms like {@code Microsoft Windows} this
      * is maximum length of each {@code path} elements.
      */
-    public static final int MAX_PATH_ELEMENT;
+    public static final int     MAX_PATH_ELEMENT;
 
     /**
      * Absolute maximum {@code file} path length this platfrom supports.
      */
-    public static final int MAX_PATH;
+    public static final int     MAX_PATH;
 
     /**
      * Size of the {@code memory} page allocation granularity.
      */
-    public static final int PAGESIZE;
+    public static final int     PAGESIZE;
 
     /**
      * The granualarity of the starting address at wich {@code memory} pages
      * can be allocated.
      */
-    public static final int ALLOCTION_GRANULARITY;
+    public static final int     ALLOCTION_GRANULARITY;
 
     /**
      * Maximum value of native {@code size_t} type.
      */
-    public static final long SIZE_T_MAX;
+    public static final long    SIZE_T_MAX;
+
+    /**
+     * Minimum size of shared memory.
+     */
+    public static final long    SHMMIN;
+
+    /**
+     * Maximum size of shared memory.
+     */
+    public static final long    SHMMAX;
 
+    
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java?rev=1095364&r1=1095363&r2=1095364&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Sizeof.java Wed Apr 20 11:19:19 2011
@@ -37,7 +37,7 @@ public final class Sizeof
         LONG    = Platform.SIZEOF_LONG;
         SIZE_T  = Platform.SIZEOF_SIZE_T;
         POINTER = Platform.SIZEOF_POINTER;
-        WCHAR   = Platform.SIZEOF_WCHAR;
+        WCHAR_T = Platform.SIZEOF_WCHAR_T;
     }
 
     /**
@@ -63,7 +63,7 @@ public final class Sizeof
     /**
      * Size of the native platform {@code wchar_t} type in bytes.
      */
-    public static final int WCHAR;
+    public static final int WCHAR_T;
 
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c?rev=1095364&r1=1095363&r2=1095364&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/platform.c Wed Apr 20 11:19:19 2011
@@ -17,6 +17,9 @@
 #include "acr/string.h"
 #include "acr/port.h"
 
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
 extern int acr_native_codepage;
 
 ACR_JNI_EXPORT(void, Platform, init0)(JNI_STDARGS, jint cp)
@@ -36,7 +39,6 @@ ACR_JNI_EXPORT(void, Platform, init1)(JN
     jint ia[16];
 
     UNREFERENCED_OBJECT;
-    (*env)->GetIntArrayRegion(env, p, 0, 16, ia);
 
     ia[0]  = ISIZEOF(int);
     ia[1]  = ISIZEOF(long);
@@ -56,10 +58,24 @@ ACR_JNI_EXPORT(void, Platform, init1)(JN
     (*env)->SetIntArrayRegion(env, p, 0, 16, ia);
 }
 
-ACR_JNI_EXPORT(jlong, Platform, init2)(JNI_STDARGS)
+ACR_JNI_EXPORT(void, Platform, init2)(JNI_STDARGS, jlongArray p)
 {
-    jlong rv = ACR_I64_C(0);
-    return rv + SIZE_T_MAX;
+    jlong sa[8];
+
+    UNREFERENCED_OBJECT;
+
+    sa[0]  = SIZE_T_MAX;
+#if defined(SHMMIN)    
+    sa[1]  = SHMMIN;
+#else
+    sa[1]  = getpagesize();
+#endif
+#if defined(SHMMAX)
+    sa[2]  = SHMMAX;
+#else
+    sa[2]  = SIZE_T_MAX;
+#endif
+    (*env)->SetLongArrayRegion(env, p, 0, 8, sa);
 }
 
 ACR_JNI_EXPORT(jboolean, Platform, supported0)(JNI_STDARGS)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=1095364&r1=1095363&r2=1095364&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Wed Apr 20 11:19:19 2011
@@ -59,10 +59,16 @@ ACR_JNI_EXPORT(void, Platform, init1)(JN
     (*env)->SetIntArrayRegion(env, p, 0, 16, ia);
 }
 
-ACR_JNI_EXPORT(jlong, Platform, init2)(JNI_STDARGS)
+ACR_JNI_EXPORT(void, Platform, init2)(JNI_STDARGS, jlongArray p)
 {
-    jlong rv = ACR_I64_C(0);
-    return rv + SIZE_T_MAX;
+    jlong sa[8];
+
+    UNREFERENCED_OBJECT;
+
+    sa[0]  = SIZE_T_MAX;
+    sa[1]  = getpagesize();
+    sa[2]  = SIZE_T_MAX;
+    (*env)->SetLongArrayRegion(env, p, 0, 8, sa);
 }
 
 ACR_JNI_EXPORT(jboolean, Platform, supported0)(JNI_STDARGS)