[libcxx-commits] [libcxx] 8d47bda - [libc++] Move math special functions under __cmath (#213944)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 5 02:58:14 PDT 2026
Author: Louis Dionne
Date: 2026-08-05T05:58:10-04:00
New Revision: 8d47bda9cd1ab5ab27295ed15eaded4084c6201c
URL: https://github.com/llvm/llvm-project/commit/8d47bda9cd1ab5ab27295ed15eaded4084c6201c
DIFF: https://github.com/llvm/llvm-project/commit/8d47bda9cd1ab5ab27295ed15eaded4084c6201c.diff
LOG: [libc++] Move math special functions under __cmath (#213944)
It was always a bit weird that these were the only functions under
__math/ which were not in the __math namespace and were not in the
global namespace. This also led to a workaround in the C++20 modules
testing.
Instead, move math special functions under __cmath/, which will contain
APIs that are part of `<cmath>` but not `<math.h>`.
Added:
libcxx/include/__cmath/special_functions.h
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/cmath
libcxx/include/module.modulemap.in
libcxx/utils/libcxx/test/modules.py
Removed:
libcxx/include/__math/special_functions.h
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 98b09b9dcf8ae..7f47c51fb10ac 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -294,6 +294,7 @@ set(files
__chrono/year_month_day.h
__chrono/year_month_weekday.h
__chrono/zoned_time.h
+ __cmath/special_functions.h
__compare/common_comparison_category.h
__compare/compare_partial_order_fallback.h
__compare/compare_strong_order_fallback.h
@@ -587,7 +588,6 @@ set(files
__math/remainder.h
__math/roots.h
__math/rounding_functions.h
- __math/special_functions.h
__math/traits.h
__math/trigonometric_functions.h
__mbstate_t.h
diff --git a/libcxx/include/__math/special_functions.h b/libcxx/include/__cmath/special_functions.h
similarity index 95%
rename from libcxx/include/__math/special_functions.h
rename to libcxx/include/__cmath/special_functions.h
index 64d16aa88d2ee..070272a2886c9 100644
--- a/libcxx/include/__math/special_functions.h
+++ b/libcxx/include/__cmath/special_functions.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
-#define _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
+#ifndef _LIBCPP___CMATH_SPECIAL_FUNCTIONS_H
+#define _LIBCPP___CMATH_SPECIAL_FUNCTIONS_H
#include <__config>
#include <__math/copysign.h>
@@ -81,4 +81,4 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 17
-#endif // _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
+#endif // _LIBCPP___CMATH_SPECIAL_FUNCTIONS_H
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index bf87509b30fdc..a4139fb8181f8 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -323,7 +323,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
# include <__type_traits/promote.h>
# include <version>
-# include <__math/special_functions.h>
+# include <__cmath/special_functions.h>
# include <math.h>
# ifndef _LIBCPP_MATH_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 41c1ac1595234..a15b2dd08f634 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -19,6 +19,10 @@ module std_config {
}
module std_core {
+ module cmath {
+ module special_functions { header "__cmath/special_functions.h" }
+ }
+
module cstddef {
module byte { header "__cstddef/byte.h" }
module max_align_t {
@@ -65,7 +69,6 @@ module std_core {
module remainder { header "__math/remainder.h" }
module roots { header "__math/roots.h" }
module rounding_functions { header "__math/rounding_functions.h" }
- module special_functions { header "__math/special_functions.h" }
module traits { header "__math/traits.h" }
module trigonometric_functions { header "__math/trigonometric_functions.h" }
}
diff --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index 4aff04864e2d1..c6563de6b293d 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -68,13 +68,6 @@
# This declaration is in the ostream header.
ExtraDeclarations["system_error"] = ["std::operator<<"]
-# TODO MODULES avoid this work-around
-# This is a work-around for the special math functions. They are declared in
-# __math/special_functions.h. Adding this as an ExtraHeader works for the std
-# module. However these functions are special; they are not available in the
-# global namespace.
-ExtraDeclarations["cmath"] = ["std::hermite", "std::hermitef", "std::hermitel"]
-
### ExtraHeader
# Adds extra headers file to scan
More information about the libcxx-commits
mailing list