From 767cae75b2d4d013d5ef0783803157b417e5e906 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 26 Jan 2008 13:23:24 +0100 Subject: [PATCH] Use the GCC built-in when available. --- ChangeLog | 6 ++++++ lib/isnanf.h | 8 ++++++-- m4/isnanf.m4 | 14 ++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83bacd8ee..0756be850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-01-26 Bruno Haible + * m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_ISNANF_WORKS): Test the + GCC >= 4.0 built-in. + * lib/isnanf.h (isnanf): Use the GCC >= 4.0 built-in. + +2008-01-26 Bruno Haible + Rename isnan, applicable to 'double' only, to isnand. * modules/isnand-nolibm: Renamed from modules/isnan-nolibm. (Files): Add lib/isnand.h, lib/isnand.c. Remove lib/isnan.h. diff --git a/lib/isnanf.h b/lib/isnanf.h index 67bbfc679..774942c72 100644 --- a/lib/isnanf.h +++ b/lib/isnanf.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,11 @@ #if HAVE_ISNANF_IN_LIBC /* Get declaration of isnan macro or (older) isnanf function. */ # include -# ifdef isnan +# if __GNUC__ >= 4 + /* GCC 4.0 and newer provides three built-ins for isnan. */ +# undef isnanf +# define isnanf(x) __builtin_isnanf ((float)(x)) +# elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) # endif diff --git a/m4/isnanf.m4 b/m4/isnanf.m4 index 388e6c049..cff22369e 100644 --- a/m4/isnanf.m4 +++ b/m4/isnanf.m4 @@ -1,5 +1,5 @@ -# isnanf.m4 serial 4 -dnl Copyright (C) 2007 Free Software Foundation, Inc. +# isnanf.m4 serial 5 +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. @@ -33,7 +33,10 @@ AC_DEFUN([gl_HAVE_ISNANF_NO_LIBM], [gl_cv_func_isnanf_no_libm], [ AC_TRY_LINK([#include - #ifdef isnan + #if __GNUC__ >= 4 + # undef isnanf + # define isnanf(x) __builtin_isnanf ((float)(x)) + #elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) #endif @@ -54,7 +57,10 @@ AC_DEFUN([gl_ISNANF_WORKS], [ AC_TRY_RUN([ #include -#ifdef isnan +#if __GNUC__ >= 4 +# undef isnanf +# define isnanf(x) __builtin_isnanf ((float)(x)) +#elif defined isnan # undef isnanf # define isnanf(x) isnan ((float)(x)) #endif -- 2.11.0