187c01607SMichael Jones //===-- Implementation of atof --------------------------------------------===// 287c01607SMichael Jones // 387c01607SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 487c01607SMichael Jones // See https://llvm.org/LICENSE.txt for license information. 587c01607SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 687c01607SMichael Jones // 787c01607SMichael Jones //===----------------------------------------------------------------------===// 887c01607SMichael Jones 987c01607SMichael Jones #include "src/stdlib/atof.h" 1087c01607SMichael Jones #include "src/__support/common.h" 11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 1287c01607SMichael Jones #include "src/__support/str_to_float.h" 1304a9c625SMichael Jones #include "src/errno/libc_errno.h" 1487c01607SMichael Jones 15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 1687c01607SMichael Jones 1787c01607SMichael Jones LLVM_LIBC_FUNCTION(double, atof, (const char *str)) { 18cb3c41c2SMichael Jones auto result = internal::strtofloatingpoint<double>(str); 19cb3c41c2SMichael Jones if (result.has_error()) 2004a9c625SMichael Jones libc_errno = result.error; 21cb3c41c2SMichael Jones 22cb3c41c2SMichael Jones return result.value; 2387c01607SMichael Jones } 2487c01607SMichael Jones 25*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 26