blob: 4a2a18d8fef45cf2baf792975db5f73f774ba314 [file] [edit]
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Linux implementation of copy_file_range.
///
//===----------------------------------------------------------------------===//
#include "src/unistd/copy_file_range.h"
#include "hdr/types/off_t.h"
#include "hdr/types/size_t.h"
#include "hdr/types/ssize_t.h"
#include "src/__support/OSUtil/linux/syscall_wrappers/copy_file_range.h"
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(ssize_t, copy_file_range,
(int fd_in, off_t *off_in, int fd_out, off_t *off_out,
size_t len, unsigned int flags)) {
auto result = linux_syscalls::copy_file_range(fd_in, off_in, fd_out, off_out,
len, flags);
if (!result.has_value()) {
libc_errno = result.error();
return -1;
}
return result.value();
}
} // namespace LIBC_NAMESPACE_DECL