changeset 4807:bc7a85d7ee27

*** empty log message ***
author Roland McGrath <roland@gnu.org>
date Sun, 03 Oct 1993 19:33:04 +0000
parents d48a4664d92a
children 87a507860be7
files src/getloadavg.c
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/getloadavg.c	Sun Oct 03 16:50:05 1993 +0000
+++ b/src/getloadavg.c	Sun Oct 03 19:33:04 1993 +0000
@@ -51,6 +51,7 @@
    VMS
    __linux__			Linux: assumes /proc filesystem mounted.
    				Support from Michael K. Johnson.
+   __NetBSD__			NetBSD: assumes /kern filesystem mounted.
 
    In addition, to avoid nesting many #ifdefs, we internally set
    LDAV_DONE to indicate that the load average has been computed.
@@ -511,6 +512,35 @@
 
 #endif /* __linux__ */
 
+#if !defined (LDAV_DONE) && defined (__NetBSD__)
+#define LDAV_DONE
+#undef LOAD_AVE_TYPE
+
+#ifndef NETBSD_LDAV_FILE
+#define NETBSD_LDAV_FILE "/kern/loadavg"
+#endif
+
+  unsigned long int load_ave[3], scale;
+  int count;
+  FILE *fp;
+
+  fp = fopen (LINUX_LDAV_FILE, "r");
+  if (fp == NULL)
+    return -1;
+  count = fscanf (fp, "%lu %lu %lu %lu\n",
+		  &load_ave[0], &load_ave[1], &load_ave[2],
+		  &scale);
+  (void) fclose (fp);
+  if (count != 4)
+    return -1;
+
+  for (elem = 0; elem < nelem; elem++)
+    loadavg[elem] = (double) load_ave[elem] / (double) scale;
+
+  return elem;
+
+#endif /* __NetBSD__ */
+
 #if !defined (LDAV_DONE) && defined (NeXT)
 #define LDAV_DONE
   /* The NeXT code was adapted from iscreen 3.2.  */