[libc-commits] [libc] [llvm] [libc] Refactor llogbl to be header-only and constexpr (PR #175376)

Mathew Joseph via libc-commits libc-commits at lists.llvm.org
Mon Jan 19 08:13:07 PST 2026


https://github.com/mathew1046 updated https://github.com/llvm/llvm-project/pull/175376

>From 7019db02d7eb906bf7b02a42b0d420cc3f2bcb9a Mon Sep 17 00:00:00 2001
From: Mathew Joseph <mathewjosephparakka at gmail.com>
Date: Sun, 11 Jan 2026 00:22:20 +0530
Subject: [PATCH 1/6] [libc] Refactor llogbl to be header-only and constexpr

Refactor the llogbl (log base 2 of absolute value for long double) function
to be header-only and marked constexpr, enabling compile-time evaluation and
inlining opportunities while maintaining binary compatibility.

Changes:
1. Move the implementation into libc/src/math/llogbl.h as an inline constexpr
   function that delegates to the existing fputil::intlogb<long> template
   (which is already constexpr-compatible).

2. Simplify libc/src/math/generic/llogbl.cpp to be a thin wrapper that exports
   the public C symbol via LLVM_LIBC_FUNCTION, ensuring binary compatibility
   with shipped libc libraries.

3. Add constexpr compile-time tests (static_assert) in the test file to verify
   that llogbl can be evaluated at compile time for normal numbers with various
   exponents (powers of 2 from 2^-1 to 2^10).

4. The underlying fputil::intlogb<long> already handles constexpr evaluation
   correctly for all cases (zero, NaN, infinity, subnormals) by using
   is_constant_evaluated() to skip errno/FE flag operations at compile time.

Benefits:
- Callers can now use constexpr long result = llogbl(2.0L); at compile time
- Compiler can inline the function for better optimization
- No ABI changes; binary compatibility is maintained
- No platform-specific issues; inherits robust handling from fputil

Fixes: https://github.com/llvm/llvm-project/issues/175361
Signed-off-by: Mathew Joseph <mathewjosephparakka at gmail.com>
---
 libc/src/math/generic/llogbl.cpp         |  9 +++----
 libc/src/math/llogbl.h                   |  7 ++++-
 libc/test/src/math/smoke/llogbl_test.cpp | 34 ++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/libc/src/math/generic/llogbl.cpp b/libc/src/math/generic/llogbl.cpp
index 7ee3ac55653b6..73a104de57357 100644
--- a/libc/src/math/generic/llogbl.cpp
+++ b/libc/src/math/generic/llogbl.cpp
@@ -7,14 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llogbl.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) {
-  return fputil::intlogb<long>(x);
-}
+// Export the public C symbol by wrapping the inline constexpr definition.
+// This maintains binary compatibility with the shipped libc while allowing
+// callers to evaluate llogbl at compile time or have it inlined.
+LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) { return llogbl(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/llogbl.h b/libc/src/math/llogbl.h
index bf502a1c0bc3b..4a45eb6f1d895 100644
--- a/libc/src/math/llogbl.h
+++ b/libc/src/math/llogbl.h
@@ -9,12 +9,17 @@
 #ifndef LLVM_LIBC_SRC_MATH_LLOGBL_H
 #define LLVM_LIBC_SRC_MATH_LLOGBL_H
 
+#include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/types.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-long llogbl(long double x);
+// Inline constexpr implementation: extract the unbiased exponent of a long double
+// by delegating to the existing constexpr template fputil::intlogb<long>.
+LIBC_INLINE constexpr long llogbl(long double x) {
+  return fputil::intlogb<long>(x);
+}
 
 } // namespace LIBC_NAMESPACE_DECL
 
diff --git a/libc/test/src/math/smoke/llogbl_test.cpp b/libc/test/src/math/smoke/llogbl_test.cpp
index c698210fc3de1..20332bfd6776b 100644
--- a/libc/test/src/math/smoke/llogbl_test.cpp
+++ b/libc/test/src/math/smoke/llogbl_test.cpp
@@ -11,3 +11,37 @@
 #include "src/math/llogbl.h"
 
 LIST_INTLOGB_TESTS(long, long double, LIBC_NAMESPACE::llogbl);
+
+// Constexpr tests: verify that llogbl can be evaluated at compile time.
+// These static_assert cases cover normal numbers with various exponents.
+namespace {
+class LLogblConstexprTest : public LIBC_NAMESPACE::testing::Test {
+public:
+  void RunTests() {
+    // Normal numbers: 2^0 = 1.0 => exponent 0
+    static_assert(LIBC_NAMESPACE::llogbl(1.0L) == 0);
+    static_assert(LIBC_NAMESPACE::llogbl(-1.0L) == 0);
+
+    // Normal numbers: 2^1 = 2.0 => exponent 1
+    static_assert(LIBC_NAMESPACE::llogbl(2.0L) == 1);
+    static_assert(LIBC_NAMESPACE::llogbl(-2.0L) == 1);
+
+    // Normal numbers: 2^2 = 4.0 => exponent 2
+    static_assert(LIBC_NAMESPACE::llogbl(4.0L) == 2);
+    static_assert(LIBC_NAMESPACE::llogbl(-4.0L) == 2);
+
+    // Normal numbers: 2^(-1) = 0.5 => exponent -1
+    static_assert(LIBC_NAMESPACE::llogbl(0.5L) == -1);
+    static_assert(LIBC_NAMESPACE::llogbl(-0.5L) == -1);
+
+    // Normal numbers: 2^3 = 8.0 => exponent 3
+    static_assert(LIBC_NAMESPACE::llogbl(8.0L) == 3);
+
+    // Normal numbers: 2^10 = 1024.0 => exponent 10
+    static_assert(LIBC_NAMESPACE::llogbl(1024.0L) == 10);
+  }
+};
+
+// Instantiate the test to trigger static_asserts at compile time.
+LLogblConstexprTest constexpr_test;
+} // anonymous namespace

>From 7386cfa52ed656f71d8c713873d9822c4d27f318 Mon Sep 17 00:00:00 2001
From: Mathew Joseph <69132893+mathew1046 at users.noreply.github.com>
Date: Sun, 11 Jan 2026 00:45:07 +0530
Subject: [PATCH 2/6] Update libc/test/src/math/smoke/llogbl_test.cpp

Co-authored-by: Copilot <175728472+Copilot at users.noreply.github.com>
---
 libc/test/src/math/smoke/llogbl_test.cpp | 51 ++++++++++--------------
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/libc/test/src/math/smoke/llogbl_test.cpp b/libc/test/src/math/smoke/llogbl_test.cpp
index 20332bfd6776b..5558960beabd1 100644
--- a/libc/test/src/math/smoke/llogbl_test.cpp
+++ b/libc/test/src/math/smoke/llogbl_test.cpp
@@ -15,33 +15,26 @@ LIST_INTLOGB_TESTS(long, long double, LIBC_NAMESPACE::llogbl);
 // Constexpr tests: verify that llogbl can be evaluated at compile time.
 // These static_assert cases cover normal numbers with various exponents.
 namespace {
-class LLogblConstexprTest : public LIBC_NAMESPACE::testing::Test {
-public:
-  void RunTests() {
-    // Normal numbers: 2^0 = 1.0 => exponent 0
-    static_assert(LIBC_NAMESPACE::llogbl(1.0L) == 0);
-    static_assert(LIBC_NAMESPACE::llogbl(-1.0L) == 0);
-
-    // Normal numbers: 2^1 = 2.0 => exponent 1
-    static_assert(LIBC_NAMESPACE::llogbl(2.0L) == 1);
-    static_assert(LIBC_NAMESPACE::llogbl(-2.0L) == 1);
-
-    // Normal numbers: 2^2 = 4.0 => exponent 2
-    static_assert(LIBC_NAMESPACE::llogbl(4.0L) == 2);
-    static_assert(LIBC_NAMESPACE::llogbl(-4.0L) == 2);
-
-    // Normal numbers: 2^(-1) = 0.5 => exponent -1
-    static_assert(LIBC_NAMESPACE::llogbl(0.5L) == -1);
-    static_assert(LIBC_NAMESPACE::llogbl(-0.5L) == -1);
-
-    // Normal numbers: 2^3 = 8.0 => exponent 3
-    static_assert(LIBC_NAMESPACE::llogbl(8.0L) == 3);
-
-    // Normal numbers: 2^10 = 1024.0 => exponent 10
-    static_assert(LIBC_NAMESPACE::llogbl(1024.0L) == 10);
-  }
-};
-
-// Instantiate the test to trigger static_asserts at compile time.
-LLogblConstexprTest constexpr_test;
+
+// Normal numbers: 2^0 = 1.0 => exponent 0
+static_assert(LIBC_NAMESPACE::llogbl(1.0L) == 0);
+static_assert(LIBC_NAMESPACE::llogbl(-1.0L) == 0);
+
+// Normal numbers: 2^1 = 2.0 => exponent 1
+static_assert(LIBC_NAMESPACE::llogbl(2.0L) == 1);
+static_assert(LIBC_NAMESPACE::llogbl(-2.0L) == 1);
+
+// Normal numbers: 2^2 = 4.0 => exponent 2
+static_assert(LIBC_NAMESPACE::llogbl(4.0L) == 2);
+static_assert(LIBC_NAMESPACE::llogbl(-4.0L) == 2);
+
+// Normal numbers: 2^(-1) = 0.5 => exponent -1
+static_assert(LIBC_NAMESPACE::llogbl(0.5L) == -1);
+static_assert(LIBC_NAMESPACE::llogbl(-0.5L) == -1);
+
+// Normal numbers: 2^3 = 8.0 => exponent 3
+static_assert(LIBC_NAMESPACE::llogbl(8.0L) == 3);
+
+// Normal numbers: 2^10 = 1024.0 => exponent 10
+static_assert(LIBC_NAMESPACE::llogbl(1024.0L) == 10);
 } // anonymous namespace

>From 355026640bdc25603395f20c04f3d73b55d9f181 Mon Sep 17 00:00:00 2001
From: Mathew Joseph <69132893+mathew1046 at users.noreply.github.com>
Date: Sun, 11 Jan 2026 00:45:22 +0530
Subject: [PATCH 3/6] Update libc/src/math/generic/llogbl.cpp

Co-authored-by: Copilot <175728472+Copilot at users.noreply.github.com>
---
 libc/src/math/generic/llogbl.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libc/src/math/generic/llogbl.cpp b/libc/src/math/generic/llogbl.cpp
index 73a104de57357..6fa675f566755 100644
--- a/libc/src/math/generic/llogbl.cpp
+++ b/libc/src/math/generic/llogbl.cpp
@@ -14,6 +14,8 @@ namespace LIBC_NAMESPACE_DECL {
 // Export the public C symbol by wrapping the inline constexpr definition.
 // This maintains binary compatibility with the shipped libc while allowing
 // callers to evaluate llogbl at compile time or have it inlined.
-LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) { return llogbl(x); }
+LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) {
+  return LIBC_NAMESPACE::llogbl(x);
+}
 
 } // namespace LIBC_NAMESPACE_DECL

