Add isnan module.
[gnulib.git] / m4 / isnan.m4
diff --git a/m4/isnan.m4 b/m4/isnan.m4
new file mode 100644 (file)
index 0000000..f146601
--- /dev/null
@@ -0,0 +1,32 @@
+# isnan.m4 serial 1
+dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_ISNAN],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_ISNANF])
+  AC_REQUIRE([gl_FUNC_ISNAND])
+  AC_REQUIRE([gl_FUNC_ISNANL])
+
+  ISNAN_LIBM="$ISNANF_LIBM $ISNAND_LIBM $ISNANL_LIBM"
+  AC_SUBST([ISNAN_LIBM])
+
+  # If we replaced any of the underlying isnan* functions, replace
+  # the isnan macro; it undoubtedly suffers from the same flaws.
+  AC_MSG_CHECKING([whether isnan macro works])
+  if test $gl_func_isnanf = yes \
+     && test $gl_func_isnand = yes \
+     && test $gl_func_isnanl = yes; then
+    AC_MSG_RESULT([yes])
+  else
+    # Make sure the rpl_isnan[fdl] functions get built.
+    gl_BUILD_ISNANF
+    gl_BUILD_ISNAND
+    gl_BUILD_ISNANL
+    REPLACE_ISNAN=1
+    AC_MSG_RESULT([no])
+  fi
+])