[flang] Use object before converts in fir.dispatch (#68589)
[llvm-project.git] / libc / src / unistd / linux / lseek.cpp
blob6f3d9937db245ef31bf01376837bdc7f4a2d9707
1 //===-- Linux implementation of lseek -------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/unistd/lseek.h"
10 #include "src/errno/libc_errno.h"
12 #include "src/__support/File/linux/lseekImpl.h"
13 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
14 #include "src/__support/common.h"
16 #include <sys/syscall.h> // For syscall numbers.
17 #include <unistd.h> // For off_t.
19 namespace LIBC_NAMESPACE {
21 LLVM_LIBC_FUNCTION(off_t, lseek, (int fd, off_t offset, int whence)) {
22 auto result = internal::lseekimpl(fd, offset, whence);
23 if (!result.has_value()) {
24 libc_errno = result.error();
25 return -1;
27 return result.value();
30 } // namespace LIBC_NAMESPACE