UnixOperatingSystem.st
changeset 3737 7560b716b2d5
parent 3735 3560084b4f83
child 3759 1601d99a36b5
--- a/UnixOperatingSystem.st	Wed Aug 05 18:08:50 1998 +0200
+++ b/UnixOperatingSystem.st	Wed Aug 05 19:34:41 1998 +0200
@@ -545,6 +545,18 @@
 #  undef HAS_WAIT3
 # endif
 
+# if defined(alpha) && defined(__osf__)
+#  ifndef HAS_GETSYSTEMINFO
+#   define HAS_GETSYSTEMINFO
+#  endif
+# endif
+
+# if defined(solaris)
+#  ifndef HAS_SYSCONF
+#   define HAS_SYSCONF
+#  endif
+# endif
+
 /*
  * some (BSD ?) have no timezone global,
  * but provide the info in struct timezone.
@@ -576,12 +588,18 @@
 #  include <linux/sys.h>
 # endif
 
-#if defined(alpha) && defined(__osf__)
+#if defined(HAS_GETSYSTEMINFO)
 # include <sys/sysinfo.h>
 # include <machine/hal_sysinfo.h>
 # include <machine/hal/cpuconf.h>
-# define HAS_GETSYSTEMINFO
-#endif
+#endif
+
+# if defined(HAS_SYSCONF)
+#  ifndef _UNISTD_H_INCLUDED_
+#   include <unistd.h>
+#   define _UNISTD_H_INCLUDED_
+#  endif
+# endif
 
 #endif /* not transputer */
 
@@ -6618,8 +6636,8 @@
         #domain  -> domain name (hosts domain)
         #machine -> type of CPU (i586, mips ...)
      
-     those are only returned on some machines
-     (currently: linux):
+     those are currently returned on some machines (no warranty)
+     linux:
         #totalRam -> total amount of memory available
         #sharedRam -> amount of memory which is shared among processes
                       (i.e. shared code)
@@ -6627,14 +6645,21 @@
         #swapSize -> total size of swap space
         #freeSwap -> free amount in swapSpace
 
-     (currently: osf):
+     osf:
         #physicalRam -> total amount of physical memory
         #cpuType -> type of cpu (more detailed than machine)
+        #numberOfCPUs -> number of cpus in box
         
+     solaris:
+        #physicalRam -> total amount of physical memory
+        #numberOfCPUs -> number of cpus in box
+	#dCacheSize -> bytes in data cache
+	#iCacheSize -> bytes in data cache
     "
 
     |sys node rel ver mach dom mtyp brel info arch cpuType
-     physicalRam totalRam sharedRam bufferRam swapSize freeSwap numberOfCPUs|
+     physicalRam totalRam sharedRam bufferRam swapSize freeSwap
+     numberOfCPUs pageSize physicalPages dCacheSize iCacheSize|
 
 %{  /* STACK: 4096 */
 
@@ -6698,6 +6723,56 @@
     }
 #endif /* HAS_GETDOMAINNAME */
 
+#if defined(HAS_SYSCONF)
+
+# ifdef _SC_NPROCESSORS_ONLN
+    {
+	long val;
+ 
+        val = sysconf(_SC_NPROCESSORS_ONLN);
+	if (val > 0) {
+	    numberOfCPUs = __MKINT(val);
+	}
+    }
+# endif
+# if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
+    {
+	long val;
+
+	val = sysconf(_SC_PHYS_PAGES);
+	if (val != -1) {
+	    physicalPages = __MKUINT(val);
+	    val = sysconf(_SC_PAGESIZE);
+	    if (val != -1) {
+	        pageSize = __MKUINT(val);
+	    }
+	}
+    }
+# endif
+# if defined(_SC_ICACHE_SZ)
+    {
+	long val;
+
+	val = sysconf(_SC_ICACHE_SZ);
+	if (val != -1) {
+	    iCacheSize = __MKUINT(val);
+	}
+    }
+# endif
+# if defined(_SC_DCACHE_SZ)
+    {
+        long val;
+ 
+        val = sysconf(_SC_DCACHE_SZ);
+        if (val != -1) {
+            dCacheSize = __MKUINT(val);
+        }
+    }
+# endif
+
+
+#endif /* HAS_SYSCONF */
+
 #if defined(HAS_GETSYSTEMINFO)
     {
         INT index;
@@ -7017,6 +7092,9 @@
     mach notNil ifTrue:[info at:#machine put:mach].
     arch notNil ifTrue:[info at:#architecture put:arch].
     dom notNil ifTrue:[info at:#domain put:dom].
+    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
+	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
+    ].
     physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
     totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
     sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
@@ -7025,6 +7103,8 @@
     freeSwap notNil ifTrue:[info at:#freeSwap put:freeSwap].
     numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
     cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
+    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
+    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
     info at:#osType put:(self getOSType).
     ^ info
 
@@ -9027,6 +9107,6 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.34 1998-08-05 16:04:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.35 1998-08-05 17:34:41 cg Exp $'
 ! !
 UnixOperatingSystem initialize!