-#if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL))
-#define LOAD_AVE_TYPE double
-#endif
-
-#ifdef LOAD_AVE_TYPE
-
-#ifndef VMS
-#ifndef NLIST_STRUCT
-#include <a.out.h>
-#else /* NLIST_STRUCT */
-#include <nlist.h>
-#endif /* NLIST_STRUCT */
-
-#ifdef SUNOS_5
-#include <fcntl.h>
-#include <kvm.h>
-#endif
-
-#ifndef KERNEL_FILE
-#define KERNEL_FILE "/vmunix"
-#endif /* KERNEL_FILE */
-
-#ifndef LDAV_SYMBOL
-#define LDAV_SYMBOL "_avenrun"
-#endif /* LDAV_SYMBOL */
-
-#else /* VMS */
-
-#ifndef eunice
-#include <iodef.h>
-#include <descrip.h>
-#else /* eunice */
-#include <vms/iodef.h>
-#endif /* eunice */
-#endif /* VMS */
-
-#ifndef LDAV_CVT
-#define LDAV_CVT(n) ((double) (n))
-#endif /* !LDAV_CVT */
-
-#endif /* LOAD_AVE_TYPE */
-
-#ifdef NeXT
-#ifdef HAVE_MACH_MACH_H
-#include <mach/mach.h>
-#else
-#include <mach.h>
-#endif
-#endif /* NeXT */
-
-#ifdef sgi
-#include <sys/sysmp.h>
-#endif /* sgi */
-
-#ifdef UMAX
-#include <stdio.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/syscall.h>
-
-#ifdef UMAX_43
-#include <machine/cpu.h>
-#include <inq_stats/statistics.h>
-#include <inq_stats/sysstats.h>
-#include <inq_stats/cpustats.h>
-#include <inq_stats/procstats.h>
-#else /* Not UMAX_43. */
-#include <sys/sysdefs.h>
-#include <sys/statistics.h>
-#include <sys/sysstats.h>
-#include <sys/cpudefs.h>
-#include <sys/cpustats.h>
-#include <sys/procstats.h>
-#endif /* Not UMAX_43. */
-#endif /* UMAX */
-
-#ifdef DGUX
-#include <sys/dg_sys_info.h>
-#endif
-
-#if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
-#include <fcntl.h>
-#else
-#include <sys/file.h>
-#endif
+# if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
+# define LOAD_AVE_TYPE double
+# endif
+
+# ifdef LOAD_AVE_TYPE
+
+# ifndef __VMS
+# ifndef __linux__
+# ifndef NLIST_STRUCT
+# include <a.out.h>
+# else /* NLIST_STRUCT */
+# include <nlist.h>
+# endif /* NLIST_STRUCT */
+
+# ifdef SUNOS_5
+# include <fcntl.h>
+# include <kvm.h>
+# include <kstat.h>
+# endif
+
+# if defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
+# include <sys/pstat.h>
+# endif
+
+# ifndef KERNEL_FILE
+# define KERNEL_FILE "/vmunix"
+# endif /* KERNEL_FILE */
+
+# ifndef LDAV_SYMBOL
+# define LDAV_SYMBOL "_avenrun"
+# endif /* LDAV_SYMBOL */
+# endif /* __linux__ */
+
+# else /* __VMS */
+
+# ifndef eunice
+# include <iodef.h>
+# include <descrip.h>
+# else /* eunice */
+# include <vms/iodef.h>
+# endif /* eunice */
+# endif /* __VMS */
+
+# ifndef LDAV_CVT
+# define LDAV_CVT(n) ((double) (n))
+# endif /* !LDAV_CVT */
+
+# endif /* LOAD_AVE_TYPE */
+
+# 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
+
+# ifdef NeXT
+# ifdef HAVE_MACH_MACH_H
+# include <mach/mach.h>
+# else
+# include <mach.h>
+# endif
+# endif /* NeXT */
+
+# ifdef sgi
+# include <sys/sysmp.h>
+# endif /* sgi */
+
+# ifdef UMAX
+# include <signal.h>
+# include <sys/time.h>
+# include <sys/wait.h>
+# include <sys/syscall.h>
+
+# ifdef UMAX_43
+# include <machine/cpu.h>
+# include <inq_stats/statistics.h>
+# include <inq_stats/sysstats.h>
+# include <inq_stats/cpustats.h>
+# include <inq_stats/procstats.h>
+# else /* Not UMAX_43. */
+# include <sys/sysdefs.h>
+# include <sys/statistics.h>
+# include <sys/sysstats.h>
+# include <sys/cpudefs.h>
+# include <sys/cpustats.h>
+# include <sys/procstats.h>
+# endif /* Not UMAX_43. */
+# endif /* UMAX */
+
+# ifdef DGUX
+# include <sys/dg_sys_info.h>
+# endif
+
+# include "fcntl--.h"