>From 238d90f8ed778b54f795b7e5a7e4314ebbeac963 Mon Sep 17 00:00:00 2001
From: Mathew Joseph <mathewjosephparakka at gmail.com>
Date: Fri, 16 Jan 2026 16:53:03 +0530
Subject: [PATCH 4/6] fix: [libc][math] Refactor llogbl implementation to
 header-only in src/__support/math folder

---
 libc/shared/math.h                            |  1 +
 libc/shared/math/llogbl.h                     | 23 ++++++++++++++++
 libc/src/__support/math/CMakeLists.txt        |  8 ++++++
 libc/src/__support/math/llogbl.h              | 27 +++++++++++++++++++
 libc/src/math/generic/CMakeLists.txt          |  2 +-
 libc/src/math/generic/llogbl.cpp              |  8 ++----
 libc/src/math/llogbl.h                        |  8 +-----
 libc/test/shared/CMakeLists.txt               |  1 +
 libc/test/shared/shared_math_test.cpp         |  1 +
 libc/test/src/math/smoke/llogbl_test.cpp      | 21 ++++++++-------
 .../llvm-project-overlay/libc/BUILD.bazel     | 15 ++++++++++-
 11 files changed, 90 insertions(+), 25 deletions(-)
 create mode 100644 libc/shared/math/llogbl.h
 create mode 100644 libc/src/__support/math/llogbl.h

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 7fb4c43f509c4..f1b37bf6905ee 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -63,6 +63,7 @@
 #include "math/ldexpf.h"
 #include "math/ldexpf128.h"
 #include "math/ldexpf16.h"
