+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
+
+if test "x$nan_type" = "xnone"; then
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -lm"
+ AC_CACHE_CHECK([whether NAN can be defined by 0/0],
+ [c_cv_have_nan_zero],
+ [
+ AC_RUN_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <stdlib.h>
+ #include <math.h>
+ #ifdef NAN
+ # undef NAN
+ #endif
+ #define NAN (0.0 / 0.0)
+ #ifndef isnan
+ # define isnan(f) ((f) != (f))
+ #endif
+ static double foo = NAN;
+ ]],
+ [[
+ if (isnan (foo))
+ return 0;
+ return 1;
+ ]]
+ )
+ ],
+ [c_cv_have_nan_zero="yes"],
+ [c_cv_have_nan_zero="no"]
+ )
+ ]
+ )
+ LDFLAGS=$SAVE_LDFLAGS
+fi
+
+if test "x$c_cv_have_nan_zero" = "xyes"; then
+ nan_type="zero"
+fi
+
+if test "x$nan_type" = "xdefault"; then
+ AC_DEFINE([NAN_STATIC_DEFAULT], [1],
+ [Define if NAN is defined by default and can initialize static variables.]
+ )
+else if test "x$nan_type" = "xisoc99"; then
+ AC_DEFINE([NAN_STATIC_ISOC], [1],
+ [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.]
+ )
+else if test "x$nan_type" = "xzero"; then
+ AC_DEFINE([NAN_ZERO_ZERO], [1],
+ [Define if NAN can be defined as (0.0 / 0.0)]
+ )