[libc-commits] [libc] [libc] Fix `INFINITY` being defined as a double (PR #103445)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Tue Aug 13 13:52:00 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/103445

Summary:
If the implementation supports floating-point infinities, the macro
INFINITY expands to constant expression of type float which evaluates to
positive or unsigned infinity.

Currently this is a double, this makes it a float.


>From 4b604270d72c77d22cfcffdefbecd6e2c3fce332 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 13 Aug 2024 15:49:45 -0500
Subject: [PATCH] [libc] Fix `INFINITY` being defined as a double

Summary:
If the implementation supports floating-point infinities, the macro
INFINITY expands to constant expression of type float which evaluates to
positive or unsigned infinity.

Currently this is a double, this makes it a float.
---
 libc/include/llvm-libc-macros/math-macros.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index 0ceb2c5c8202b0..2f05d7544666e6 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -28,7 +28,7 @@
 
 #define HUGE_VAL __builtin_huge_val()
 #define HUGE_VALF __builtin_huge_valf()
-#define INFINITY __builtin_inf()
+#define INFINITY __builtin_inff()
 #define NAN __builtin_nanf("")
 
 #define FP_ILOGB0 (-INT_MAX - 1)



More information about the libc-commits mailing list