summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2bd9ed6)
raw | patch | inline | side by side (parent: 2bd9ed6)
author | Vincent Bernat <vincent@bernat.im> | |
Wed, 12 Nov 2014 12:19:05 +0000 (13:19 +0100) | ||
committer | Vincent Bernat <Vincent.Bernat@exoscale.ch> | |
Wed, 12 Nov 2014 12:20:11 +0000 (13:20 +0100) |
In those versions, `sg_get_user_stats()` need to be invoked with an
additional argument. The need for such an argument is detected at
configure-time.
Fixes: #445
additional argument. The need for such an argument is detected at
configure-time.
Fixes: #445
configure.ac | patch | blob | history | |
src/users.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 35f8946450bd69aebe5164efa451cf5f32a6e8d2..f1873dee2427bea78ff037b62d20fee61ad5f829 100644 (file)
--- a/configure.ac
+++ b/configure.ac
)
)
+ AC_CACHE_CHECK([if sg_get_user_stats() requires an argument],
+ [c_cv_have_libstatgrab_get_user_stats_arg],
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdio.h>
+#include <statgrab.h>
+]]],
+[[[
+ if (sg_get_user_stats()) return 0;
+]]]
+ )],
+ [c_cv_have_libstatgrab_get_user_stats_arg="no"],
+ [c_cv_have_libstatgrab_get_user_stats_arg="yes"]
+ )
+ )
+
CFLAGS="$SAVE_CFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
fi
then
AC_DEFINE(HAVE_LIBSTATGRAB_INIT_ARG, 1, [Define to 1 if sg_init does require an argument])
fi
+ if test "x$c_cv_have_libstatgrab_get_user_stats_arg" = "xyes"
+ then
+ AC_DEFINE(HAVE_LIBSTATGRAB_GET_USER_STATS_ARG, 1, [Define to 1 if sg_get_user_stats does require an argument])
+ fi
fi
# }}}
diff --git a/src/users.c b/src/users.c
index 781e778734687b70ecbcbd24ffd73e1c6ff8545e..40ffece1fef537342338bc26ccf467cdeba7dac0 100644 (file)
--- a/src/users.c
+++ b/src/users.c
#elif HAVE_LIBSTATGRAB
sg_user_stats *us;
+# if HAVE_LIBSTATGRAB_GET_USER_STATS_ARG
+ size_t num_entries;
+ us = sg_get_user_stats (&num_entries);
+# else
us = sg_get_user_stats ();
+# endif
if (us == NULL)
return (-1);
- users_submit ((gauge_t) us->num_entries);
+ users_submit ((gauge_t)
+# if HAVE_LIBSTATGRAB_GET_USER_STATS_ARG
+ num_entries);
+# else
+ us->num_entries);
+# endif
/* #endif HAVE_LIBSTATGRAB */
#else