From 89aab6dde9b5afaf958c645afa8a135466f8d4f7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 25 Feb 2007 04:46:17 +0000 Subject: [PATCH] Also handle the case that isnan is a "type-generic" macro. --- ChangeLog | 10 ++++++++++ lib/isnan.h | 2 +- lib/isnanl.h | 6 +++++- m4/isnan.m4 | 14 ++++++++++---- m4/isnanl.m4 | 18 ++++++++++++++---- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14fedc7dbc..3d953dada2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-02-24 Bruno Haible + + * 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 . + 2007-02-24 Bruno Haible * lib/isnan.c: Support the 'long double' case if USE_LONG_DOUBLE is diff --git a/lib/isnan.h b/lib/isnan.h index 8d534378f5..c4181bbdcb 100644 --- a/lib/isnan.h +++ b/lib/isnan.h @@ -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 #else /* Test whether X is a NaN. */ diff --git a/lib/isnanl.h b/lib/isnanl.h index 95f45410ed..1eac3c65f5 100644 --- a/lib/isnanl.h +++ b/lib/isnanl.h @@ -16,8 +16,12 @@ 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 +# ifdef isnan +# undef isnanl +# define isnanl(x) isnan ((long double)(x)) +# endif #else /* Test whether X is a NaN. */ # undef isnanl diff --git a/m4/isnan.m4 b/m4/isnan.m4 index 5bb133d0dc..d4729cdc37 100644 --- a/m4/isnan.m4 +++ b/m4/isnan.m4 @@ -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 + 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 diff --git a/m4/isnanl.m4 b/m4/isnanl.m4 index 54395793bf..6c6b0d057b 100644 --- a/m4/isnanl.m4 +++ b/m4/isnanl.m4 @@ -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 + #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 -- 2.30.2