/* Compile-time symbols that this file uses:
+ HAVE_PSTAT_GETDYNAMIC Define this if your system has the
+ pstat_getdynamic function. I think it
+ is unique to HPUX9. The best way to get the
+ definition is through the AC_FUNC_GETLOADAVG
+ macro that comes with autoconf 2.13 or newer.
+ If that isn't an option, then just put
+ AC_CHECK_FUNCS(pstat_getdynamic) in your
+ configure.in file.
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
KERNEL_FILE Pathname of the kernel to nlist.
LDAV_CVT() Scale the load average from the kernel.
LOAD_AVE_TYPE Type of the load average array in the kernel.
Must be defined unless one of
apollo, DGUX, NeXT, or UMAX is defined;
+ or we have libkstat;
otherwise, no load average is available.
NLIST_STRUCT Include nlist.h, not a.out.h, and
the nlist n_name element is a pointer,
DGUX
eunice UNIX emulator under VMS.
hpux
- MSDOS No-op for MSDOS.
+ __MSDOS__ No-op for MSDOS.
NeXT
sgi
sequent Sequent Dynix 3.x.x (BSD)
UMAX
UMAX4_3
VMS
- WIN32 No-op for Windows95/NT.
+ WINDOWS32 No-op for Windows95/NT.
__linux__ Linux: assumes /proc filesystem mounted.
Support from Michael K. Johnson.
__NetBSD__ NetBSD: assumes /kern filesystem mounted.
/* Both the Emacs and non-Emacs sections want this. Some
configuration files' definitions for the LOAD_AVE_CVT macro (like
sparc.h's) use macros like FSCALE, defined here. */
-#ifdef unix
+#if defined (unix) || defined (__unix)
# include <sys/param.h>
#endif
# undef FSCALE
# endif
+/* Same issues as for NeXT apply to the HURD-based GNU system. */
+# ifdef __GNU__
+# undef BSD
+# undef FSCALE
+# endif /* __GNU__ */
+
/* Set values that are different from the defaults, which are
set a little farther down with #ifndef. */
# if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
# define OSF_ALPHA
+# include <sys/mbuf.h>
+# include <sys/socket.h>
+# include <net/route.h>
# include <sys/table.h>
# endif
# define LDAV_CVT(n) (((double) (n)) / FSCALE)
# endif
-/* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */
-# ifndef NLIST_STRUCT
-
-# ifdef MORE_BSD
-# define NLIST_STRUCT
-# endif
-
-# ifdef sun
-# define NLIST_STRUCT
-# endif
-
-# ifdef decstation
-# define NLIST_STRUCT
-# endif
-
-# ifdef hpux
-# define NLIST_STRUCT
-# endif
-
-# if defined (_SEQUENT_) || defined (sequent)
-# define NLIST_STRUCT
-# endif
-
-# ifdef sgi
-# define NLIST_STRUCT
-# endif
-
-# ifdef SVR4
-# define NLIST_STRUCT
-# endif
-
-# ifdef sony_news
-# define NLIST_STRUCT
-# endif
-
-# ifdef OSF_ALPHA
-# define NLIST_STRUCT
-# endif
-
-# if defined (ardent) && defined (titan)
-# define NLIST_STRUCT
-# endif
-
-# ifdef tek4300
-# define NLIST_STRUCT
-# endif
-
-# ifdef butterfly
-# define NLIST_STRUCT
-# endif
-
-# if defined(alliant) && defined(i860) /* Alliant FX/2800 */
-# define NLIST_STRUCT
-# endif
-
-# ifdef _AIX
-# define NLIST_STRUCT
-# endif
-
-# endif /* defined (NLIST_STRUCT) */
-
# if defined(sgi) || (defined(mips) && !defined(BSD))
# define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
# endif /* LOAD_AVE_TYPE */
-# ifdef __GNU__
-/* GNU hurd systems act sort of like NeXT ones, for load average purposes. */
+# if defined(__GNU__) && !defined (NeXT)
+/* Note that NeXT Openstep defines __GNU__ even though it should not. */
+/* GNU system acts much like NeXT, for load average purposes,
+ but not exactly. */
# define NeXT
# define host_self mach_host_self
# endif
# include <sys/file.h>
# endif
\f
+
/* Avoid static vars inside a function since in HPUX they dump as pure. */
# ifdef NeXT
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
# endif /* DGUX */
-# ifdef LOAD_AVE_TYPE
+#if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE)
/* File descriptor open to /dev/kmem or VMS load ave driver. */
static int channel;
/* Nonzero iff channel is valid. */
/* Offset in kmem to seek to read load average, or 0 means invalid. */
static long offset;
-# if !defined(VMS) && !defined(sgi) && !defined(__linux__)
+#if !defined(VMS) && !defined(sgi) && !defined(__linux__)
static struct nlist nl[2];
-# endif /* Not VMS or sgi */
+#endif /* Not VMS or sgi */
-# ifdef SUNOS_5
+#ifdef SUNOS_5
static kvm_t *kd;
-# endif /* SUNOS_5 */
+#endif /* SUNOS_5 */
-# endif /* LOAD_AVE_TYPE */
+#endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */
\f
/* Put the 1 minute, 5 minute and 15 minute load averages
into the first NELEM elements of LOADAVG.
elem = -1;
# endif
-# if !defined (LDAV_DONE) && defined (SUNOS_5)
+# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT)
/* Use libkstat because we don't have to be root. */
# define LDAV_DONE
kstat_ctl_t *kc;
}
kstat_close (kc);
-# endif /* SUNOS_5 */
+# endif /* HAVE_LIBKSTAT */
# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
/* Use pstat_getdynamic() because we don't have to be root. */
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
# endif /* OSF_MIPS */
-# if !defined (LDAV_DONE) && (defined (MSDOS) || defined (WIN32))
+# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
# define LDAV_DONE
/* A faithful emulation is going to have to be saved for a rainy day. */
{
loadavg[elem] = 0.0;
}
-# endif /* MSDOS */
+# endif /* __MSDOS__ || WINDOWS32 */
# if !defined (LDAV_DONE) && defined (OSF_ALPHA)
# define LDAV_DONE
{
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
-# ifdef FD_SETFD
+# ifdef F_SETFD
# ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
# endif
#endif /* ! HAVE_GETLOADAVG */
\f
#ifdef TEST
-void
+int
main (argc, argv)
int argc;
char **argv;