+
+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(
+ [[
+ #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+ # undef _FILE_OFFSET_BITS
+ # undef _LARGEFILE64_SOURCE
+ #endif
+ #include <sys/stat.h>
+ #include <sys/param.h>
+ #include <sys/swap.h>
+ #include <unistd.h>
+ ]],
+ [[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(
+ [[
+ #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+ # undef _FILE_OFFSET_BITS
+ # undef _LARGEFILE64_SOURCE
+ #endif
+ #include <sys/stat.h>
+ #include <sys/param.h>
+ #include <sys/swap.h>
+ #include <unistd.h>
+ ]],
+ [[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
+
+# Check for NAN
+AC_ARG_WITH([nan-emulation],
+ [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
+ [
+ if test "x$withval" = "xno"; then
+ nan_type="none"
+ else if test "x$withval" = "xyes"; then
+ nan_type="zero"
+ else
+ nan_type="$withval"
+ fi; fi
+ ],
+ [nan_type="none"]
+)
+
+if test "x$nan_type" = "xnone"; then
+ AC_CACHE_CHECK([whether NAN is defined by default],
+ [c_cv_have_nan_default],
+ [
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <stdlib.h>
+ #include <math.h>
+ static double foo = NAN;
+ ]],
+ [[
+ if (isnan (foo))
+ return 0;
+ return 1;
+ ]]
+ )
+ ],
+ [c_cv_have_nan_default="yes"],
+ [c_cv_have_nan_default="no"]
+ )
+ ]
+ )
+fi
+
+if test "x$c_cv_have_nan_default" = "xyes"; then
+ nan_type="default"
+fi
+
+if test "x$nan_type" = "xnone"; then
+ AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
+ [c_cv_have_nan_isoc],
+ [
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <stdlib.h>
+ #define __USE_ISOC99 1
+ #include <math.h>
+ static double foo = NAN;
+ ]],
+ [[
+ if (isnan (foo))
+ return 0;
+ return 1;
+ ]]
+ )
+ ],
+ [c_cv_have_nan_isoc="yes"],
+ [c_cv_have_nan_isoc="no"]
+ )
+ ]
+ )
+fi
+
+if test "x$c_cv_have_nan_isoc" = "xyes"; then
+ nan_type="isoc99"
+fi
+