xref: /llvm-project/libc/src/stdio/generic/ftello.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
155b74030SShourya Goel //===-- Implementation of ftello ------------------------------------------===//
255b74030SShourya Goel //
355b74030SShourya Goel // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
455b74030SShourya Goel // See https://llvm.org/LICENSE.txt for license information.
555b74030SShourya Goel // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
655b74030SShourya Goel //
755b74030SShourya Goel //===----------------------------------------------------------------------===//
855b74030SShourya Goel 
955b74030SShourya Goel #include "src/stdio/ftello.h"
1055b74030SShourya Goel #include "src/__support/File/file.h"
1155b74030SShourya Goel 
12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
1355b74030SShourya Goel #include "src/errno/libc_errno.h"
1455b74030SShourya Goel 
15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
1655b74030SShourya Goel 
1755b74030SShourya Goel LLVM_LIBC_FUNCTION(off_t, ftello, (::FILE * stream)) {
1855b74030SShourya Goel   auto result = reinterpret_cast<LIBC_NAMESPACE::File *>(stream)->tell();
1955b74030SShourya Goel   if (!result.has_value()) {
2055b74030SShourya Goel     libc_errno = result.error();
2155b74030SShourya Goel     return -1;
2255b74030SShourya Goel   }
2355b74030SShourya Goel   return result.value();
2455b74030SShourya Goel }
2555b74030SShourya Goel 
26*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
27