1//===-- Implementation file for readv -------------------------------------===//
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//===----------------------------------------------------------------------===//
8#include "src/sys/uio/readv.h"
9#include "hdr/types/ssize_t.h"
10#include "hdr/types/struct_iovec.h"
11#include "src/__support/OSUtil/syscall.h"
12#include "src/__support/common.h"
13#include "src/__support/libc_errno.h"
14#include <sys/syscall.h>
15
16namespace LIBC_NAMESPACE_DECL {
17
18LLVM_LIBC_FUNCTION(ssize_t, readv, (int fd, const iovec *iov, int iovcnt)) {
19 long ret = LIBC_NAMESPACE::syscall_impl<long>(SYS_readv, fd, iov, iovcnt);
20 // On failure, return -1 and set errno.
21 if (ret < 0) {
22 libc_errno = static_cast<int>(-ret);
23 return -1;
24 }
25 // On success, return number of bytes read.
26 return static_cast<ssize_t>(ret);
27}
28
29} // namespace LIBC_NAMESPACE_DECL
30

source code of libc/src/sys/uio/linux/readv.cpp