Author: mturk
Date: Thu Apr 23 13:48:19 2009
New Revision: 767922

URL: http://svn.apache.org/viewvc?rev=767922&view=rev
Log:
Use a single call and fill int[] array instead multiple calls

Modified:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c

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=767922&r1=767921&r2=767922&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
 Thu Apr 23 13:48:19 2009
@@ -33,16 +33,17 @@
      * Get Platform integer property value.
      * @see APR_PLAT_* in acr_platform.h file.
      */
-    private static native int intProp(int what);
+    private static native int[] intProp();
 
     static {
-        SIZEOF_INT                      =   intProp(0);
-        SIZEOF_LONG                     =   intProp(1);
-        SIZEOF_SIZE_T                   =   intProp(2);
-        SIZEOF_POINTER                  =   intProp(3);
-        SIZEOF_WCHAR                    =   intProp(4);
-        DATA_MODEL                      =   intProp(5);
-        MAX_PATH                        =   intProp(6);
+        int [] i                        = intProp();
+        SIZEOF_INT                      =   i[0];
+        SIZEOF_LONG                     =   i[1];
+        SIZEOF_SIZE_T                   =   i[2];
+        SIZEOF_POINTER                  =   i[3];
+        SIZEOF_WCHAR                    =   i[4];
+        DATA_MODEL                      =   i[5];
+        MAX_PATH                        =   i[6];
     }
 
     /**

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h?rev=767922&r1=767921&r2=767922&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h Thu 
Apr 23 13:48:19 2009
@@ -31,13 +31,6 @@
  * ACR platform private structures
  *
  */
-#define ACR_PLAT_SIZEOF_INT                     0
-#define ACR_PLAT_SIZEOF_LONG                    1
-#define ACR_PLAT_SIZEOF_SIZE_T                  2
-#define ACR_PLAT_SIZEOF_POINTER                 3
-#define ACR_PLAT_SIZEOF_WCHAR                   4
-#define ACR_PLAT_DATA_MODEL                     5
-#define ACR_PLAT_PATH_MAX                       6
 
 #ifdef __cplusplus
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c?rev=767922&r1=767921&r2=767922&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c Thu Apr 
23 13:48:19 2009
@@ -22,39 +22,27 @@
 
 static const char unknown[] = "unknown";
 
-ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what)
+ACR_JNI_EXPORT_DECLARE(jintArray, Platform, intProp)(ACR_JNISTDARGS)
 {
-    UNREFERENCED_STDARGS;
+    jintArray ra;
+    int ia[32];
+    UNREFERENCED_O;
 
-    switch (what) {
-        case ACR_PLAT_SIZEOF_INT:
-            return sizeof(int);
-        break;
-        case ACR_PLAT_SIZEOF_LONG:
-            return sizeof(long);
-        break;
-        case ACR_PLAT_SIZEOF_SIZE_T:
-            return sizeof(size_t);
-        break;
-        case ACR_PLAT_SIZEOF_POINTER:
-            return sizeof(void *);
-        break;
-        case ACR_PLAT_SIZEOF_WCHAR:
-            return sizeof(wchar_t);
-        break;
-        case ACR_PLAT_DATA_MODEL:
+    ia[0]  =   sizeof(int);
+    ia[1]  =   sizeof(long);
+    ia[2]  =   sizeof(size_t);
+    ia[3]  =   sizeof(void *);
+    ia[4]  =   sizeof(wchar_t);
 #if CC_SIZEOF_VOIDP == 8
-            return 64;
+    ia[5]  =   64;
 #else
-            return 32;
+    ia[5]  =   32;
 #endif
-        break;
-        case ACR_PLAT_PATH_MAX:
-            return PATH_MAX;
-        break;
-        default:
-        break;
-    }
+    ia[6]  =   PATH_MAX;
 
-    return -1;
+    ra = (*_E)->NewIntArray(_E, 32);
+    if (ra) {
+        (*_E)->SetIntArrayRegion(_E, ra, 0, 32, ia);
+    }
+    return ra;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c?rev=767922&r1=767921&r2=767922&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c Thu Apr 23 
13:48:19 2009
@@ -22,39 +22,27 @@
 
 static const char unknown[] = "unknown";
 
-ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what)
+ACR_JNI_EXPORT_DECLARE(jintArray, Platform, intProp)(ACR_JNISTDARGS)
 {
-    UNREFERENCED_STDARGS;
+    jintArray ra;
+    int ia[32];
+    UNREFERENCED_O;
 
-    switch (what) {
-        case ACR_PLAT_SIZEOF_INT:
-            return sizeof(int);
-        break;
-        case ACR_PLAT_SIZEOF_LONG:
-            return sizeof(long);
-        break;
-        case ACR_PLAT_SIZEOF_SIZE_T:
-            return sizeof(size_t);
-        break;
-        case ACR_PLAT_SIZEOF_POINTER:
-            return sizeof(void *);
-        break;
-        case ACR_PLAT_SIZEOF_WCHAR:
-            return sizeof(wchar_t);
-        break;
-        case ACR_PLAT_DATA_MODEL:
+    ia[0]  =   sizeof(int);
+    ia[1]  =   sizeof(long);
+    ia[2]  =   sizeof(size_t);
+    ia[3]  =   sizeof(void *);
+    ia[4]  =   sizeof(wchar_t);
 #if CC_SIZEOF_VOIDP == 8
-            return 64;
+    ia[5]  =   64;
 #else
-            return 32;
+    ia[5]  =   32;
 #endif
-        break;
-        case ACR_PLAT_PATH_MAX:
-            return PATH_MAX;
-        break;
-        default:
-        break;
-    }
+    ia[6]  =   PATH_MAX;
 
-    return -1;
+    ra = (*_E)->NewIntArray(_E, 32);
+    if (ra) {
+        (*_E)->SetIntArrayRegion(_E, ra, 0, 32, ia);
+    }
+    return ra;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c?rev=767922&r1=767921&r2=767922&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c Thu Apr 
23 13:48:19 2009
@@ -22,39 +22,27 @@
 
 static const char unknown[] = "unknown";
 
-ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what)
+ACR_JNI_EXPORT_DECLARE(jintArray, Platform, intProp)(ACR_JNISTDARGS)
 {
-    UNREFERENCED_STDARGS;
+    jintArray ra;
+    int ia[32];
+    UNREFERENCED_O;
 
-    switch (what) {
-        case ACR_PLAT_SIZEOF_INT:
-            return sizeof(int);
-        break;
-        case ACR_PLAT_SIZEOF_LONG:
-            return sizeof(long);
-        break;
-        case ACR_PLAT_SIZEOF_SIZE_T:
-            return sizeof(size_t);
-        break;
-        case ACR_PLAT_SIZEOF_POINTER:
-            return sizeof(void *);
-        break;
-        case ACR_PLAT_SIZEOF_WCHAR:
-            return sizeof(wchar_t);
-        break;
-        case ACR_PLAT_DATA_MODEL:
+    ia[0]  =   sizeof(int);
+    ia[1]  =   sizeof(long);
+    ia[2]  =   sizeof(size_t);
+    ia[3]  =   sizeof(void *);
+    ia[4]  =   sizeof(wchar_t);
 #if CC_SIZEOF_VOIDP == 8
-            return 64;
+    ia[5]  =   64;
 #else
-            return 32;
+    ia[5]  =   32;
 #endif
-        break;
-        case ACR_PLAT_PATH_MAX:
-            return PATH_MAX;
-        break;
-        default:
-        break;
-    }
+    ia[6]  =   PATH_MAX;
 
-    return -1;
+    ra = (*_E)->NewIntArray(_E, 32);
+    if (ra) {
+        (*_E)->SetIntArrayRegion(_E, ra, 0, 32, ia);
+    }
+    return ra;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c?rev=767922&r1=767921&r2=767922&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c Thu Apr 
23 13:48:19 2009
@@ -22,39 +22,27 @@
 
 static const char unknown[] = "unknown";
 
-ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what)
+ACR_JNI_EXPORT_DECLARE(jintArray, Platform, intProp)(ACR_JNISTDARGS)
 {
-    UNREFERENCED_STDARGS;
+    jintArray ra;
+    int ia[32];
+    UNREFERENCED_O;
 
-    switch (what) {
-        case ACR_PLAT_SIZEOF_INT:
-            return sizeof(int);
-        break;
-        case ACR_PLAT_SIZEOF_LONG:
-            return sizeof(long);
-        break;
-        case ACR_PLAT_SIZEOF_SIZE_T:
-            return sizeof(size_t);
-        break;
-        case ACR_PLAT_SIZEOF_POINTER:
-            return sizeof(void *);
-        break;
-        case ACR_PLAT_SIZEOF_WCHAR:
-            return sizeof(wchar_t);
-        break;
-        case ACR_PLAT_DATA_MODEL:
+    ia[0]  =   sizeof(int);
+    ia[1]  =   sizeof(long);
+    ia[2]  =   sizeof(size_t);
+    ia[3]  =   sizeof(void *);
+    ia[4]  =   sizeof(wchar_t);
 #if CC_SIZEOF_VOIDP == 8
-            return 64;
+    ia[5]  =   64;
 #else
-            return 32;
+    ia[5]  =   32;
 #endif
-        break;
-        case ACR_PLAT_PATH_MAX:
-            return PATH_MAX;
-        break;
-        default:
-        break;
-    }
+    ia[6]  =   PATH_MAX;
 
-    return -1;
+    ra = (*_E)->NewIntArray(_E, 32);
+    if (ra) {
+        (*_E)->SetIntArrayRegion(_E, ra, 0, 32, ia);
+    }
+    return ra;
 }

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=767922&r1=767921&r2=767922&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 Thu Apr 
23 13:48:19 2009
@@ -22,40 +22,27 @@
 
 static const char unknown[] = "unknown";
 
-ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what)
+ACR_JNI_EXPORT_DECLARE(jintArray, Platform, intProp)(ACR_JNISTDARGS)
 {
-    UNREFERENCED_STDARGS;
+    jintArray ra;
+    int ia[32];
+    UNREFERENCED_O;
 
-    switch (what) {
-        case ACR_PLAT_SIZEOF_INT:
-            return sizeof(int);
-        break;
-        case ACR_PLAT_SIZEOF_LONG:
-            return sizeof(long);
-        break;
-        case ACR_PLAT_SIZEOF_SIZE_T:
-            return sizeof(size_t);
-        break;
-        case ACR_PLAT_SIZEOF_POINTER:
-            return sizeof(void *);
-        break;
-        case ACR_PLAT_SIZEOF_WCHAR:
-            return sizeof(wchar_t);
-        break;
-        case ACR_PLAT_DATA_MODEL:
+    ia[0]  =   sizeof(int);
+    ia[1]  =   sizeof(long);
+    ia[2]  =   sizeof(size_t);
+    ia[3]  =   sizeof(void *);
+    ia[4]  =   sizeof(wchar_t);
 #if CC_SIZEOF_VOIDP == 8
-            return 64;
+    ia[5]  =   64;
 #else
-            return 32;
+    ia[5]  =   32;
 #endif
-        break;
-        case ACR_PLAT_PATH_MAX:
-            /* Without \\?\ frefix */ 
-            return 248;
-        break;
-        default:
-        break;
-    }
+    ia[6]  =   248;
 
-    return -1;
+    ra = (*_E)->NewIntArray(_E, 32);
+    if (ra) {
+        (*_E)->SetIntArrayRegion(_E, ra, 0, 32, ia);
+    }
+    return ra;
 }


Reply via email to