--- getloadavg.c	2002-05-09 20:15:08.000000000 -0700
+++ ../coreutils-4.5.11/lib/getloadavg.c	2003-03-24 10:38:47.000000000 -0800
@@ -35,12 +35,11 @@
    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,
 				not an array.
-   HAVE_STRUCT_NLIST_N_UN_N_NAME struct nlist has an n_un member, not n_name.
+   NLIST_NAME_UNION		struct nlist has an n_un member, not n_name.
    LINUX_LDAV_FILE		[__linux__]: File containing load averages.
 
    Specific system predefines this file uses, aside from setting
@@ -82,7 +81,7 @@
 /* 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.  */
-#if defined (unix) || defined (__unix)
+#ifdef unix
 # include <sys/param.h>
 #endif
 
@@ -108,7 +107,6 @@
 
 #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
    returns the load average multiplied by 100.  What we actually want
@@ -139,12 +137,6 @@
 #  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.  */
 
@@ -199,10 +191,6 @@
 #  define tek4300			/* Define by emacs, but not by other users.  */
 # endif
 
-/* AC_FUNC_GETLOADAVG thinks QNX is SVR4, but it isn't. */
-# if defined(__QNX__)
-#  undef SVR4
-# endif
 
 /* VAX C can't handle multi-line #ifs, or lines longer than 256 chars.  */
 # ifndef LOAD_AVE_TYPE
@@ -266,6 +254,10 @@
 #   endif
 #  endif
 
+#  ifdef _SCO_DS
+#   define LOAD_AVE_TYPE unsigned short
+#  endif
+
 # endif /* No LOAD_AVE_TYPE.  */
 
 # ifdef OSF_ALPHA
@@ -299,7 +291,7 @@
 /* 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
+#   define FSCALE 1000.0
 #  endif
 
 #  if defined (ardent) && defined (titan)
@@ -314,12 +306,83 @@
 #   define FSCALE 65536.0
 #  endif
 
+#  ifdef _SCO_DS
+#   define FSCALE 256.0
+#  endif
+
 # endif	/* Not FSCALE.  */
 
 # if !defined (LDAV_CVT) && defined (FSCALE)
-#  define	LDAV_CVT(n) (((double) (n)) / FSCALE)
+#  define LDAV_CVT(n) (((double) (n)) / FSCALE)
+# endif
+
+# ifndef NLIST_STRUCT
+#  if HAVE_NLIST_H
+#   define NLIST_STRUCT
+#  endif
 # 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))
@@ -334,7 +397,7 @@
 #  define KERNEL_FILE "/hp-ux"
 # endif
 
-# if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
+# if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan))) || defined(_SCO_DS)
 #  define KERNEL_FILE "/unix"
 # endif
 
@@ -343,7 +406,7 @@
 #  define LDAV_SYMBOL "_Loadavg"
 # endif
 
-# if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
+# if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX)) || defined(_SCO_DS)
 #  define LDAV_SYMBOL "avenrun"
 # endif
 
@@ -363,11 +426,11 @@
 
 #  ifndef VMS
 #   ifndef __linux__
-#    ifdef HAVE_NLIST_H
-#     include <nlist.h>
-#    else
+#    ifndef NLIST_STRUCT
 #     include <a.out.h>
-#    endif
+#    else /* NLIST_STRUCT */
+#     include <nlist.h>
+#    endif /* NLIST_STRUCT */
 
 #    ifdef SUNOS_5
 #     include <fcntl.h>
@@ -457,7 +520,6 @@
 #  include <sys/file.h>
 # endif
 
-
 /* Avoid static vars inside a function since in HPUX they dump as pure.  */
 
 # ifdef NeXT
@@ -474,7 +536,7 @@
 static struct dg_sys_info_load_info load_info;	/* what-a-mouthful! */
 # endif /* DGUX */
 
-#if !defined(HAVE_LIBKSTAT) && defined(LOAD_AVE_TYPE)
+# ifdef LOAD_AVE_TYPE
 /* File descriptor open to /dev/kmem or VMS load ave driver.  */
 static int channel;
 /* Nonzero iff channel is valid.  */
@@ -482,15 +544,15 @@
 /* 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 && !HAVE_LIBKSTAT */
+# endif /* LOAD_AVE_TYPE */
 
 /* Put the 1 minute, 5 minute and 15 minute load averages
    into the first NELEM elements of LOADAVG.
@@ -876,13 +938,13 @@
       strcpy (nl[0].n_name, LDAV_SYMBOL);
       strcpy (nl[1].n_name, "");
 #   else /* NLIST_STRUCT */
-#    ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
+#    ifdef NLIST_NAME_UNION
       nl[0].n_un.n_name = LDAV_SYMBOL;
       nl[1].n_un.n_name = 0;
-#    else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
+#    else /* not NLIST_NAME_UNION */
       nl[0].n_name = LDAV_SYMBOL;
       nl[1].n_name = 0;
-#    endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
+#    endif /* not NLIST_NAME_UNION */
 #   endif /* NLIST_STRUCT */
 
 #   ifndef SUNOS_5
@@ -919,7 +981,7 @@
 	{
 	  /* Set the channel to close on exec, so it does not
 	     litter any child's descriptor table.  */
-#   ifdef F_SETFD
+#   ifdef FD_SETFD
 #    ifndef FD_CLOEXEC
 #     define FD_CLOEXEC 1
 #    endif
@@ -991,9 +1053,7 @@
 #endif /* ! HAVE_GETLOADAVG */
 
 #ifdef TEST
-#include "make.h"
-
-int
+void
 main (argc, argv)
      int argc;
      char **argv;
