Don't redefine INFINITY nor NAN

Since math/math.h isn't a system header, clang issues errors:

In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:91:11: error: 'INFINITY' macro redefined [-Werror,-Wmacro-redefined]
   91 | #  define INFINITY (__builtin_inff ())
      |           ^
/usr/bin/../lib/clang/19/include/float.h:173:11: note: previous definition is here
  173 | #  define INFINITY (__builtin_inff())
      |           ^
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:98:11: error: 'NAN' macro redefined [-Werror,-Wmacro-redefined]
   98 | #  define NAN (__builtin_nanf (""))
      |           ^
/usr/bin/../lib/clang/19/include/float.h:174:11: note: previous definition is here
  174 | #  define NAN (__builtin_nanf(""))

Don't define INFINITY nor NAN if they are defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
H.J. Lu 2024-12-15 09:56:34 +08:00
parent 6d9d7865d0
commit bdc7f4b4e2
1 changed files with 12 additions and 8 deletions

View File

@ -87,13 +87,16 @@ __BEGIN_DECLS
#ifdef __USE_ISOC99
/* IEEE positive infinity. */
# ifndef INFINITY
# if __GNUC_PREREQ (3, 3)
# define INFINITY (__builtin_inff ())
# else
# define INFINITY HUGE_VALF
# endif
# endif
/* IEEE Not A Number. */
# ifndef NAN
# if __GNUC_PREREQ (3, 3)
# define NAN (__builtin_nanf (""))
# else
@ -102,6 +105,7 @@ __BEGIN_DECLS
constant expression. */
# define NAN (0.0f / 0.0f)
# endif
# endif
#endif /* __USE_ISOC99 */
#if __GLIBC_USE (IEC_60559_BFP_EXT)