commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r818107 - in /commons/sandbox/runtime/trunk/src: ant/org/apache/commons/runtime/SystemIdTask.java main/java/org/apache/commons/runtime/SystemId.java
Date Wed, 23 Sep 2009 14:01:44 GMT
Author: mturk
Date: Wed Sep 23 14:01:44 2009
New Revision: 818107

URL: http://svn.apache.org/viewvc?rev=818107&view=rev
Log:
Add getDataModel to SystemId

Modified:
    commons/sandbox/runtime/trunk/src/ant/org/apache/commons/runtime/SystemIdTask.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java

Modified: commons/sandbox/runtime/trunk/src/ant/org/apache/commons/runtime/SystemIdTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/ant/org/apache/commons/runtime/SystemIdTask.java?rev=818107&r1=818106&r2=818107&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/ant/org/apache/commons/runtime/SystemIdTask.java (original)
+++ commons/sandbox/runtime/trunk/src/ant/org/apache/commons/runtime/SystemIdTask.java Wed
Sep 23 14:01:44 2009
@@ -39,7 +39,8 @@
     /* Copy of the {@code SystemId.getSysname} method.
      * Make sure those methods are in sync!
      */
-    private static String getSysname() {
+    private static String getSysname()
+    {
         String name = props.getProperty("os.name");
         String platform = "unknown";
 
@@ -63,22 +64,41 @@
         return platform;
     }
 
-    /* Copy of the {@code SystemId.getProcessor} method.
+    /* Copy of the {@code SystemId.getDataModel} method.
      * Make sure those methods are in sync!
      */
-    private static String getProcessor()
+    private static String getDataModel()
     {
-        String cpu;
-        String name = props.getProperty("os.name");
-        String arch = props.getProperty("os.arch");
         String data = props.getProperty("sun.arch.data.model");
 
         if (data == null) {
             data = props.getProperty("com.ibm.vm.bitmode");
         }
         if (data == null) {
-            data = "32";
+            String arch = props.getProperty("os.arch");
+            if (arch.indexOf("64") < 0) {
+                /* TODO: Investigate other JVM's property for
+                 * figuring the data model (32 or 64)
+                 */
+                data = "32";
+            }
+            else {
+                data = "64";
+            }
         }
+        return data;
+    }
+
+    /* Copy of the {@code SystemId.getProcessor} method.
+     * Make sure those methods are in sync!
+     */
+    private static String getProcessor()
+    {
+        String cpu;
+        String name = props.getProperty("os.name");
+        String arch = props.getProperty("os.arch");
+        String data = getDataModel();
+
         if (arch.endsWith("86")) {
             cpu = "x86";
             if (name.startsWith("Mac OS")) {
@@ -86,12 +106,26 @@
                     cpu = "x86_64";
             }
         }
-        else if (arch.startsWith("PA_RISC"))
-            cpu = "parisc" + data;
+        else if (arch.startsWith("PA_RISC")) {
+            if (data.equals("64"))
+                cpu = "parisc64";
+            else
+                cpu = "parisc";
+        }
         else if (arch.startsWith("IA64"))
             cpu = "ia64";
-        else if (arch.startsWith("sparc"))
-            cpu = "sparc" + data;
+        else if (arch.startsWith("sparc")) {
+            if (data.equals("64"))
+                cpu = "sparc64";
+            else
+                cpu = "sparc";
+        }
+        else if (arch.startsWith("ppc")) {
+            if (data.equals("64"))
+                cpu = "ppc64";
+            else
+                cpu = "ppc";
+        }
         else if (arch.equals("amd64"))
             cpu = "x86_64";
         else
@@ -140,6 +174,7 @@
         getProject().setNewProperty(prefix + ".so",  getSoExtension());
         getProject().setNewProperty(prefix + ".cpu", getProcessor());
         getProject().setNewProperty(prefix + ".os",  getSysname());
+        getProject().setNewProperty(prefix + ".data.model", getDataModel());
     }
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java?rev=818107&r1=818106&r2=818107&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SystemId.java Wed
Sep 23 14:01:44 2009
@@ -47,7 +47,8 @@
      * @return {@code String} representing the operating system
      * this {@code JVM} is running on.
      */
-    public static String getSysname() {
+    public static String getSysname()
+    {
         String name = props.getProperty("os.name");
         String platform = "unknown";
 
@@ -72,23 +73,44 @@
     }
 
     /**
-     * Name of the operating system proccessor.
+     * Data model of the operating system proccessor.
      * @return {@code String} representing the processor
-     * this {@code JVM} is running on.
+     * data model {@code (32 or 64 bit)}.
      */
-    public static String getProcessor()
+    public static String getDataModel()
     {
-        String cpu;
-        String name = props.getProperty("os.name");
-        String arch = props.getProperty("os.arch");
         String data = props.getProperty("sun.arch.data.model");
 
         if (data == null) {
             data = props.getProperty("com.ibm.vm.bitmode");
         }
         if (data == null) {
-            data = "32";
+            String arch = props.getProperty("os.arch");
+            if (arch.indexOf("64") < 0) {
+                /* TODO: Investigate other JVM's property for
+                 * figuring the data model (32 or 64)
+                 */
+                data = "32";
+            }
+            else {
+                data = "64";
+            }
         }
+        return data;
+    }
+
+    /**
+     * Name of the operating system proccessor.
+     * @return {@code String} representing the processor
+     * this {@code JVM} is running on.
+     */
+    public static String getProcessor()
+    {
+        String cpu;
+        String name = props.getProperty("os.name");
+        String arch = props.getProperty("os.arch");
+        String data = getDataModel();
+
         if (arch.endsWith("86")) {
             cpu = "x86";
             if (name.startsWith("Mac OS")) {
@@ -96,12 +118,26 @@
                     cpu = "x86_64";
             }
         }
-        else if (arch.startsWith("PA_RISC"))
-            cpu = "parisc" + data;
+        else if (arch.startsWith("PA_RISC")) {
+            if (data.equals("64"))
+                cpu = "parisc64";
+            else
+                cpu = "parisc";
+        }
         else if (arch.startsWith("IA64"))
             cpu = "ia64";
-        else if (arch.startsWith("sparc"))
-            cpu = "sparc" + data;
+        else if (arch.startsWith("sparc")) {
+            if (data.equals("64"))
+                cpu = "sparc64";
+            else
+                cpu = "sparc";
+        }
+        else if (arch.startsWith("ppc")) {
+            if (data.equals("64"))
+                cpu = "ppc64";
+            else
+                cpu = "ppc";
+        }
         else if (arch.equals("amd64"))
             cpu = "x86_64";
         else
@@ -187,8 +223,6 @@
         else {
             ext = "so";
         }
-        /* TODO: Check if this matches the System.mapLibraryName()
-         */
         return ext;
     }
 



Mime
View raw message