summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f4c0fb)
raw | patch | inline | side by side (parent: 6f4c0fb)
author | Vincent Bernat <vincent@bernat.im> | |
Mon, 17 Nov 2014 09:35:16 +0000 (10:35 +0100) | ||
committer | Vincent Bernat <vincent@bernat.im> | |
Mon, 17 Nov 2014 09:35:16 +0000 (10:35 +0100) |
Previously, each API change was tested in configure.ac. Some of the
tests are relying on signature checks and would need to have -Werror
flag enabled to make them work. This is quite fragile.
Instead, we assume that if `sg_init()` requires an argument, we must use
the 0.90 API.
Fixes: #795
tests are relying on signature checks and would need to have -Werror
flag enabled to make them work. This is quite fragile.
Instead, we assume that if `sg_init()` requires an argument, we must use
the 0.90 API.
Fixes: #795
configure.ac | patch | blob | history | |
src/daemon/collectd.c | patch | blob | history | |
src/disk.c | patch | blob | history | |
src/users.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 6ac2554c8643e908133e03a6eb78f8582ffe0360..d9a6b67e6378b5ad799a7ee694caeb3dcca00e6f 100644 (file)
--- a/configure.ac
+++ b/configure.ac
CFLAGS="$CFLAGS $with_libstatgrab_cflags"
LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
- AC_CACHE_CHECK([if sg_init() requires an argument],
- [c_cv_have_libstatgrab_init_arg],
+ AC_CACHE_CHECK([if libstatgrab >= 0.90],
+ [c_cv_have_libstatgrab_0_90],
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdio.h>
if (sg_init()) return 0;
]]]
)],
- [c_cv_have_libstatgrab_init_arg="no"],
- [c_cv_have_libstatgrab_init_arg="yes"]
- )
- )
-
- 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"]
- )
- )
-
- AC_CACHE_CHECK([if sg_disk_io_stats() uses size_t],
- [c_cv_have_libstatgrab_get_disk_io_stats_sizet],
- AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdio.h>
-#include <statgrab.h>
-]]],
-[[[
- sg_disk_io_stats *(*ptr) (size_t *);
- ptr = sg_get_disk_io_stats;
- if (ptr != NULL) return 0;
-]]]
- )],
- [c_cv_have_libstatgrab_get_disk_io_stats_sizet="yes"],
- [c_cv_have_libstatgrab_get_disk_io_stats_sizet="no"]
+ [c_cv_have_libstatgrab_0_90="no"],
+ [c_cv_have_libstatgrab_0_90="yes"]
)
)
BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
- if test "x$c_cv_have_libstatgrab_init_arg" = "xyes"
- 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
- if test "x$c_cv_have_libstatgrab_get_disk_io_stats_sizet" = "xyes"
+ if test "x$c_cv_have_libstatgrab_0_90" = "xyes"
then
- AC_DEFINE(HAVE_LIBSTATGRAB_GET_DISK_IO_STATS_SIZET, 1, [Define to 1 if sg_get_disk_io_stats does require pointer to size_t as an argument])
+ AC_DEFINE(HAVE_LIBSTATGRAB_0_90, 1, [Define to 1 if libstatgrab version >= 0.90])
fi
fi
# }}}
diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c
index 9cba9132814cbcafa97ddf92f6289c5bd9c0991d..309af1badfadacb642a59b34317fed261576bc68 100644 (file)
--- a/src/daemon/collectd.c
+++ b/src/daemon/collectd.c
#if HAVE_LIBSTATGRAB
if (sg_init (
-# if HAVE_LIBSTATGRAB_INIT_ARG
+# if HAVE_LIBSTATGRAB_0_90
0
# endif
))
diff --git a/src/disk.c b/src/disk.c
index 51fbc025dde38c0f5eac02075f2aae010d0b3271..0d4c2bf07b2f6c9e5735aef8acf4a7ec54f37fe6 100644 (file)
--- a/src/disk.c
+++ b/src/disk.c
#elif defined(HAVE_LIBSTATGRAB)
sg_disk_io_stats *ds;
-# if HAVE_LIBSTATGRAB_GET_DISK_IO_STATS_SIZET
+# if HAVE_LIBSTATGRAB_0_90
size_t disks;
# else
int disks;
diff --git a/src/users.c b/src/users.c
index 40ffece1fef537342338bc26ccf467cdeba7dac0..10f34ee9483023959cc129c6e53a7e29e18e18c5 100644 (file)
--- a/src/users.c
+++ b/src/users.c
#elif HAVE_LIBSTATGRAB
sg_user_stats *us;
-# if HAVE_LIBSTATGRAB_GET_USER_STATS_ARG
+# if HAVE_LIBSTATGRAB_0_90
size_t num_entries;
us = sg_get_user_stats (&num_entries);
# else
return (-1);
users_submit ((gauge_t)
-# if HAVE_LIBSTATGRAB_GET_USER_STATS_ARG
+# if HAVE_LIBSTATGRAB_0_90
num_entries);
# else
us->num_entries);