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 2009/04/09 16:35:09 UTC

svn commit: r763666 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c

Author: mturk
Date: Thu Apr  9 14:35:09 2009
New Revision: 763666

URL: http://svn.apache.org/viewvc?rev=763666&view=rev
Log:
Use Mac sysctlbyname

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c?rev=763666&r1=763665&r2=763666&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c Thu Apr  9 14:35:09 2009
@@ -18,6 +18,8 @@
 #include "acr_private.h"
 #include <sys/utsname.h>
 #include <sys/sysctl.h>
+#include <mach/machine.h>
+#include <mach-o/arch.h>
 
 #define MAXSIZESYSSTRING 256
 static const char unknown[] = "unknown";
@@ -90,9 +92,18 @@
     size_t s = sizeof(string);
     int mib[] = { CTL_HW, HW_MACHINE_ARCH };
 
-    if (sysctl(mib, 2, string, &s, 0, 0) < 0)
-        return CSTR_TO_JSTRING(unknown);
-     else
+    if (sysctl(mib, 2, string, &s, 0, 0) < 0) {
+        cpu_type_t cpu;
+        NXArchInfo const *ai;
+
+        s = sizeof(cpu_type_t);
+        if ((sysctlbyname("hw.cputype", &cpu, &s, NULL, 0) == 0) &&
+            (ai = NXGetArchInfoFromCpuType(cpu, CPU_SUBTYPE_MULTIPLE)) != NULL)
+            return CSTR_TO_JSTRING(ai->name);
+        else
+            return CSTR_TO_JSTRING(unknown);
+    }
+    else
         return CSTR_TO_JSTRING(string);
 }