187c01607SMichael Jones //===-- Implementation of strtof ------------------------------------------===// 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/strtof.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(float, strtof, 1887c01607SMichael Jones (const char *__restrict str, char **__restrict str_end)) { 19cb3c41c2SMichael Jones auto result = internal::strtofloatingpoint<float>(str); 20cb3c41c2SMichael Jones if (result.has_error()) 2104a9c625SMichael Jones libc_errno = result.error; 22cb3c41c2SMichael Jones 237789ec06SNick Desaulniers if (str_end != nullptr) 24cb3c41c2SMichael Jones *str_end = const_cast<char *>(str + result.parsed_len); 25cb3c41c2SMichael Jones 26cb3c41c2SMichael Jones return result.value; 2787c01607SMichael Jones } 2887c01607SMichael Jones 29*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 30