From 2820444284d2e674f7ad7613c7d82f170f111dcf Mon Sep 17 00:00:00 2001 From: aviralgarg05 Date: Mon, 9 Feb 2026 23:58:53 +0530 Subject: [PATCH] include/cxx/cmath: Use toolchain with toolchain libm. When CONFIG_LIBM_TOOLCHAIN is enabled, include_next the toolchain\n/cmath wrapper instead of importing symbols from the NuttX\ncmath shim. This avoids include-order recursion and lets libstdc\+\+\nresolve std::abs/std::acos/... against the matching toolchain C\nmath.h declarations.\n\nKeep the existing NuttX cmath namespace path unchanged for non-\ntoolchain libm configurations. Signed-off-by: aviralgarg05 --- include/cxx/cmath | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/cxx/cmath b/include/cxx/cmath index 314f0900ac1..719e625324f 100644 --- a/include/cxx/cmath +++ b/include/cxx/cmath @@ -30,7 +30,16 @@ #include #include -#include +#if defined(CONFIG_LIBM_TOOLCHAIN) +/* In toolchain libm mode, use toolchain so it can include_next the + * matching C math.h header and populate std::* consistently. + */ + +# include_next + +#else + +# include #undef signbit #undef fpclassify @@ -222,4 +231,6 @@ namespace std } +#endif + #endif // __INCLUDE_CXX_CMATH