From 34eb0428ed2d9f8e9433cc71e43da6761d174e1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aur=C3=A9lien=20Reynaud?= Date: Tue, 4 May 2010 15:05:12 +0200 Subject: [PATCH] Check for different versions of swapctl() in configure.in The swapctl() function comes in two flavors. Depending on the OS, it can take two or three arguments with the following prototypes: swapctl (int cmd, void *arg, int misc); (BSD version) or swapctl (int cmd, void *arg); (HP-UX or Solaris version) This patch adds support for detecting the right version of swapctl() at configure time. In addition to HAVE_SWAPCTL, HAVE_SWAPCTL_TWO_ARGS and/or HAVE_SWAPCTL_THREE_ARGS are defined to reflect the result of the check. Signed-off-by: Florian Forster --- configure.in | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/configure.in b/configure.in index 88ff302d..dbb4c32a 100644 --- a/configure.in +++ b/configure.in @@ -588,6 +588,55 @@ AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"]) AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"]) AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"]) AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"]) +if test "x$have_swapctl" = "xyes"; then + AC_CACHE_CHECK([whether swapctl takes two arguments], + [c_cv_have_swapctl_two_args], + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# undef _LARGEFILE64_SOURCE +#endif +#include +#include ]], + [[ + int num = swapctl(0, NULL); + ]] + ), + [c_cv_have_swapctl_two_args="yes"], + [c_cv_have_swapctl_two_args="no"] + ) + ) + AC_CACHE_CHECK([whether swapctl takes three arguments], + [c_cv_have_swapctl_three_args], + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# undef _LARGEFILE64_SOURCE +#endif +#include +#include ]], + [[ + int num = swapctl(0, NULL,0); + ]] + ), + [c_cv_have_swapctl_three_args="yes"], + [c_cv_have_swapctl_three_args="no"] + ) + ) +fi +# Check for different versions of `swapctl' here.. +if test "x$have_swapctl" = "xyes"; then + if test "x$c_cv_have_swapctl_two_args" = "xyes"; then + AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1, + [Define if the function swapctl exists and takes two arguments.]) + fi + if test "x$c_cv_have_swapctl_three_args" = "xyes"; then + AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1, + [Define if the function swapctl exists and takes three arguments.]) + fi +fi # For load module AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"]) -- 2.11.0