Mercurial > hg > octave-shane > gnulib-hg
changeset 9646:a113e473cc98
Rename isnan, applicable to 'double' only, to isnand.
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,71 @@ +2008-01-26 Bruno Haible <bruno@clisp.org> + + 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 <math.h>): Replace isnan-nolibm with + isnand-nolibm. + * NEWS: Mention the change. + 2008-01-25 Paul Eggert <eggert@cs.ucla.edu> Bruno Haible <bruno@clisp.org>
--- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1984,8 +1984,8 @@ 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
--- a/NEWS +++ b/NEWS @@ -6,6 +6,11 @@ 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
--- 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()
--- 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 <config.h> -#include "isnan.h" #include "isnanf.h" +#include "isnand.h" #include "isnanl-nolibm.h" int gl_isfinitef (float x) @@ -30,7 +30,7 @@ int gl_isfinited (double x) { - return !isnan (x) && x - x == 0.; + return !isnand (x) && x - x == 0.; } int gl_isfinitel (long double x)
deleted file mode 100644 --- 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 <http://www.gnu.org/licenses/>. */ - -#if HAVE_ISNAN_IN_LIBC -/* Get declaration of isnan macro. */ -# include <math.h> -#else -/* Test whether X is a NaN. */ -# undef isnan -# define isnan rpl_isnan -extern int isnan (double x); -#endif
new file mode 100644 --- /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 <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include "isnan.c"
new file mode 100644 --- /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 <http://www.gnu.org/licenses/>. */ + +#if HAVE_ISNAND_IN_LIBC +/* Get declaration of isnan macro. */ +# include <math.h> +# 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
--- 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 <math.h> #include <string.h> -#include "isnan.h" +#include "isnand.h" #include "float+.h" #undef gl_signbitd @@ -45,7 +45,7 @@ #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;
--- 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 <math.h> -# 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 <math.h> -# include "isnan.h" +# include "isnand.h" # include "printf-frexp.h" #endif @@ -236,7 +236,7 @@ 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 @@ # 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 @@ 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 @@ { double arg = a.arg[dp->arg_index].a.a_double; - if (isnan (arg)) + if (isnand (arg)) { if (dp->conversion >= 'A' && dp->conversion <= 'Z') {
deleted file mode 100644 --- 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 <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(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 <float.h> -#include <stddef.h> -#include <stdio.h> -#include <string.h> -#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 -])
new file mode 100644 --- /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 <math.h> + 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 <float.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> +#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 +])
--- a/modules/fprintf-posix +++ b/modules/fprintf-posix @@ -10,7 +10,7 @@ stdio fseterr vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/frexp +++ b/modules/frexp @@ -7,7 +7,7 @@ Depends-on: math -isnan-nolibm +isnand-nolibm configure.ac: gl_FUNC_FREXP
--- a/modules/frexp-nolibm +++ b/modules/frexp-nolibm @@ -7,7 +7,7 @@ Depends-on: math -isnan-nolibm +isnand-nolibm configure.ac: gl_FUNC_FREXP_NO_LIBM
--- a/modules/frexp-nolibm-tests +++ b/modules/frexp-nolibm-tests @@ -2,7 +2,7 @@ tests/test-frexp.c Depends-on: -isnan-nolibm +isnand-nolibm signbit configure.ac:
--- a/modules/frexp-tests +++ b/modules/frexp-tests @@ -2,7 +2,7 @@ tests/test-frexp.c Depends-on: -isnan-nolibm +isnand-nolibm signbit configure.ac:
--- a/modules/isfinite +++ b/modules/isfinite @@ -7,8 +7,8 @@ m4/check-math-lib.m4 Depends-on: -isnan-nolibm isnanf-nolibm +isnand-nolibm isnanl-nolibm math extensions
deleted file mode 100644 --- 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 -
deleted file mode 100644 --- 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 -
new file mode 100644 --- /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 +
new file mode 100644 --- /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 +
--- a/modules/round-tests +++ b/modules/round-tests @@ -3,7 +3,7 @@ tests/test-round2.c Depends-on: -isnan-nolibm +isnand-nolibm stdbool stdint fprintf-posix
--- a/modules/signbit +++ b/modules/signbit @@ -12,7 +12,7 @@ float math isnanf-nolibm -isnan-nolibm +isnand-nolibm isnanl-nolibm fpieee
--- 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:
--- a/modules/snprintf-posix +++ b/modules/snprintf-posix @@ -9,7 +9,7 @@ Depends-on: snprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/sprintf-posix +++ b/modules/sprintf-posix @@ -9,7 +9,7 @@ Depends-on: stdio vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/trunc-tests +++ b/modules/trunc-tests @@ -4,7 +4,7 @@ Depends-on: float -isnan-nolibm +isnand-nolibm stdbool stdint fprintf-posix
--- a/modules/unistdio/u16-u16-vasnprintf +++ b/modules/unistdio/u16-u16-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/u16-vasnprintf +++ b/modules/unistdio/u16-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/u32-u32-vasnprintf +++ b/modules/unistdio/u32-u32-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/u32-vasnprintf +++ b/modules/unistdio/u32-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/u8-u8-vasnprintf +++ b/modules/unistdio/u8-u8-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/u8-vasnprintf +++ b/modules/unistdio/u8-vasnprintf @@ -30,7 +30,7 @@ unistr/u16-strmblen unistr/u32-strlen unistr/u32-strmblen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/unistdio/ulc-vasnprintf +++ b/modules/unistdio/ulc-vasnprintf @@ -28,7 +28,7 @@ unistr/u32-strlen unistr/u32-strmblen mbsnlen -isnan-nolibm +isnand-nolibm isnanl-nolibm frexpl-nolibm printf-frexp
--- a/modules/vasnprintf-posix +++ b/modules/vasnprintf-posix @@ -8,7 +8,7 @@ Depends-on: vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/vasprintf-posix +++ b/modules/vasprintf-posix @@ -8,7 +8,7 @@ Depends-on: vasprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/vfprintf-posix +++ b/modules/vfprintf-posix @@ -10,7 +10,7 @@ stdio fseterr vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/vsnprintf-posix +++ b/modules/vsnprintf-posix @@ -9,7 +9,7 @@ Depends-on: vsnprintf vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- a/modules/vsprintf-posix +++ b/modules/vsprintf-posix @@ -9,7 +9,7 @@ Depends-on: stdio vasnprintf -isnan-nolibm +isnand-nolibm isnanl-nolibm frexp-nolibm frexpl-nolibm
--- 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 <stdio.h> #include <stdlib.h> -#include "isnan.h" +#include "isnand.h" #define ASSERT(expr) \ do \ @@ -75,7 +75,7 @@ double mantissa; x = NaN (); mantissa = frexp (x, &exp); - ASSERT (isnan (mantissa)); + ASSERT (isnand (mantissa)); } { /* Positive infinity. */
deleted file mode 100644 --- 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 <http://www.gnu.org/licenses/>. */ - -/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ - -#include <config.h> - -#include "isnan.h" - -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> - -#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; -}
new file mode 100644 --- /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 <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +#include "isnand.h" + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> + +#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; +}
--- 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 <stdio.h> #include <stdlib.h> +#include "isnand.h" + #define ASSERT(expr) \ do \ { \ @@ -84,7 +86,7 @@ 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; }
--- 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
--- 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 <stdio.h> #include <stdlib.h> +#include "isnand.h" + #define ASSERT(expr) \ do \ { \ @@ -76,7 +78,7 @@ 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; }
--- 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 <stdio.h> #include <stdlib.h> -#include "isnan.h" +#include "isnand.h" #define ASSERT(expr) \ do \ @@ -103,7 +103,7 @@ 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. */