xref: /llvm-project/libc/src/math/generic/nan.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
10504e932SNishant Mittal //===-- Implementation of nan function ------------------------------------===//
20504e932SNishant Mittal //
30504e932SNishant Mittal // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40504e932SNishant Mittal // See https://llvm.org/LICENSE.txt for license information.
50504e932SNishant Mittal // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60504e932SNishant Mittal //
70504e932SNishant Mittal //===----------------------------------------------------------------------===//
80504e932SNishant Mittal 
90504e932SNishant Mittal #include "src/math/nan.h"
100504e932SNishant Mittal #include "src/__support/common.h"
11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
120504e932SNishant Mittal #include "src/__support/str_to_float.h"
130504e932SNishant Mittal #include "src/errno/libc_errno.h"
140504e932SNishant Mittal 
15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
160504e932SNishant Mittal 
170504e932SNishant Mittal LLVM_LIBC_FUNCTION(double, nan, (const char *arg)) {
180504e932SNishant Mittal   auto result = internal::strtonan<double>(arg);
190504e932SNishant Mittal   if (result.has_error())
200504e932SNishant Mittal     libc_errno = result.error;
210504e932SNishant Mittal   return result.value;
220504e932SNishant Mittal }
230504e932SNishant Mittal 
24*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
25