summaryrefslogtreecommitdiff
path: root/getloadavg.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-10-03 19:33:04 +0000
committerRoland McGrath <roland@redhat.com>1993-10-03 19:33:04 +0000
commit492f92b9ec1178dd0e078106114ac0ed29940eba (patch)
tree8575cbb10e600cc9a2d30e70d18f7790b6afefd2 /getloadavg.c
parentcc5be7c0cd7f22b96f6b75ed2edd05ede457a7cc (diff)
downloadgunmake-492f92b9ec1178dd0e078106114ac0ed29940eba.tar.gz
*** empty log message ***
Diffstat (limited to 'getloadavg.c')
-rw-r--r--getloadavg.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/getloadavg.c b/getloadavg.c
index ad79231..d94d589 100644
--- a/getloadavg.c
+++ b/getloadavg.c
@@ -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 @@ getloadavg (loadavg, nelem)
#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. */