harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r498815 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
Date Mon, 22 Jan 2007 21:23:51 GMT
Author: hindessm
Date: Mon Jan 22 13:23:50 2007
New Revision: 498815

URL: http://svn.apache.org/viewvc?view=rev&rev=498815
Log:
Attempt to implement some system info functions on FreeBSD.

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c?view=diff&rev=498815&r1=498814&r2=498815
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hysysinfo.c
Mon Jan 22 13:23:50 2007
@@ -38,6 +38,10 @@
 #if defined(LINUX)
 #include <sys/sysinfo.h>
 #endif
+#if defined(FREEBSD)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
 
 #include <unistd.h>
 
@@ -644,7 +648,7 @@
 UDATA VMCALL
 hysysinfo_get_number_CPUs (struct HyPortLibrary * portLibrary)
 {
-#if defined(LINUX)
+#if defined(LINUX) || defined(FREEBSD)
   /* returns number of online(_SC_NPROCESSORS_ONLN) processors, number configured(_SC_NPROCESSORS_CONF)
may  be more than online */
   return sysconf (_SC_NPROCESSORS_ONLN);
 #else
@@ -667,6 +671,18 @@
 hysysinfo_get_physical_memory (struct HyPortLibrary * portLibrary)
 {
 
+#if defined(FREEBSD)
+  /* derived from examples in sysctl(3) man page */
+  int mib[2], mem;
+  size_t len;
+
+  mib[0] = CTL_HW;
+  mib[1] = HW_PHYSMEM;
+  len = sizeof(mem);
+  sysctl(mib, 2, &mem, &len, NULL, 0);
+  return (U_64)mem;
+
+#else
   IDATA pagesize, num_pages;
 
   pagesize = sysconf (_SC_PAGESIZE);
@@ -680,6 +696,7 @@
     {
       return (U_64) pagesize *num_pages;
     }
+#endif
 
 }
 



Mime
View raw message