aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-12-15 09:56:34 +0800
committerH.J. Lu <hjl.tools@gmail.com>2024-12-22 12:44:42 +0800
commitbdc7f4b4e25f49b4e25578d98d58b113d0e961f1 (patch)
treef47e1799aaea3e0f20fe5d81c8c6d98d63f0c3f8 /math
parent6d9d7865d029e94d1aee24c609f4d222d0620fff (diff)
downloadglibc-bdc7f4b4e25f49b4e25578d98d58b113d0e961f1.tar.xz
glibc-bdc7f4b4e25f49b4e25578d98d58b113d0e961f1.zip
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>
Diffstat (limited to 'math')
-rw-r--r--math/math.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/math/math.h b/math/math.h
index 599ca3ae79..5e085fdf9a 100644
--- a/math/math.h
+++ b/math/math.h
@@ -87,20 +87,24 @@ __BEGIN_DECLS
#ifdef __USE_ISOC99
/* IEEE positive infinity. */
-# if __GNUC_PREREQ (3, 3)
-# define INFINITY (__builtin_inff ())
-# else
-# define INFINITY HUGE_VALF
+# ifndef INFINITY
+# if __GNUC_PREREQ (3, 3)
+# define INFINITY (__builtin_inff ())
+# else
+# define INFINITY HUGE_VALF
+# endif
# endif
/* IEEE Not A Number. */
-# if __GNUC_PREREQ (3, 3)
-# define NAN (__builtin_nanf (""))
-# else
+# ifndef NAN
+# if __GNUC_PREREQ (3, 3)
+# define NAN (__builtin_nanf (""))
+# else
/* This will raise an "invalid" exception outside static initializers,
but is the best that can be done in ISO C while remaining a
constant expression. */
-# define NAN (0.0f / 0.0f)
+# define NAN (0.0f / 0.0f)
+# endif
# endif
#endif /* __USE_ISOC99 */