Also handle the case that isnan is a "type-generic" macro.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Feb 2007 04:46:17 +0000 (04:46 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Feb 2007 04:46:17 +0000 (04:46 +0000)
ChangeLog
lib/isnan.h
lib/isnanl.h
m4/isnan.m4
m4/isnanl.m4

index 14fedc7..3d953da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2007-02-24  Bruno Haible  <bruno@clisp.org>
 
+       * lib/isnanl.h (isnanl): Define through isnan if isnan is a macro.
+       * m4/isnan.m4 (gl_FUNC_ISNAN_NO_LIBM): Don't check for isnan as a
+       function; instead check whether isnan with a double argument links.
+       * m4/isnanl.m4 (gl_FUNC_ISNANL_NO_LIBM): Don't check for isnanl as a
+       function; instead check whether isnan with a 'long double' argument
+       links.
+       Reported by Eric Blake <ebb9@byu.net>.
+
+2007-02-24  Bruno Haible  <bruno@clisp.org>
+
        * lib/isnan.c: Support the 'long double' case if USE_LONG_DOUBLE is
        defined.
        * lib/isnanl.c: Remove all code. Just include isnan.c.
index 8d53437..c4181bb 100644 (file)
@@ -16,7 +16,7 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #if HAVE_ISNAN_IN_LIBC
-/* Get declaration of isnan.  */
+/* Get declaration of isnan macro.  */
 # include <math.h>
 #else
 /* Test whether X is a NaN.  */
index 95f4541..1eac3c6 100644 (file)
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #if HAVE_ISNANL_IN_LIBC
-/* Get declaration of isnanl.  */
+/* Get declaration of isnan macro or (older) isnanl function.  */
 # include <math.h>
+# ifdef isnan
+#  undef isnanl
+#  define isnanl(x) isnan ((long double)(x))
+# endif
 #else
 /* Test whether X is a NaN.  */
 # undef isnanl
index 5bb133d..d4729cd 100644 (file)
@@ -8,12 +8,18 @@ dnl Check how to get or define isnan() without linking with libm.
 
 AC_DEFUN([gl_FUNC_ISNAN_NO_LIBM],
 [
-  AC_CHECK_FUNC([isnan],
-    [gl_cv_func_isnan_no_libm=yes],
-    [gl_cv_func_isnan_no_libm=no])
+  AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm],
+    [gl_cv_func_isnan_no_libm],
+    [
+      AC_TRY_LINK([#include <math.h>
+                   double x;],
+                  [return isnan (x);],
+        [gl_cv_func_isnan_no_libm=yes],
+        [gl_cv_func_isnan_no_libm=no])
+    ])
   if test $gl_cv_func_isnan_no_libm = yes; then
     AC_DEFINE([HAVE_ISNAN_IN_LIBC], 1,
-      [Define if the isnan() function is available in libc.])
+      [Define if the isnan(double) function is available in libc.])
   else
     AC_LIBOBJ([isnan])
     gl_DOUBLE_EXPONENT_LOCATION
index 5439579..6c6b0d0 100644 (file)
@@ -8,12 +8,22 @@ AC_DEFUN([gl_FUNC_ISNANL_NO_LIBM],
 [
   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
   if test $gt_cv_c_long_double = yes; then
-    AC_CHECK_FUNC([isnanl],
-      [gl_cv_func_isnanl_no_libm=yes],
-      [gl_cv_func_isnanl_no_libm=no])
+    AC_CACHE_CHECK([whether isnan(long double) can be used without linking with libm],
+      [gl_cv_func_isnanl_no_libm],
+      [
+        AC_TRY_LINK([#include <math.h>
+                     #ifdef isnan
+                     # undef isnanl
+                     # define isnanl(x) isnan ((long double)(x))
+                     #endif
+                     long double x;],
+                    [return isnanl (x);],
+          [gl_cv_func_isnanl_no_libm=yes],
+          [gl_cv_func_isnanl_no_libm=no])
+      ])
     if test $gl_cv_func_isnanl_no_libm = yes; then
       AC_DEFINE([HAVE_ISNANL_IN_LIBC], 1,
-        [Define if the isnanl() function is available in libc.])
+        [Define if the isnan(long double) function is available in libc.])
     else
       AC_LIBOBJ([isnanl])
       gl_LONG_DOUBLE_EXPONENT_LOCATION