[libc-commits] [libc] [llvm] [libc][math] Refactor sqrt to header-only (PR #178335)
Muhammad Bassiouni via libc-commits
libc-commits at lists.llvm.org
Wed Jan 28 15:57:16 PST 2026
================
@@ -0,0 +1,26 @@
+//===-- Implementation header for sqrt --------------------------*- 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_SQRT_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SQRT_H
+
+#include "src/__support/FPUtil/sqrt.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static constexpr double sqrt(double x) {
+ return fputil::sqrt<double>(x);
+}
----------------
bassiounix wrote:
I suspect that there might be situations where `sqrt` may not be `constexpr` qualified, so I'd suggest:
```suggestion
LIBC_INLINE static double sqrt(double x) {
return fputil::sqrt<double>(x);
}
```
https://github.com/llvm/llvm-project/pull/178335
More information about the libc-commits
mailing list