commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r787150 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ main/native/os/darwin/ main/native/os/hpux/ main/native/os/linux/ main/native/os/solaris/ main/native/os/win32/ test/org/apache/commons/runtime/
Date Mon, 22 Jun 2009 06:27:30 GMT
Author: mturk
Date: Mon Jun 22 06:27:29 2009
New Revision: 787150

URL: http://svn.apache.org/viewvc?rev=787150&view=rev
Log:
Calculate structure alignment at runtime.
TODO: Structure code needs revision

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
    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
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java

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=787150&r1=787149&r2=787150&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 Mon
Jun 22 06:27:29 2009
@@ -58,6 +58,11 @@
         ABS_MAX_PATH                    =   i[7];
         PAGESIZE                        =   i[8];
 
+        if (i[9] == 16)
+            STRUCT_ALIGN = 4;
+        else
+            STRUCT_ALIGN = 8;
+
     }
 
     /**
@@ -108,4 +113,10 @@
      */
     public static final int PAGESIZE;
 
+    /**
+     * Size of the {@code structure} alignment.
+     */
+    public static final int STRUCT_ALIGN;
+
 }
+

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=787150&r1=787149&r2=787150&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 Mon Jun 22 06:27:29
2009
@@ -23,6 +23,12 @@
 static const char unknown[] = "unknown";
 acr_size_t acr_page_size;
 
+typedef struct struct_align_t {
+    char        c;
+    acr_int64_t l;
+    acr_int32_t i;
+} struct_align_t;
+
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
 {
@@ -44,6 +50,7 @@
     ia[7]  =   PATH_MAX;
     acr_page_size = (acr_size_t)getpagesize();
     ia[8]  =   (jint)acr_page_size;
+    ia[9]  =   (jint)sizeof(struct_align_t);
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

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=787150&r1=787149&r2=787150&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 Mon Jun 22 06:27:29 2009
@@ -23,6 +23,12 @@
 static const char unknown[] = "unknown";
 acr_size_t acr_page_size;
 
+typedef struct struct_align_t {
+    char        c;
+    acr_int64_t l;
+    acr_int32_t i;
+} struct_align_t;
+
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
 {
@@ -44,6 +50,7 @@
     ia[7]  =   PATH_MAX;
     acr_page_size = (acr_size_t)getpagesize();
     ia[8]  =   (jint)acr_page_size;
+    ia[9]  =   (jint)sizeof(struct_align_t);
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

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=787150&r1=787149&r2=787150&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 Mon Jun 22 06:27:29
2009
@@ -23,6 +23,12 @@
 static const char unknown[] = "unknown";
 acr_size_t acr_page_size;
 
+typedef struct struct_align_t {
+    char        c;
+    acr_int64_t l;
+    acr_int32_t i;
+} struct_align_t;
+
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
 {
@@ -44,6 +50,7 @@
     ia[7]  =   PATH_MAX;
     acr_page_size = (acr_size_t)getpagesize();
     ia[8]  =   (jint)acr_page_size;
+    ia[9]  =   (jint)sizeof(struct_align_t);
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

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=787150&r1=787149&r2=787150&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 Mon Jun 22 06:27:29
2009
@@ -23,6 +23,12 @@
 static const char unknown[] = "unknown";
 acr_size_t acr_page_size;
 
+typedef struct struct_align_t {
+    char        c;
+    acr_int64_t l;
+    acr_int32_t i;
+} struct_align_t;
+
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
 {
@@ -44,6 +50,7 @@
     ia[7]  =   PATH_MAX;
     acr_page_size = (acr_size_t)getpagesize();
     ia[8]  =   (jint)acr_page_size;
+    ia[9]  =   (jint)sizeof(struct_align_t);
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

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=787150&r1=787149&r2=787150&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 Mon Jun 22 06:27:29
2009
@@ -28,6 +28,12 @@
 extern LPSYSTEM_INFO acr_osinf;
 acr_size_t  acr_page_size;
 
+typedef struct struct_align_t {
+    char        c;
+    acr_int64_t l;
+    acr_int32_t i;
+} struct_align_t;
+
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
 {
@@ -58,6 +64,7 @@
     ia[7]  =   32760;
     acr_page_size = (acr_size_t)acr_osinf->dwPageSize;
     ia[8]  =   (jint)acr_page_size;
+    ia[9]  =   (jint)sizeof(struct_align_t);
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java?rev=787150&r1=787149&r2=787150&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java Mon Jun
22 06:27:29 2009
@@ -78,6 +78,7 @@
         System.out.println("Max path   " + Platform.MAX_PATH);
         System.out.println("Abs path   " + Platform.ABS_MAX_PATH);
         System.out.println("Page size  " + Platform.PAGESIZE);
+        System.out.println("Alignment  " + Platform.STRUCT_ALIGN);
 
     }
 



Mime
View raw message