]> code.delx.au - gnu-emacs/blobdiff - src/getloadavg.c
merge from upstream. currently seems to have bitroted and i get segfaults
[gnu-emacs] / src / getloadavg.c
index a2ae9bc310b1ec9d921f13f54566f6cbed1d3917..d9c24717b79d73309ba9036c588ea9572409f536 100644 (file)
@@ -1,6 +1,7 @@
 /* Get the system load averages.
    Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995,
-                 1997, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+                 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 Free Software Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with gnulib.
    Bugs can be reported to bug-gnulib@gnu.org.
@@ -354,10 +355,7 @@ extern int errno;
 #  define LDAV_SYMBOL "avenrun"
 # endif
 
-# ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-# endif
-
+# include <unistd.h>
 # include <stdio.h>
 
 /* LOAD_AVE_TYPE should only get defined if we're going to use the
@@ -483,13 +481,13 @@ static struct dg_sys_info_load_info load_info;    /* what-a-mouthful! */
 #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.  */
+/* Nonzero if channel is valid.  */
 static int getloadavg_initialized;
 /* Offset in kmem to seek to read load average, or 0 means invalid.  */
 static long offset;
 
 #  if !defined(VMS) && !defined(sgi) && !defined(__linux__)
-static struct nlist nl[2];
+static struct nlist name_list[2];
 #  endif /* Not VMS or sgi */
 
 #  ifdef SUNOS_5
@@ -712,7 +710,7 @@ getloadavg (loadavg, nelem)
       for (i = 0; i < conf.config_maxclass; ++i)
        {
          struct class_stats stats;
-         bzero ((char *) &stats, sizeof stats);
+         memset (&stats, 0, sizeof stats);
 
          desc.sd_type = CPUTYPE_CLASS;
          desc.sd_objid = i;
@@ -879,32 +877,32 @@ getloadavg (loadavg, nelem)
     {
 #  ifndef sgi
 #   ifndef NLIST_STRUCT
-      strcpy (nl[0].n_name, LDAV_SYMBOL);
-      strcpy (nl[1].n_name, "");
+      strcpy (name_list[0].n_name, LDAV_SYMBOL);
+      strcpy (name_list[1].n_name, "");
 #   else /* NLIST_STRUCT */
 #    ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
-      nl[0].n_un.n_name = LDAV_SYMBOL;
-      nl[1].n_un.n_name = 0;
+      name_list[0].n_un.n_name = LDAV_SYMBOL;
+      name_list[1].n_un.n_name = 0;
 #    else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
-      nl[0].n_name = LDAV_SYMBOL;
-      nl[1].n_name = 0;
+      name_list[0].n_name = LDAV_SYMBOL;
+      name_list[1].n_name = 0;
 #    endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
 #   endif /* NLIST_STRUCT */
 
 #   ifndef SUNOS_5
       if (
 #    if !(defined (_AIX) && !defined (ps2))
-         nlist (KERNEL_FILE, nl)
+         nlist (KERNEL_FILE, name_list)
 #    else  /* _AIX */
-         knlist (nl, 1, sizeof (nl[0]))
+         knlist (name_list, 1, sizeof (name_list[0]))
 #    endif
          >= 0)
-         /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i.  */
+         /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i.  */
          {
 #    ifdef FIXUP_KERNEL_SYMBOL_ADDR
-           FIXUP_KERNEL_SYMBOL_ADDR (nl);
+           FIXUP_KERNEL_SYMBOL_ADDR (name_list);
 #    endif
-           offset = nl[0].n_value;
+           offset = name_list[0].n_value;
          }
 #   endif /* !SUNOS_5 */
 #  else  /* sgi */
@@ -940,8 +938,8 @@ getloadavg (loadavg, nelem)
       if (kd != 0)
        {
          /* nlist the currently running kernel.  */
-         kvm_nlist (kd, nl);
-         offset = nl[0].n_value;
+         kvm_nlist (kd, name_list);
+         offset = name_list[0].n_value;
          getloadavg_initialized = 1;
        }
 #  endif /* SUNOS_5 */
@@ -1037,5 +1035,3 @@ main (argc, argv)
 }
 #endif /* TEST */
 
-/* arch-tag: 2b37a242-6289-41f4-8cd5-0e73fd615db1
-   (do not change this comment) */