From: Bruno Haible <bruno@clisp.org> Date: Fri, 13 Oct 2023 11:05:06 +0000 (+0200) Subject: signed-nan: New module, renamed from qnan. X-Git-Tag: v1.0~711 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=80f9860e2631345d5e0078f184307dbd6bdf905b;p=gnulib.git signed-nan: New module, renamed from qnan. * lib/signed-nan.h: Renamed from lib/qnan.h. Update double-inclusion guard. * modules/signed-nan: Renamed from modules/qnan. Update. * tests/test-signbit.c: Update. * tests/test-stdio.c: Likewise. * tests/test-totalorder.c: Likewise. * modules/*-tests: Update. --- diff --git a/ChangeLog b/ChangeLog index 0a4be95ecf..7a06938f21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2023-10-13 Bruno Haible <bruno@clisp.org> + + signed-nan: New module, renamed from qnan. + * lib/signed-nan.h: Renamed from lib/qnan.h. Update double-inclusion + guard. + * modules/signed-nan: Renamed from modules/qnan. Update. + * tests/test-signbit.c: Update. + * tests/test-stdio.c: Likewise. + * tests/test-totalorder.c: Likewise. + * modules/*-tests: Update. + 2023-10-13 Bruno Haible <bruno@clisp.org> access: Fix test failure on native Windows. diff --git a/lib/qnan.h b/lib/qnan.h deleted file mode 100644 index e6538c227e..0000000000 --- a/lib/qnan.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Macros for quiet not-a-number. - Copyright (C) 2023 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 <https://www.gnu.org/licenses/>. */ - -#ifndef _QNAN_H -#define _QNAN_H - -#include <math.h> - -#include "nan.h" - - -/* Returns a quiet 'float' NaN with sign bit == 0. */ -_GL_UNUSED static float -positive_NaNf () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - float volatile nan = NaNf (); - return (signbit (nan) ? - nan : nan); -} - -/* Returns a quiet 'float' NaN with sign bit == 1. */ -_GL_UNUSED static float -negative_NaNf () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - float volatile nan = NaNf (); - return (signbit (nan) ? nan : - nan); -} - - -/* Returns a quiet 'double' NaN with sign bit == 0. */ -_GL_UNUSED static double -positive_NaNd () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - double volatile nan = NaNd (); - return (signbit (nan) ? - nan : nan); -} - -/* Returns a quiet 'double' NaN with sign bit == 1. */ -_GL_UNUSED static double -negative_NaNd () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - double volatile nan = NaNd (); - return (signbit (nan) ? nan : - nan); -} - - -/* Returns a quiet 'long double' NaN with sign bit == 0. */ -_GL_UNUSED static long double -positive_NaNl () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - long double volatile nan = NaNl (); - return (signbit (nan) ? - nan : nan); -} - -/* Returns a quiet 'long double' NaN with sign bit == 1. */ -_GL_UNUSED static long double -negative_NaNl () -{ - /* 'volatile' works around a GCC bug: - <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ - long double volatile nan = NaNl (); - return (signbit (nan) ? nan : - nan); -} - - -#endif /* _QNAN_H */ diff --git a/lib/signed-nan.h b/lib/signed-nan.h new file mode 100644 index 0000000000..1018b58cd0 --- /dev/null +++ b/lib/signed-nan.h @@ -0,0 +1,88 @@ +/* Macros for quiet not-a-number. + Copyright (C) 2023 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 <https://www.gnu.org/licenses/>. */ + +#ifndef _SIGNED_NAN_H +#define _SIGNED_NAN_H + +#include <math.h> + +#include "nan.h" + + +/* Returns a quiet 'float' NaN with sign bit == 0. */ +_GL_UNUSED static float +positive_NaNf () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + float volatile nan = NaNf (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'float' NaN with sign bit == 1. */ +_GL_UNUSED static float +negative_NaNf () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + float volatile nan = NaNf (); + return (signbit (nan) ? nan : - nan); +} + + +/* Returns a quiet 'double' NaN with sign bit == 0. */ +_GL_UNUSED static double +positive_NaNd () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + double volatile nan = NaNd (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'double' NaN with sign bit == 1. */ +_GL_UNUSED static double +negative_NaNd () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + double volatile nan = NaNd (); + return (signbit (nan) ? nan : - nan); +} + + +/* Returns a quiet 'long double' NaN with sign bit == 0. */ +_GL_UNUSED static long double +positive_NaNl () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + long double volatile nan = NaNl (); + return (signbit (nan) ? - nan : nan); +} + +/* Returns a quiet 'long double' NaN with sign bit == 1. */ +_GL_UNUSED static long double +negative_NaNl () +{ + /* 'volatile' works around a GCC bug: + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */ + long double volatile nan = NaNl (); + return (signbit (nan) ? nan : - nan); +} + + +#endif /* _SIGNED_NAN_H */ diff --git a/modules/qnan b/modules/qnan deleted file mode 100644 index fd3cbb5097..0000000000 --- a/modules/qnan +++ /dev/null @@ -1,25 +0,0 @@ -Description: -Macros for quiet not-a-number. - -Files: -lib/qnan.h - -Depends-on: -nan -signbit - -configure.ac: - -Makefile.am: -lib_SOURCES += qnan.h - -Include: -"qnan.h" - -Link: - -License: -GPL - -Maintainer: -all diff --git a/modules/signbit-tests b/modules/signbit-tests index c491d7c885..20b18efdf0 100644 --- a/modules/signbit-tests +++ b/modules/signbit-tests @@ -6,7 +6,7 @@ tests/macros.h Depends-on: float -qnan +signed-nan snan configure.ac: diff --git a/modules/signed-nan b/modules/signed-nan new file mode 100644 index 0000000000..f544a6c58c --- /dev/null +++ b/modules/signed-nan @@ -0,0 +1,25 @@ +Description: +Macros for quiet not-a-number. + +Files: +lib/signed-nan.h + +Depends-on: +nan +signbit + +configure.ac: + +Makefile.am: +lib_SOURCES += signed-nan.h + +Include: +"signed-nan.h" + +Link: + +License: +GPL + +Maintainer: +all diff --git a/modules/stdio-tests b/modules/stdio-tests index 5f94d3961d..a24433f511 100644 --- a/modules/stdio-tests +++ b/modules/stdio-tests @@ -5,7 +5,7 @@ m4/exponentd.m4 Depends-on: assert-h -qnan +signed-nan snan stdio-c++-tests fgetc-tests diff --git a/modules/totalorder-tests b/modules/totalorder-tests index 5ff4c752f0..3741b88d4c 100644 --- a/modules/totalorder-tests +++ b/modules/totalorder-tests @@ -5,7 +5,7 @@ tests/infinity.h tests/macros.h Depends-on: -qnan +signed-nan configure.ac: diff --git a/modules/totalorderf-tests b/modules/totalorderf-tests index 7e2e7938f6..f2801f496f 100644 --- a/modules/totalorderf-tests +++ b/modules/totalorderf-tests @@ -6,7 +6,7 @@ tests/infinity.h tests/macros.h Depends-on: -qnan +signed-nan configure.ac: diff --git a/modules/totalorderl-tests b/modules/totalorderl-tests index 1b6ca5200f..fa25c3e301 100644 --- a/modules/totalorderl-tests +++ b/modules/totalorderl-tests @@ -6,7 +6,7 @@ tests/infinity.h tests/macros.h Depends-on: -qnan +signed-nan configure.ac: diff --git a/tests/test-signbit.c b/tests/test-signbit.c index f89fdf6d05..35b845c6c3 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -30,7 +30,7 @@ #include "minus-zero.h" #include "infinity.h" -#include "qnan.h" +#include "signed-nan.h" #include "snan.h" #include "macros.h" diff --git a/tests/test-stdio.c b/tests/test-stdio.c index cc44250150..6bd100edae 100644 --- a/tests/test-stdio.c +++ b/tests/test-stdio.c @@ -39,7 +39,7 @@ va_list t5; #include <string.h> -#include "qnan.h" +#include "signed-nan.h" #include "snan.h" #include "macros.h" diff --git a/tests/test-totalorder.c b/tests/test-totalorder.c index b63c7c2211..af903c68b5 100644 --- a/tests/test-totalorder.c +++ b/tests/test-totalorder.c @@ -21,7 +21,7 @@ #include "infinity.h" #include "macros.h" #include "minus-zero.h" -#include "qnan.h" +#include "signed-nan.h" #ifndef TOTALORDER # define TOTALORDER totalorder