1 //===-- Linux implementation of lseek -------------------------------------===//
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
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();
27 return result
.value();
30 } // namespace LIBC_NAMESPACE