From 09ef9756f22a8c4143c6b8d3afcddc72fb700c76 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Sat, 16 Nov 2024 17:04:38 +0100
Subject: [PATCH] libgcc: Fix a warning/error in libgcc2.c [PR117624]

Since the switch to -std=gnu23 by default, float.h (included from
tsystem.h) defines INFINITY macro (to __builtin_inff ()), which now
results in a warning when compiling libgcc2.c which defines it
to something else (and, worse aarch64 compiles it with -Werror and
build fails).
libgcc2.c asserts INFINITY has the expected type which depends on
the macros with which libgcc2.c is being compiled, so guarding
the define with #ifndef INFINITY wouldn't work.
So this patch instead #undefs the macro before defining it.

2024-11-16  Jakub Jelinek  <jakub@redhat.com>

	PR libgcc/117624
	* libgcc2.c (INFINITY): Add #undef before #define.
---
 libgcc/libgcc2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c
index 3fcb85c5b92e..27959a6e0f25 100644
--- a/libgcc/libgcc2.c
+++ b/libgcc/libgcc2.c
@@ -2673,6 +2673,7 @@ NAME (TYPE x, int m)
 #define isfinite(x)	__builtin_isfinite (x)
 #define isinf(x)	__builtin_isinf (x)
 
+#undef INFINITY
 #define INFINITY	CONCAT2(__builtin_huge_val, CEXT) ()
 #define I		1i
 
-- 
GitLab