[libc-commits] [libc] [llvm] [libc][math] Implement nan(f|l) functions (PR #76690)
Nishant Mittal via libc-commits
libc-commits at lists.llvm.org
Mon Jan 1 12:22:43 PST 2024
================
@@ -0,0 +1,26 @@
+//===-- Implementation of nanl function -----------------------------------===//
+//
+// 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 "src/math/nanl.h"
+#include "src/__support/common.h"
+#include "src/__support/str_to_float.h"
+#include "src/errno/libc_errno.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long double, nanl, (const char *arg)) {
+ const char *fp_str = internal::nan_str_to_floatingpoint_str(arg);
+ auto result = internal::strtofloatingpoint<long double>(fp_str);
----------------
nishantwrp wrote:
Should I instead of creating a `NAN(...)` and then passing it to `strtofloatingpoint`, extract out the nan handling from `strtofloatingpoint` to a common function and use it directly? (For better performance)
https://github.com/llvm/llvm-project/pull/76690
More information about the libc-commits
mailing list