the nlist n_name element is a pointer,
not an array.
NLIST_NAME_UNION struct nlist has an n_un member, not n_name.
- LINUX_LDAV_FILE [LINUX]: Name of file containing load averages.
+ LINUX_LDAV_FILE [__linux__]: File containing load averages.
Specific system predefines this file uses, aside from setting
default values if not emacs:
UMAX
UMAX4_3
VMS
- LINUX Linux: assumes /proc filesystem mounted.
+ __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.
#ifdef HAVE_CONFIG_H
+#if defined (emacs) || defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
#include "config.h"
#endif
+#endif
+
+
+/* Exclude all the code except the test program at the end
+ if the system has its own `getloadavg' function. */
+
+#ifndef HAVE_GETLOADAVG
+
/* The existing Emacs configuration files define a macro called
LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
#define SUNOS_5
#endif
-#if defined (__osf__) && defined (__alpha__)
+#if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
#define OSF_ALPHA
#endif
#endif /* No LOAD_AVE_TYPE. */
+#ifdef OSF_ALPHA
+/* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
+ according to ghazi@noc.rutgers.edu. */
+#undef FSCALE
+#define FSCALE 1024.0
+#endif
+
+
#ifndef FSCALE
/* SunOS and some others define FSCALE in sys/param.h. */
#endif
#if defined (sgi) || defined (sequent)
+/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
+ above under #ifdef MIPS. But we want the sgi value. */
+#undef FSCALE
#define FSCALE 1000.0
#endif
elem = -1;
#endif
-#if !defined (LDAV_DONE) && defined (LINUX)
+#if !defined (LDAV_DONE) && defined (__linux__)
#define LDAV_DONE
#undef LOAD_AVE_TYPE
return elem;
-#endif /* LINUX */
+#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 (NETBSD_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
return -1;
#endif
}
+
+#endif /* ! HAVE_GETLOADAVG */
\f
#ifdef TEST
void
if (argc > 1)
naptime = atoi (argv[1]);
- if (naptime == 0)
- naptime = 5;
-
while (1)
{
double avg[3];
printf ("15-minute: %f ", avg[2]);
if (loads > 0)
putchar ('\n');
+
+ if (naptime == 0)
+ break;
sleep (naptime);
}
+
+ exit (0);
}
#endif /* TEST */