xref: /llvm-project/libc/src/stdlib/atoll.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1bad3168bSMichael Jones //===-- Implementation of atoll -------------------------------------------===//
2bad3168bSMichael Jones //
3bad3168bSMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4bad3168bSMichael Jones // See https://llvm.org/LICENSE.txt for license information.
5bad3168bSMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6bad3168bSMichael Jones //
7bad3168bSMichael Jones //===----------------------------------------------------------------------===//
8bad3168bSMichael Jones 
9bad3168bSMichael Jones #include "src/stdlib/atoll.h"
10bad3168bSMichael Jones #include "src/__support/common.h"
11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
1231d797f4SMichael Jones #include "src/__support/str_to_integer.h"
1304a9c625SMichael Jones #include "src/errno/libc_errno.h"
14bad3168bSMichael Jones 
15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
16bad3168bSMichael Jones 
17bad3168bSMichael Jones LLVM_LIBC_FUNCTION(long long, atoll, (const char *str)) {
1874da5e6cSMichael Jones   auto result = internal::strtointeger<long long>(str, 10);
1974da5e6cSMichael Jones   if (result.has_error())
2004a9c625SMichael Jones     libc_errno = result.error;
2174da5e6cSMichael Jones 
2274da5e6cSMichael Jones   return result;
23bad3168bSMichael Jones }
24bad3168bSMichael Jones 
25*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
26