+#include "math/llogbl.h"
 #include "math/rsqrtf.h"
 #include "math/rsqrtf16.h"
 #include "math/sin.h"
diff --git a/libc/shared/math/llogbl.h b/libc/shared/math/llogbl.h
new file mode 100644
index 0000000000000..3135787e08d2f
--- /dev/null
+++ b/libc/shared/math/llogbl.h
@@ -0,0 +1,23 @@
+//===-- Shared llogbl function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLOGBL_H
+#define LLVM_LIBC_SHARED_MATH_LLOGBL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/llogbl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::llogbl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLOGBL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 741da7432c94f..de978acbd3af3 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -659,6 +659,14 @@ add_header_library(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_header_library(
+  llogbl
+  HDRS
+    llogbl.h
+  DEPENDS
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_header_library(
   exp_constants
   HDRS
diff --git a/libc/src/__support/math/llogbl.h b/libc/src/__support/math/llogbl.h
new file mode 100644
index 0000000000000..03230f14313a4
--- /dev/null
+++ b/libc/src/__support/math/llogbl.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for llogbl ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBL_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr long llogbl(long double x) {
+  return fputil::intlogb<long>(x);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 9c0da076b6cf0..90a896d1db324 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1848,7 +1848,7 @@ add_entrypoint_object(
   HDRS
     ../llogbl.h
   DEPENDS
-    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.math.llogbl
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/llogbl.cpp b/libc/src/math/generic/llogbl.cpp
index 6fa675f566755..2cf1851f77945 100644
--- a/libc/src/math/generic/llogbl.cpp
+++ b/libc/src/math/generic/llogbl.cpp
@@ -8,14 +8,10 @@
 
 #include "src/math/llogbl.h"
 #include "src/__support/common.h"
+#include "src/__support/math/llogbl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-// Export the public C symbol by wrapping the inline constexpr definition.
-// This maintains binary compatibility with the shipped libc while allowing
-// callers to evaluate llogbl at compile time or have it inlined.
-LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) {
-  return LIBC_NAMESPACE::llogbl(x);
-}
+LLVM_LIBC_FUNCTION(long, llogbl, (long double x)) { return math::llogbl(x); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/llogbl.h b/libc/src/math/llogbl.h
index 4a45eb6f1d895..028bf1958c4ff 100644
--- a/libc/src/math/llogbl.h
+++ b/libc/src/math/llogbl.h
@@ -9,17 +9,11 @@
 #ifndef LLVM_LIBC_SRC_MATH_LLOGBL_H
 #define LLVM_LIBC_SRC_MATH_LLOGBL_H
 
-#include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-// Inline constexpr implementation: extract the unbiased exponent of a long double
-// by delegating to the existing constexpr template fputil::intlogb<long>.
-LIBC_INLINE constexpr long llogbl(long double x) {
-  return fputil::intlogb<long>(x);
-}
+long llogbl(long double x);
 
 } // namespace LIBC_NAMESPACE_DECL
 
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 0f23162798a8b..4b488ef2b569e 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -59,6 +59,7 @@ add_fp_unittest(
     libc.src.__support.math.ldexpf
     libc.src.__support.math.ldexpf128
     libc.src.__support.math.ldexpf16
+    libc.src.__support.math.llogbl
     libc.src.__support.math.rsqrtf
     libc.src.__support.math.rsqrtf16
     libc.src.__support.math.sin
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index f823d414e2afd..dae1c0b9107b1 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -90,6 +90,7 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
   EXPECT_FP_EQ(0x1p+0, LIBC_NAMESPACE::shared::exp2(0.0));
   EXPECT_FP_EQ(0x1p+0, LIBC_NAMESPACE::shared::exp10(0.0));
   EXPECT_FP_EQ(0x0p+0, LIBC_NAMESPACE::shared::expm1(0.0));
+  EXPECT_EQ(0, LIBC_NAMESPACE::shared::llogbl(1.0L));
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::sin(0.0));
 }
 
diff --git a/libc/test/src/math/smoke/llogbl_test.cpp b/libc/test/src/math/smoke/llogbl_test.cpp
index 5558960beabd1..bbcda099e12c0 100644
--- a/libc/test/src/math/smoke/llogbl_test.cpp
+++ b/libc/test/src/math/smoke/llogbl_test.cpp
@@ -9,6 +9,7 @@
 #include "ILogbTest.h"
 
 #include "src/math/llogbl.h"
+#include "src/__support/math/llogbl.h"
 
 LIST_INTLOGB_TESTS(long, long double, LIBC_NAMESPACE::llogbl);
 
@@ -17,24 +18,24 @@ LIST_INTLOGB_TESTS(long, long double, LIBC_NAMESPACE::llogbl);
 namespace {
 
 // Normal numbers: 2^0 = 1.0 => exponent 0
-static_assert(LIBC_NAMESPACE::llogbl(1.0L) == 0);
-static_assert(LIBC_NAMESPACE::llogbl(-1.0L) == 0);
+static_assert(LIBC_NAMESPACE::math::llogbl(1.0L) == 0);
+static_assert(LIBC_NAMESPACE::math::llogbl(-1.0L) == 0);
 
 // Normal numbers: 2^1 = 2.0 => exponent 1
-static_assert(LIBC_NAMESPACE::llogbl(2.0L) == 1);
-static_assert(LIBC_NAMESPACE::llogbl(-2.0L) == 1);
+static_assert(LIBC_NAMESPACE::math::llogbl(2.0L) == 1);
+static_assert(LIBC_NAMESPACE::math::llogbl(-2.0L) == 1);
 
 // Normal numbers: 2^2 = 4.0 => exponent 2
-static_assert(LIBC_NAMESPACE::llogbl(4.0L) == 2);
-static_assert(LIBC_NAMESPACE::llogbl(-4.0L) == 2);
+static_assert(LIBC_NAMESPACE::math::llogbl(4.0L) == 2);
+static_assert(LIBC_NAMESPACE::math::llogbl(-4.0L) == 2);
 
 // Normal numbers: 2^(-1) = 0.5 => exponent -1
-static_assert(LIBC_NAMESPACE::llogbl(0.5L) == -1);
-static_assert(LIBC_NAMESPACE::llogbl(-0.5L) == -1);
+static_assert(LIBC_NAMESPACE::math::llogbl(0.5L) == -1);
+static_assert(LIBC_NAMESPACE::math::llogbl(-0.5L) == -1);
 
 // Normal numbers: 2^3 = 8.0 => exponent 3
-static_assert(LIBC_NAMESPACE::llogbl(8.0L) == 3);
+static_assert(LIBC_NAMESPACE::math::llogbl(8.0L) == 3);
 
 // Normal numbers: 2^10 = 1024.0 => exponent 10
-static_assert(LIBC_NAMESPACE::llogbl(1024.0L) == 10);
+static_assert(LIBC_NAMESPACE::math::llogbl(1024.0L) == 10);
 } // anonymous namespace
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 210c25dddd0b9..27374b7da950d 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -2870,6 +2870,14 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_llogbl",
+    hdrs = ["src/__support/math/llogbl.h"],
+    deps = [
+        ":__support_fputil_manipulation_functions",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_exp_constants",
     hdrs = ["src/__support/math/exp_constants.h"],
@@ -4341,7 +4349,12 @@ libc_math_function(name = "llogb")
 
 libc_math_function(name = "llogbf")
 
-libc_math_function(name = "llogbl")
+libc_math_function(
+    name = "llogbl",
+    additional_deps = [
+        ":__support_math_llogbl",
+    ],
+)
 
 libc_math_function(name = "llogbf128")
 

>From 46e8cb05655cbc460576c63105be9b39b4b95a5b Mon Sep 17 00:00:00 2001
From: Mathew Joseph <69132893+mathew1046 at users.noreply.github.com>
Date: Mon, 19 Jan 2026 21:41:58 +0530
Subject: [PATCH 5/6] Delete libc/test/src/math/smoke/llogbl_test.cpp

---
 libc/test/src/math/smoke/llogbl_test.cpp | 41 ------------------------
 1 file changed, 41 deletions(-)
 delete mode 100644 libc/test/src/math/smoke/llogbl_test.cpp

diff --git a/libc/test/src/math/smoke/llogbl_test.cpp b/libc/test/src/math/smoke/llogbl_test.cpp
deleted file mode 100644
index bbcda099e12c0..0000000000000
--- a/libc/test/src/math/smoke/llogbl_test.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//===-- Unittests for llogbl ----------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "ILogbTest.h"
-
-#include "src/math/llogbl.h"
-#include "src/__support/math/llogbl.h"
-
-LIST_INTLOGB_TESTS(long, long double, LIBC_NAMESPACE::llogbl);
-
-// Constexpr tests: verify that llogbl can be evaluated at compile time.
-// These static_assert cases cover normal numbers with various exponents.
-namespace {
-
-// Normal numbers: 2^0 = 1.0 => exponent 0
-static_assert(LIBC_NAMESPACE::math::llogbl(1.0L) == 0);
-static_assert(LIBC_NAMESPACE::math::llogbl(-1.0L) == 0);
-
-// Normal numbers: 2^1 = 2.0 => exponent 1
-static_assert(LIBC_NAMESPACE::math::llogbl(2.0L) == 1);
-static_assert(LIBC_NAMESPACE::math::llogbl(-2.0L) == 1);
-
-// Normal numbers: 2^2 = 4.0 => exponent 2
-static_assert(LIBC_NAMESPACE::math::llogbl(4.0L) == 2);
-static_assert(LIBC_NAMESPACE::math::llogbl(-4.0L) == 2);
-
-// Normal numbers: 2^(-1) = 0.5 => exponent -1
-static_assert(LIBC_NAMESPACE::math::llogbl(0.5L) == -1);
-static_assert(LIBC_NAMESPACE::math::llogbl(-0.5L) == -1);
-
-// Normal numbers: 2^3 = 8.0 => exponent 3
-static_assert(LIBC_NAMESPACE::math::llogbl(8.0L) == 3);
-
-// Normal numbers: 2^10 = 1024.0 => exponent 10
-static_assert(LIBC_NAMESPACE::math::llogbl(1024.0L) == 10);
-} // anonymous namespace

>From dff9319e05ab25786b7351d3419b710ab5007a66 Mon Sep 17 00:00:00 2001
From: Mathew Joseph <69132893+mathew1046 at users.noreply.github.com>
Date: Mon, 19 Jan 2026 21:42:56 +0530
Subject: [PATCH 6/6] Add include for types in llogbl.h

---
 libc/src/math/llogbl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/src/math/llogbl.h b/libc/src/math/llogbl.h
index 028bf1958c4ff..bf502a1c0bc3b 100644
--- a/libc/src/math/llogbl.h
+++ b/libc/src/math/llogbl.h
@@ -10,6 +10,7 @@
 #define LLVM_LIBC_SRC_MATH_LLOGBL_H
 
 #include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
 
 namespace LIBC_NAMESPACE_DECL {
 



More information about the libc-commits mailing list