aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jones <michaelrj@google.com>2024-03-27 15:09:57 -0700
committerGitHub <noreply@github.com>2024-03-27 15:09:57 -0700
commitd5f06342a3007f414c783ba42cb49453a9cee835 (patch)
tree57d9188008a3a501527902b64bb9becda5d03574
parent88812819022ecff392dfc8d3f964899f63bdffdb (diff)
downloadllvm-d5f06342a3007f414c783ba42cb49453a9cee835.zip
llvm-d5f06342a3007f414c783ba42cb49453a9cee835.tar.gz
llvm-d5f06342a3007f414c783ba42cb49453a9cee835.tar.bz2
[libc] add flag for FP_*LOGB0/NAN values (#86723)
These values vary by system, this flag allows you to toggle their value.
-rw-r--r--libc/include/llvm-libc-macros/math-macros.h9
-rw-r--r--utils/bazel/llvm-project-overlay/libc/BUILD.bazel1
2 files changed, 8 insertions, 2 deletions
diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index 03c7a82..1497e32 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -31,10 +31,15 @@
#define NAN __builtin_nanf("")
#define FP_ILOGB0 (-INT_MAX - 1)
-#define FP_ILOGBNAN INT_MAX
-
#define FP_LLOGB0 (-LONG_MAX - 1)
+
+#ifdef __FP_LOGBNAN_MIN
+#define FP_ILOGBNAN (-INT_MAX - 1)
+#define FP_LLOGBNAN (-LONG_MAX - 1)
+#else
+#define FP_ILOGBNAN INT_MAX
#define FP_LLOGBNAN LONG_MAX
+#endif
#ifdef __FAST_MATH__
#define math_errhandling 0
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index eb0afbb..acdf934 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -68,6 +68,7 @@ libc_support_library(
name = "llvm_libc_macros_math_macros",
hdrs = ["include/llvm-libc-macros/math-macros.h"],
deps = [":llvm_libc_macros_limits_macros"],
+ defines = ["__FP_LOGBNAN_MIN"],
)
libc_support_library(