summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-24 13:05:45 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-02-24 17:44:53 -0800
commitd436ab2166c03a54e58f6f4b48e876ba1c147d13 (patch)
treed75550aef7a7dd1b63c8d1fa79238de51a4e1a84
parentb0613198f87af22be989fa54e785c64e147debb6 (diff)
Make getloadavg() the first choice on Unix systems that have it
Only fall back to complex, platform specific code if the simpler, more portable option isn't found by configure. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--get_load.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/get_load.c b/get_load.c
index 06890f5..489ec26 100644
--- a/get_load.c
+++ b/get_load.c
@@ -101,8 +101,32 @@ void GetLoadPoint(
if (ret!=0) return;
*loadavg = (fmtvalue.u.vDouble-0.01)/100.0;
}
-#else
+#else /* not CYGWIN */
+
+static void xload_error(const char *, const char *) _X_NORETURN;
+#ifdef HAVE_GETLOADAVG
+#include <stdlib.h>
+#ifdef HAVE_SYS_LOADAVG_H
+#include <sys/loadavg.h> /* Solaris definition of getloadavg */
+#endif
+
+void InitLoadPoint(void)
+{
+}
+
+void GetLoadPoint(
+ Widget w, /* unused */
+ XtPointer closure, /* unused */
+ XtPointer call_data) /* ptr to (double) return value */
+{
+ double *loadavg = (double *)call_data;
+
+ if (getloadavg(loadavg, 1) < 0)
+ xload_error("couldn't obtain load average", "");
+}
+
+#else /* not HAVE_GETLOADAVG */
#if defined(att) || defined(QNX4)
#define LOADSTUB
@@ -140,9 +164,6 @@ void GetLoadPoint(
#endif
#endif
-static void xload_error(const char *, const char *) _X_NORETURN;
-
-
#if defined(SYSV) && defined(i386)
/*
* inspired by 'avgload' by John F. Haugh II
@@ -490,29 +511,6 @@ void GetLoadPoint(
}
#else /* not __bsdi__ */
-#if defined(HAVE_GETLOADAVG)
-#include <stdlib.h>
-#ifdef HAVE_SYS_LOADAVG_H
-#include <sys/loadavg.h> /* Solaris definition of getloadavg */
-#endif
-
-void InitLoadPoint()
-{
-}
-
-void GetLoadPoint(w, closure, call_data)
- Widget w; /* unused */
- XtPointer closure; /* unused */
- XtPointer call_data; /* ptr to (double) return value */
-{
- double *loadavg = (double *)call_data;
-
- if (getloadavg(loadavg, 1) < 0)
- xload_error("couldn't obtain load average", "");
-}
-
-#else /* not HAVE_GETLOADAVG */
-
#ifndef KMEM_FILE
#define KMEM_FILE "/dev/kmem"
#endif
@@ -647,7 +645,6 @@ void GetLoadPoint( w, closure, call_data )
#endif /* SVR4 or ... else */
return;
}
-#endif /* HAVE_GETLOADAVG else */
#endif /* __bsdi__ else */
#endif /* __QNXNTO__ else */
#endif /* __osf__ else */
@@ -656,6 +653,7 @@ void GetLoadPoint( w, closure, call_data )
#endif /* __GNU__ else */
#endif /* linux else */
#endif /* SYSV && i386 else */
+#endif /* HAVE_GETLOADAVG else */
static void xload_error(const char *str1, const char *str2)
{