1aa1902f9SMichael Jones //===-- Implementation of strtold -----------------------------------------===// 2aa1902f9SMichael Jones // 3aa1902f9SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4aa1902f9SMichael Jones // See https://llvm.org/LICENSE.txt for license information. 5aa1902f9SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6aa1902f9SMichael Jones // 7aa1902f9SMichael Jones //===----------------------------------------------------------------------===// 8aa1902f9SMichael Jones 9aa1902f9SMichael Jones #include "src/stdlib/strtold.h" 10aa1902f9SMichael Jones #include "src/__support/common.h" 11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 12aa1902f9SMichael Jones #include "src/__support/str_to_float.h" 1304a9c625SMichael Jones #include "src/errno/libc_errno.h" 14aa1902f9SMichael Jones 15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 16aa1902f9SMichael Jones 17aa1902f9SMichael Jones LLVM_LIBC_FUNCTION(long double, strtold, 18aa1902f9SMichael Jones (const char *__restrict str, char **__restrict str_end)) { 19cb3c41c2SMichael Jones auto result = internal::strtofloatingpoint<long double>(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; 27aa1902f9SMichael Jones } 28aa1902f9SMichael Jones 29*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 30