aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoland McGrath1993-10-03 19:33:04 +0000
committerRoland McGrath1993-10-03 19:33:04 +0000
commit9eb8034b1e0b2f4c6ce799302c111ab056287167 (patch)
tree66dfdf1af09a87d63f0dc96d42dffb050cf89a0a /src
parent77ba1f303acb856b3720073cba7e38001cc4f787 (diff)
downloademacs-9eb8034b1e0b2f4c6ce799302c111ab056287167.tar.gz
emacs-9eb8034b1e0b2f4c6ce799302c111ab056287167.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/getloadavg.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/getloadavg.c b/src/getloadavg.c
index ad79231f671..d94d58946c3 100644
--- a/src/getloadavg.c
+++ b/src/getloadavg.c
@@ -51,6 +51,7 @@
51 VMS 51 VMS
52 __linux__ Linux: assumes /proc filesystem mounted. 52 __linux__ Linux: assumes /proc filesystem mounted.
53 Support from Michael K. Johnson. 53 Support from Michael K. Johnson.
54 __NetBSD__ NetBSD: assumes /kern filesystem mounted.
54 55
55 In addition, to avoid nesting many #ifdefs, we internally set 56 In addition, to avoid nesting many #ifdefs, we internally set
56 LDAV_DONE to indicate that the load average has been computed. 57 LDAV_DONE to indicate that the load average has been computed.
@@ -511,6 +512,35 @@ getloadavg (loadavg, nelem)
511 512
512#endif /* __linux__ */ 513#endif /* __linux__ */
513 514
515#if !defined (LDAV_DONE) && defined (__NetBSD__)
516#define LDAV_DONE
517#undef LOAD_AVE_TYPE
518
519#ifndef NETBSD_LDAV_FILE
520#define NETBSD_LDAV_FILE "/kern/loadavg"
521#endif
522
523 unsigned long int load_ave[3], scale;
524 int count;
525 FILE *fp;
526
527 fp = fopen (LINUX_LDAV_FILE, "r");
528 if (fp == NULL)
529 return -1;
530 count = fscanf (fp, "%lu %lu %lu %lu\n",
531 &load_ave[0], &load_ave[1], &load_ave[2],
532 &scale);
533 (void) fclose (fp);
534 if (count != 4)
535 return -1;
536
537 for (elem = 0; elem < nelem; elem++)
538 loadavg[elem] = (double) load_ave[elem] / (double) scale;
539
540 return elem;
541
542#endif /* __NetBSD__ */
543
514#if !defined (LDAV_DONE) && defined (NeXT) 544#if !defined (LDAV_DONE) && defined (NeXT)
515#define LDAV_DONE 545#define LDAV_DONE
516 /* The NeXT code was adapted from iscreen 3.2. */ 546 /* The NeXT code was adapted from iscreen 3.2. */