From: Bruno Haible Date: Sat, 26 Jan 2008 14:17:58 +0000 (+0100) Subject: Rename isnan, applicable to 'double' only, to isnand. X-Git-Tag: v0.1~7807 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=b17d7ac7df62c7c7f56fe857ed28151d8b0e4e28;p=gnulib.git Rename isnan, applicable to 'double' only, to isnand. --- diff --git a/ChangeLog b/ChangeLog index 9f7c35dd8..83bacd8ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,71 @@ +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. + (configure.ac): Update. + (Include): Replace "isnan.h" with "isnand.h". + * m4/isnand.m4: Renamed from m4/isnan.m4. + (gl_FUNC_ISNAND_NO_LIBM): Renamed from gl_FUNC_ISNAN_NO_LIBM. Set + HAVE_ISNAND_IN_LIBC instead of HAVE_ISNAN_IN_LIBC. Build isnand.c + instead of isnan.c. + * lib/isnand.h: Renamed from lib/isnan.h. Test HAVE_ISNAND_IN_LIBC + instead of HAVE_ISNAN_IN_LIBC. + (isnand): Renamed from isnan. + * lib/isnand.c: New file. + * modules/isnand-nolibm-tests: Renamed from modules/isnan-nolibm-tests. + (Files): Add tests/test-isnand.c. Remove tests/test-isnan.c. + (Makefile.am): Update. + * tests/test-isnand.c: Renamed from tests/test-isnan.c. + Include isnand.h instead of isnan.h. + (main): Test isnand instead of isnan. + * modules/fprintf-posix (Depends-on): Add isnand-nolibm, remove + isnan-nolibm. + * modules/frexp (Depends-on): Likewise. + * modules/frexp-tests (Depends-on): Likewise. + * modules/frexp-nolibm (Depends-on): Likewise. + * modules/frexp-nolibm-tests (Depends-on): Likewise. + * modules/isfinite (Depends-on): Likewise. + * modules/round-tests (Depends-on): Likewise. + * modules/signbit (Depends-on): Likewise. + * modules/signbit-tests (Depends-on): Likewise. + * modules/snprintf-posix (Depends-on): Likewise. + * modules/sprintf-posix (Depends-on): Likewise. + * modules/trunc-tests (Depends-on): Likewise. + * modules/unistdio/u8-vasnprintf (Depends-on): Likewise. + * modules/unistdio/u8-u8-vasnprintf (Depends-on): Likewise. + * modules/unistdio/u16-vasnprintf (Depends-on): Likewise. + * modules/unistdio/u16-u16-vasnprintf (Depends-on): Likewise. + * modules/unistdio/u32-vasnprintf (Depends-on): Likewise. + * modules/unistdio/u32-u32-vasnprintf (Depends-on): Likewise. + * modules/unistdio/ulc-vasnprintf (Depends-on): Likewise. + * modules/vasnprintf-posix (Depends-on): Likewise. + * modules/vasprintf-posix (Depends-on): Likewise. + * modules/vfprintf-posix (Depends-on): Likewise. + * modules/vsnprintf-posix (Depends-on): Likewise. + * modules/vsprintf-posix (Depends-on): Likewise. + * lib/frexp.c: Include isnand.h instead of isnan.h. + (ISNAN): Set to isnand instead of isnan. + * lib/isfinite.c: Include isnand.h instead of isnan.h. + (gl_isfinited): Use isnand instead of isnan. + * lib/signbitd.c: Include isnand.h instead of isnan.h. + (gl_signbitd): Use isnand instead of isnan. + * lib/vasnprintf.c: Include isnand.h instead of isnan.h. + (is_infinite_or_zero, VASNPRINTF): Use isnand instead of isnan. + * tests/test-frexp.c: Include isnand.h instead of isnan.h. + (main): Use isnand instead of isnan. + * tests/test-round1.c: Include isnand.h. + (main): Use isnand instead of isnan. + * tests/test-round2.c: Include isnand.h instead of isnan.h. + (ISNAN): Set to isnand instead of isnan. + * tests/test-trunc1.c: Include isnand.h. + (main): Use isnand instead of isnan. + * tests/test-trunc2.c: Include isnand.h instead of isnan.h. + (equal): Use isnand instead of isnan. + * MODULES.html.sh (Mathematics ): Replace isnan-nolibm with + isnand-nolibm. + * NEWS: Mention the change. + 2008-01-25 Paul Eggert Bruno Haible diff --git a/MODULES.html.sh b/MODULES.html.sh index 53bf494b3..bf89f4b77 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1984,8 +1984,8 @@ func_all_modules () func_module frexpl func_module frexpl-nolibm func_module isfinite - func_module isnan-nolibm func_module isnanf-nolibm + func_module isnand-nolibm func_module isnanl func_module isnanl-nolibm func_module ldexpl diff --git a/NEWS b/NEWS index 568d57af8..f541b6144 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,11 @@ User visible incompatible changes Date Modules Changes +2008-01-26 isnan-nolibm The module name is changed from isnan-nolibm to + isnand-nolibm. The include file is changed from + "isnan.h" to "isnand.h". The function that it + defines is changed from isnan() to isnand(). + 2008-01-14 strcasestr This module now replaces worst-case inefficient implementations; clients that use controlled needles and thus do not care about worst-case diff --git a/lib/frexp.c b/lib/frexp.c index ed4da8862..4fd081920 100644 --- a/lib/frexp.c +++ b/lib/frexp.c @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa. - 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 @@ -27,7 +27,7 @@ # include "isnanl-nolibm.h" # include "fpucw.h" #else -# include "isnan.h" +# include "isnand.h" #endif /* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater @@ -45,7 +45,7 @@ #else # define FUNC frexp # define DOUBLE double -# define ISNAN isnan +# define ISNAN isnand # define DECL_ROUNDING # define BEGIN_ROUNDING() # define END_ROUNDING() diff --git a/lib/isfinite.c b/lib/isfinite.c index 84dcd175a..e6489297f 100644 --- a/lib/isfinite.c +++ b/lib/isfinite.c @@ -1,5 +1,5 @@ /* Test for finite value (zero, subnormal, or normal, and not infinite or NaN). - 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 @@ -19,8 +19,8 @@ #include -#include "isnan.h" #include "isnanf.h" +#include "isnand.h" #include "isnanl-nolibm.h" int gl_isfinitef (float x) @@ -30,7 +30,7 @@ int gl_isfinitef (float x) int gl_isfinited (double x) { - return !isnan (x) && x - x == 0.; + return !isnand (x) && x - x == 0.; } int gl_isfinitel (long double x) diff --git a/lib/isnan.h b/lib/isnan.h deleted file mode 100644 index c67110431..000000000 --- a/lib/isnan.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2007 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 - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#if HAVE_ISNAN_IN_LIBC -/* Get declaration of isnan macro. */ -# include -#else -/* Test whether X is a NaN. */ -# undef isnan -# define isnan rpl_isnan -extern int isnan (double x); -#endif diff --git a/lib/isnand.c b/lib/isnand.c new file mode 100644 index 000000000..8e5bbb399 --- /dev/null +++ b/lib/isnand.c @@ -0,0 +1,19 @@ +/* Test for NaN that does not need libm. + Copyright (C) 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2008. */ + +#include "isnan.c" diff --git a/lib/isnand.h b/lib/isnand.h new file mode 100644 index 000000000..c58697f17 --- /dev/null +++ b/lib/isnand.h @@ -0,0 +1,29 @@ +/* Test for NaN that does not need libm. + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#if HAVE_ISNAND_IN_LIBC +/* Get declaration of isnan macro. */ +# include +# ifdef isnan +# undef isnand +# define isnand(x) isnan ((double)(x)) +# endif +#else +/* Test whether X is a NaN. */ +# undef isnand +# define isnand rpl_isnand +extern int isnand (double x); +#endif diff --git a/lib/signbitd.c b/lib/signbitd.c index 8907766f2..8871de792 100644 --- a/lib/signbitd.c +++ b/lib/signbitd.c @@ -1,5 +1,5 @@ /* signbit() macro: Determine the sign bit of a floating-point number. - 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 @@ -20,7 +20,7 @@ #include #include -#include "isnan.h" +#include "isnand.h" #include "float+.h" #undef gl_signbitd @@ -45,7 +45,7 @@ gl_signbitd (double arg) #else /* This does not do the right thing for NaN, but this is irrelevant for most use cases. */ - if (isnan (arg)) + if (isnand (arg)) return 0; if (arg < 0.0) return 1; diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index f26b42be6..7e533be1f 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-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 @@ -95,7 +95,7 @@ #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL # include -# include "isnan.h" +# include "isnand.h" #endif #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL @@ -106,7 +106,7 @@ #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL # include -# include "isnan.h" +# include "isnand.h" # include "printf-frexp.h" #endif @@ -236,7 +236,7 @@ decimal_point_char () static int is_infinite_or_zero (double x) { - return isnan (x) || x + x == x; + return isnand (x) || x + x == x; } #endif @@ -2327,7 +2327,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE double arg = a.arg[dp->arg_index].a.a_double; - if (isnan (arg)) + if (isnand (arg)) { if (dp->conversion == 'A') { @@ -2676,7 +2676,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (dp->conversion == 'f' || dp->conversion == 'F') { double arg = a.arg[dp->arg_index].a.a_double; - if (!(isnan (arg) || arg + arg == arg)) + if (!(isnand (arg) || arg + arg == arg)) { /* arg is finite and nonzero. */ int exponent = floorlog10 (arg < 0 ? -arg : arg); @@ -3080,7 +3080,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { double arg = a.arg[dp->arg_index].a.a_double; - if (isnan (arg)) + if (isnand (arg)) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') { diff --git a/m4/isnan.m4 b/m4/isnan.m4 deleted file mode 100644 index de692e69a..000000000 --- a/m4/isnan.m4 +++ /dev/null @@ -1,137 +0,0 @@ -# isnan.m4 serial 2 -dnl Copyright (C) 2007 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. - -dnl Check how to get or define isnan() without linking with libm. - -AC_DEFUN([gl_FUNC_ISNAN_NO_LIBM], -[ - 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(double) function is available in libc.]) - else - AC_LIBOBJ([isnan]) - gl_DOUBLE_EXPONENT_LOCATION - fi -]) - -AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], -[ - AC_CACHE_CHECK([where to find the exponent in a 'double'], - [gl_cv_cc_double_expbit0], - [ - AC_TRY_RUN([ -#include -#include -#include -#include -#define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) -typedef union { double value; unsigned int word[NWORDS]; } memory_double; -static unsigned int ored_words[NWORDS]; -static unsigned int anded_words[NWORDS]; -static void add_to_ored_words (double x) -{ - memory_double m; - size_t i; - /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ - memset (&m, 0, sizeof (memory_double)); - m.value = x; - for (i = 0; i < NWORDS; i++) - { - ored_words[i] |= m.word[i]; - anded_words[i] &= m.word[i]; - } -} -int main () -{ - size_t j; - FILE *fp = fopen ("conftest.out", "w"); - if (fp == NULL) - return 1; - for (j = 0; j < NWORDS; j++) - anded_words[j] = ~ (unsigned int) 0; - add_to_ored_words (0.25); - add_to_ored_words (0.5); - add_to_ored_words (1.0); - add_to_ored_words (2.0); - add_to_ored_words (4.0); - /* Remove bits that are common (e.g. if representation of the first mantissa - bit is explicit). */ - for (j = 0; j < NWORDS; j++) - ored_words[j] &= ~anded_words[j]; - /* Now find the nonzero word. */ - for (j = 0; j < NWORDS; j++) - if (ored_words[j] != 0) - break; - if (j < NWORDS) - { - size_t i; - for (i = j + 1; i < NWORDS; i++) - if (ored_words[i] != 0) - { - fprintf (fp, "unknown"); - return (fclose (fp) != 0); - } - for (i = 0; ; i++) - if ((ored_words[j] >> i) & 1) - { - fprintf (fp, "word %d bit %d", (int) j, (int) i); - return (fclose (fp) != 0); - } - } - fprintf (fp, "unknown"); - return (fclose (fp) != 0); -} - ], - [gl_cv_cc_double_expbit0=`cat conftest.out`], - [gl_cv_cc_double_expbit0="unknown"], - [ - dnl On ARM, there are two 'double' floating-point formats, used by - dnl different sets of instructions: The older FPA instructions assume - dnl that they are stored in big-endian word order, while the words - dnl (like integer types) are stored in little-endian byte order. - dnl The newer VFP instructions assume little-endian order consistenly. - AC_EGREP_CPP([mixed_endianness], [ -#if defined arm || defined __arm || defined __arm__ - mixed_endianness -#endif - ], - [gl_cv_cc_double_expbit0="unknown"], - [ - pushdef([AC_MSG_CHECKING],[:])dnl - pushdef([AC_MSG_RESULT],[:])dnl - pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl - AC_C_BIGENDIAN( - [gl_cv_cc_double_expbit0="word 0 bit 20"], - [gl_cv_cc_double_expbit0="word 1 bit 20"], - [gl_cv_cc_double_expbit0="unknown"]) - popdef([AC_MSG_RESULT_UNQUOTED])dnl - popdef([AC_MSG_RESULT])dnl - popdef([AC_MSG_CHECKING])dnl - ]) - ]) - rm -f conftest.out - ]) - case "$gl_cv_cc_double_expbit0" in - word*bit*) - word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` - bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` - AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word], - [Define as the word index where to find the exponent of 'double'.]) - AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit], - [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.]) - ;; - esac -]) diff --git a/m4/isnand.m4 b/m4/isnand.m4 new file mode 100644 index 000000000..4f747eae0 --- /dev/null +++ b/m4/isnand.m4 @@ -0,0 +1,137 @@ +# isnand.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. + +dnl Check how to get or define isnand() without linking with libm. + +AC_DEFUN([gl_FUNC_ISNAND_NO_LIBM], +[ + AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm], + [gl_cv_func_isnand_no_libm], + [ + AC_TRY_LINK([#include + double x;], + [return isnan (x);], + [gl_cv_func_isnand_no_libm=yes], + [gl_cv_func_isnand_no_libm=no]) + ]) + if test $gl_cv_func_isnand_no_libm = yes; then + AC_DEFINE([HAVE_ISNAND_IN_LIBC], 1, + [Define if the isnan(double) function is available in libc.]) + else + AC_LIBOBJ([isnand]) + gl_DOUBLE_EXPONENT_LOCATION + fi +]) + +AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], +[ + AC_CACHE_CHECK([where to find the exponent in a 'double'], + [gl_cv_cc_double_expbit0], + [ + AC_TRY_RUN([ +#include +#include +#include +#include +#define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) +typedef union { double value; unsigned int word[NWORDS]; } memory_double; +static unsigned int ored_words[NWORDS]; +static unsigned int anded_words[NWORDS]; +static void add_to_ored_words (double x) +{ + memory_double m; + size_t i; + /* Clear it first, in case sizeof (double) < sizeof (memory_double). */ + memset (&m, 0, sizeof (memory_double)); + m.value = x; + for (i = 0; i < NWORDS; i++) + { + ored_words[i] |= m.word[i]; + anded_words[i] &= m.word[i]; + } +} +int main () +{ + size_t j; + FILE *fp = fopen ("conftest.out", "w"); + if (fp == NULL) + return 1; + for (j = 0; j < NWORDS; j++) + anded_words[j] = ~ (unsigned int) 0; + add_to_ored_words (0.25); + add_to_ored_words (0.5); + add_to_ored_words (1.0); + add_to_ored_words (2.0); + add_to_ored_words (4.0); + /* Remove bits that are common (e.g. if representation of the first mantissa + bit is explicit). */ + for (j = 0; j < NWORDS; j++) + ored_words[j] &= ~anded_words[j]; + /* Now find the nonzero word. */ + for (j = 0; j < NWORDS; j++) + if (ored_words[j] != 0) + break; + if (j < NWORDS) + { + size_t i; + for (i = j + 1; i < NWORDS; i++) + if (ored_words[i] != 0) + { + fprintf (fp, "unknown"); + return (fclose (fp) != 0); + } + for (i = 0; ; i++) + if ((ored_words[j] >> i) & 1) + { + fprintf (fp, "word %d bit %d", (int) j, (int) i); + return (fclose (fp) != 0); + } + } + fprintf (fp, "unknown"); + return (fclose (fp) != 0); +} + ], + [gl_cv_cc_double_expbit0=`cat conftest.out`], + [gl_cv_cc_double_expbit0="unknown"], + [ + dnl On ARM, there are two 'double' floating-point formats, used by + dnl different sets of instructions: The older FPA instructions assume + dnl that they are stored in big-endian word order, while the words + dnl (like integer types) are stored in little-endian byte order. + dnl The newer VFP instructions assume little-endian order consistenly. + AC_EGREP_CPP([mixed_endianness], [ +#if defined arm || defined __arm || defined __arm__ + mixed_endianness +#endif + ], + [gl_cv_cc_double_expbit0="unknown"], + [ + pushdef([AC_MSG_CHECKING],[:])dnl + pushdef([AC_MSG_RESULT],[:])dnl + pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl + AC_C_BIGENDIAN( + [gl_cv_cc_double_expbit0="word 0 bit 20"], + [gl_cv_cc_double_expbit0="word 1 bit 20"], + [gl_cv_cc_double_expbit0="unknown"]) + popdef([AC_MSG_RESULT_UNQUOTED])dnl + popdef([AC_MSG_RESULT])dnl + popdef([AC_MSG_CHECKING])dnl + ]) + ]) + rm -f conftest.out + ]) + case "$gl_cv_cc_double_expbit0" in + word*bit*) + word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'` + bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'` + AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word], + [Define as the word index where to find the exponent of 'double'.]) + AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit], + [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.]) + ;; + esac +]) diff --git a/modules/fprintf-posix b/modules/fprintf-posix index 44588a95d..aaf5d6e5a 100644 --- a/modules/fprintf-posix +++ b/modules/fprintf-posix @@ -10,7 +10,7 @@ Depends-on: stdio fseterr vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/frexp b/modules/frexp index 92c635baf..7fae366db 100644 --- a/modules/frexp +++ b/modules/frexp @@ -7,7 +7,7 @@ m4/frexp.m4 Depends-on: math -isnan-nolibm +isnand-nolibm configure.ac: gl_FUNC_FREXP diff --git a/modules/frexp-nolibm b/modules/frexp-nolibm index 8026d76b7..6a909e972 100644 --- a/modules/frexp-nolibm +++ b/modules/frexp-nolibm @@ -7,7 +7,7 @@ m4/frexp.m4 Depends-on: math -isnan-nolibm +isnand-nolibm configure.ac: gl_FUNC_FREXP_NO_LIBM diff --git a/modules/frexp-nolibm-tests b/modules/frexp-nolibm-tests index c1a93da29..ec0f4c731 100644 --- a/modules/frexp-nolibm-tests +++ b/modules/frexp-nolibm-tests @@ -2,7 +2,7 @@ Files: tests/test-frexp.c Depends-on: -isnan-nolibm +isnand-nolibm signbit configure.ac: diff --git a/modules/frexp-tests b/modules/frexp-tests index adfe218ea..6982cf94e 100644 --- a/modules/frexp-tests +++ b/modules/frexp-tests @@ -2,7 +2,7 @@ Files: tests/test-frexp.c Depends-on: -isnan-nolibm +isnand-nolibm signbit configure.ac: diff --git a/modules/isfinite b/modules/isfinite index 6c77a0aa6..f122c5ad7 100644 --- a/modules/isfinite +++ b/modules/isfinite @@ -7,8 +7,8 @@ m4/isfinite.m4 m4/check-math-lib.m4 Depends-on: -isnan-nolibm isnanf-nolibm +isnand-nolibm isnanl-nolibm math extensions diff --git a/modules/isnan-nolibm b/modules/isnan-nolibm deleted file mode 100644 index 101dd94f7..000000000 --- a/modules/isnan-nolibm +++ /dev/null @@ -1,26 +0,0 @@ -Description: -isnan() function: test for NaN, without requiring libm. - -Files: -lib/isnan.h -lib/isnan.c -lib/float+.h -m4/isnan.m4 - -Depends-on: -fpieee - -configure.ac: -gl_FUNC_ISNAN_NO_LIBM - -Makefile.am: - -Include: -#include "isnan.h" - -License: -LGPL - -Maintainer: -Bruno Haible - diff --git a/modules/isnan-nolibm-tests b/modules/isnan-nolibm-tests deleted file mode 100644 index 8b158fab9..000000000 --- a/modules/isnan-nolibm-tests +++ /dev/null @@ -1,12 +0,0 @@ -Files: -tests/test-isnan.c - -Depends-on: - -configure.ac: -gl_DOUBLE_EXPONENT_LOCATION - -Makefile.am: -TESTS += test-isnan -check_PROGRAMS += test-isnan - diff --git a/modules/isnand-nolibm b/modules/isnand-nolibm new file mode 100644 index 000000000..6bb8c7da3 --- /dev/null +++ b/modules/isnand-nolibm @@ -0,0 +1,27 @@ +Description: +isnand() function: test for NaN, without requiring libm. + +Files: +lib/isnand.h +lib/isnand.c +lib/isnan.c +lib/float+.h +m4/isnand.m4 + +Depends-on: +fpieee + +configure.ac: +gl_FUNC_ISNAND_NO_LIBM + +Makefile.am: + +Include: +#include "isnand.h" + +License: +LGPL + +Maintainer: +Bruno Haible + diff --git a/modules/isnand-nolibm-tests b/modules/isnand-nolibm-tests new file mode 100644 index 000000000..cfe52b800 --- /dev/null +++ b/modules/isnand-nolibm-tests @@ -0,0 +1,12 @@ +Files: +tests/test-isnand.c + +Depends-on: + +configure.ac: +gl_DOUBLE_EXPONENT_LOCATION + +Makefile.am: +TESTS += test-isnand +check_PROGRAMS += test-isnand + diff --git a/modules/round-tests b/modules/round-tests index d061431f1..a4d2a15ab 100644 --- a/modules/round-tests +++ b/modules/round-tests @@ -3,7 +3,7 @@ tests/test-round1.c tests/test-round2.c Depends-on: -isnan-nolibm +isnand-nolibm stdbool stdint fprintf-posix diff --git a/modules/signbit b/modules/signbit index 57ba15456..94b524a97 100644 --- a/modules/signbit +++ b/modules/signbit @@ -12,7 +12,7 @@ Depends-on: float math isnanf-nolibm -isnan-nolibm +isnand-nolibm isnanl-nolibm fpieee diff --git a/modules/signbit-tests b/modules/signbit-tests index e0ee2bdf1..e2c3cf71a 100644 --- a/modules/signbit-tests +++ b/modules/signbit-tests @@ -1,7 +1,7 @@ Files: tests/test-signbit.c m4/isnanf.m4 -m4/isnan.m4 +m4/isnand.m4 m4/isnanl.m4 Depends-on: diff --git a/modules/snprintf-posix b/modules/snprintf-posix index 679569fa5..106997b45 100644 --- a/modules/snprintf-posix +++ b/modules/snprintf-posix @@ -9,7 +9,7 @@ m4/printf.m4 Depends-on: snprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/sprintf-posix b/modules/sprintf-posix index 4aaa2d46b..b5e8fcefd 100644 --- a/modules/sprintf-posix +++ b/modules/sprintf-posix @@ -9,7 +9,7 @@ m4/printf.m4 Depends-on: stdio vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/trunc-tests b/modules/trunc-tests index ade196477..621e76d42 100644 --- a/modules/trunc-tests +++ b/modules/trunc-tests @@ -4,7 +4,7 @@ tests/test-trunc2.c Depends-on: float -isnan-nolibm +isnand-nolibm stdbool stdint fprintf-posix diff --git a/modules/unistdio/u16-u16-vasnprintf b/modules/unistdio/u16-u16-vasnprintf index 9c3ec61d2..430c60d17 100644 --- a/modules/unistdio/u16-u16-vasnprintf +++ b/modules/unistdio/u16-u16-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/u16-vasnprintf b/modules/unistdio/u16-vasnprintf index 4a98d3c85..3f7c5ba16 100644 --- a/modules/unistdio/u16-vasnprintf +++ b/modules/unistdio/u16-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/u32-u32-vasnprintf b/modules/unistdio/u32-u32-vasnprintf index 062533d10..479a1382b 100644 --- a/modules/unistdio/u32-u32-vasnprintf +++ b/modules/unistdio/u32-u32-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/u32-vasnprintf b/modules/unistdio/u32-vasnprintf index 5bad1564d..5b7809851 100644 --- a/modules/unistdio/u32-vasnprintf +++ b/modules/unistdio/u32-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/u8-u8-vasnprintf b/modules/unistdio/u8-u8-vasnprintf index 072f95cfc..a36f50134 100644 --- a/modules/unistdio/u8-u8-vasnprintf +++ b/modules/unistdio/u8-u8-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/u8-vasnprintf b/modules/unistdio/u8-vasnprintf index 20eb19935..909073c9d 100644 --- a/modules/unistdio/u8-vasnprintf +++ b/modules/unistdio/u8-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strlen unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/unistdio/ulc-vasnprintf b/modules/unistdio/ulc-vasnprintf index 30dc65d1f..504538b94 100644 --- a/modules/unistdio/ulc-vasnprintf +++ b/modules/unistdio/ulc-vasnprintf @@ -28,7 +28,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen mbsnlen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp diff --git a/modules/vasnprintf-posix b/modules/vasnprintf-posix index 3d07c70f2..0eefa5802 100644 --- a/modules/vasnprintf-posix +++ b/modules/vasnprintf-posix @@ -8,7 +8,7 @@ m4/printf.m4 Depends-on: vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/vasprintf-posix b/modules/vasprintf-posix index fde988144..e60680041 100644 --- a/modules/vasprintf-posix +++ b/modules/vasprintf-posix @@ -8,7 +8,7 @@ m4/printf.m4 Depends-on: vasprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/vfprintf-posix b/modules/vfprintf-posix index 52ab7ee5a..6282280c1 100644 --- a/modules/vfprintf-posix +++ b/modules/vfprintf-posix @@ -10,7 +10,7 @@ Depends-on: stdio fseterr vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/vsnprintf-posix b/modules/vsnprintf-posix index dbe640215..187dc32e7 100644 --- a/modules/vsnprintf-posix +++ b/modules/vsnprintf-posix @@ -9,7 +9,7 @@ m4/printf.m4 Depends-on: vsnprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/modules/vsprintf-posix b/modules/vsprintf-posix index 0dc7ea23b..af02a5e96 100644 --- a/modules/vsprintf-posix +++ b/modules/vsprintf-posix @@ -9,7 +9,7 @@ m4/printf.m4 Depends-on: stdio vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm diff --git a/tests/test-frexp.c b/tests/test-frexp.c index 9856ba041..47db2bec4 100644 --- a/tests/test-frexp.c +++ b/tests/test-frexp.c @@ -1,5 +1,5 @@ /* Test of splitting a double into fraction and mantissa. - 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 @@ -24,7 +24,7 @@ #include #include -#include "isnan.h" +#include "isnand.h" #define ASSERT(expr) \ do \ @@ -75,7 +75,7 @@ main () double mantissa; x = NaN (); mantissa = frexp (x, &exp); - ASSERT (isnan (mantissa)); + ASSERT (isnand (mantissa)); } { /* Positive infinity. */ diff --git a/tests/test-isnan.c b/tests/test-isnan.c deleted file mode 100644 index 3541af4be..000000000 --- a/tests/test-isnan.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Test of isnan() substitute. - Copyright (C) 2007 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 - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Bruno Haible , 2007. */ - -#include - -#include "isnan.h" - -#include -#include -#include - -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - abort (); \ - } \ - } \ - while (0) - -/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ -#ifdef __DECC -static double -NaN () -{ - static double zero = 0.0; - return zero / zero; -} -#else -# define NaN() (0.0 / 0.0) -#endif - -int -main () -{ - /* Finite values. */ - ASSERT (!isnan (3.141)); - ASSERT (!isnan (3.141e30)); - ASSERT (!isnan (3.141e-30)); - ASSERT (!isnan (-2.718)); - ASSERT (!isnan (-2.718e30)); - ASSERT (!isnan (-2.718e-30)); - ASSERT (!isnan (0.0)); - ASSERT (!isnan (-0.0)); - /* Infinite values. */ - ASSERT (!isnan (1.0 / 0.0)); - ASSERT (!isnan (-1.0 / 0.0)); - /* Quiet NaN. */ - ASSERT (isnan (NaN ())); -#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT - /* Signalling NaN. */ - { - #define NWORDS \ - ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) - typedef union { double value; unsigned int word[NWORDS]; } memory_double; - memory_double m; - m.value = NaN (); -# if DBL_EXPBIT0_BIT > 0 - m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); -# else - m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); -# endif - m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] - |= (unsigned int) 1 << DBL_EXPBIT0_BIT; - ASSERT (isnan (m.value)); - } -#endif - return 0; -} diff --git a/tests/test-isnand.c b/tests/test-isnand.c new file mode 100644 index 000000000..0bc0a26de --- /dev/null +++ b/tests/test-isnand.c @@ -0,0 +1,87 @@ +/* Test of isnand() substitute. + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +#include "isnand.h" + +#include +#include +#include + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + abort (); \ + } \ + } \ + while (0) + +/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ +#ifdef __DECC +static double +NaN () +{ + static double zero = 0.0; + return zero / zero; +} +#else +# define NaN() (0.0 / 0.0) +#endif + +int +main () +{ + /* Finite values. */ + ASSERT (!isnand (3.141)); + ASSERT (!isnand (3.141e30)); + ASSERT (!isnand (3.141e-30)); + ASSERT (!isnand (-2.718)); + ASSERT (!isnand (-2.718e30)); + ASSERT (!isnand (-2.718e-30)); + ASSERT (!isnand (0.0)); + ASSERT (!isnand (-0.0)); + /* Infinite values. */ + ASSERT (!isnand (1.0 / 0.0)); + ASSERT (!isnand (-1.0 / 0.0)); + /* Quiet NaN. */ + ASSERT (isnand (NaN ())); +#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT + /* Signalling NaN. */ + { + #define NWORDS \ + ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) + typedef union { double value; unsigned int word[NWORDS]; } memory_double; + memory_double m; + m.value = NaN (); +# if DBL_EXPBIT0_BIT > 0 + m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); +# else + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + ^= (unsigned int) 1 << (sizeof (unsigned int) * CHAR_BIT - 1); +# endif + m.word[DBL_EXPBIT0_WORD + (DBL_EXPBIT0_WORD < NWORDS / 2 ? 1 : - 1)] + |= (unsigned int) 1 << DBL_EXPBIT0_BIT; + ASSERT (isnand (m.value)); + } +#endif + return 0; +} diff --git a/tests/test-round1.c b/tests/test-round1.c index 396fcc4b9..625b9ff36 100644 --- a/tests/test-round1.c +++ b/tests/test-round1.c @@ -1,5 +1,5 @@ /* Test of rounding to nearest, breaking ties away from zero. - 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 @@ -25,6 +25,8 @@ #include #include +#include "isnand.h" + #define ASSERT(expr) \ do \ { \ @@ -84,7 +86,7 @@ main () ASSERT (round (1.0 / 0.0) == 1.0 / 0.0); ASSERT (round (-1.0 / 0.0) == -1.0 / 0.0); /* NaNs. */ - ASSERT (isnan (round (NaN ()))); + ASSERT (isnand (round (NaN ()))); return 0; } diff --git a/tests/test-round2.c b/tests/test-round2.c index 47d818c1d..b3ae0c80b 100644 --- a/tests/test-round2.c +++ b/tests/test-round2.c @@ -1,5 +1,5 @@ /* Test of rounding to nearest, breaking ties away from zero. - 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 @@ -37,8 +37,8 @@ #ifdef USE_LONG_DOUBLE # error Long double not supported. #elif ! defined USE_FLOAT -# include "isnan.h" -# define ISNAN isnan +# include "isnand.h" +# define ISNAN isnand # define FUNCTION "round" # define DOUBLE_UINT uint64_t # define DOUBLE_BITS 64 diff --git a/tests/test-trunc1.c b/tests/test-trunc1.c index 58669035b..a2d6dd4b4 100644 --- a/tests/test-trunc1.c +++ b/tests/test-trunc1.c @@ -1,5 +1,5 @@ /* Test of rounding towards zero. - 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 @@ -23,6 +23,8 @@ #include #include +#include "isnand.h" + #define ASSERT(expr) \ do \ { \ @@ -76,7 +78,7 @@ main () ASSERT (trunc (1.0 / 0.0) == 1.0 / 0.0); ASSERT (trunc (-1.0 / 0.0) == -1.0 / 0.0); /* NaNs. */ - ASSERT (isnan (trunc (NaN ()))); + ASSERT (isnand (trunc (NaN ()))); return 0; } diff --git a/tests/test-trunc2.c b/tests/test-trunc2.c index f3238ffe2..c06846d31 100644 --- a/tests/test-trunc2.c +++ b/tests/test-trunc2.c @@ -1,5 +1,5 @@ /* Test of rounding towards zero. - 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 @@ -26,7 +26,7 @@ #include #include -#include "isnan.h" +#include "isnand.h" #define ASSERT(expr) \ do \ @@ -103,7 +103,7 @@ trunc_reference (DOUBLE x) static int equal (DOUBLE x, DOUBLE y) { - return (isnan (x) ? isnan (y) : x == y); + return (isnand (x) ? isnand (y) : x == y); } /* Test whether the result for a given argument is correct. */