blob: eff3b1473c98d214a1c738d5075d73d77a8bb88b [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Elliott Hughesff26a162017-08-17 22:34:21 +000028
Elliott Hughescf59e192021-10-13 18:25:21 -070029#pragma once
30
31/**
32 * @file sys/uio.h
33 * @brief Multi-buffer ("vector") I/O operations using `struct iovec`.
34 */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080035
36#include <sys/cdefs.h>
37#include <sys/types.h>
38#include <linux/uio.h>
39
40__BEGIN_DECLS
41
Elliott Hughescf59e192021-10-13 18:25:21 -070042/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000043 * [readv(2)](https://man7.org/linux/man-pages/man2/readv.2.html) reads
Elliott Hughescf59e192021-10-13 18:25:21 -070044 * from an fd into the `__count` buffers described by `__iov`.
45 *
46 * Returns the number of bytes read on success,
47 * and returns -1 and sets `errno` on failure.
48 */
zijunzhaod6336002023-05-03 22:48:15 +000049ssize_t readv(int __fd, const struct iovec* _Nonnull __iov, int __count);
Elliott Hughescf59e192021-10-13 18:25:21 -070050
51/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000052 * [writev(2)](https://man7.org/linux/man-pages/man2/writev.2.html) writes
Elliott Hughescf59e192021-10-13 18:25:21 -070053 * to an fd from the `__count` buffers described by `__iov`.
54 *
55 * Returns the number of bytes written on success,
56 * and returns -1 and sets `errno` on failure.
57 */
zijunzhaod6336002023-05-03 22:48:15 +000058ssize_t writev(int __fd, const struct iovec* _Nonnull __iov, int __count);
Elliott Hughesbe57a402015-06-10 17:24:20 -070059
60#if defined(__USE_GNU)
Elliott Hughes6f4594d2015-08-26 13:27:43 -070061
Elliott Hughescf59e192021-10-13 18:25:21 -070062/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000063 * [preadv(2)](https://man7.org/linux/man-pages/man2/preadv.2.html) reads
Elliott Hughescf59e192021-10-13 18:25:21 -070064 * from an fd into the `__count` buffers described by `__iov`, starting at
65 * offset `__offset` into the file.
66 *
67 * Returns the number of bytes read on success,
68 * and returns -1 and sets `errno` on failure.
69 *
70 * Available since API level 24.
71 */
Dan Albert02ce4012024-10-25 19:13:49 +000072
73#if __BIONIC_AVAILABILITY_GUARD(24)
zijunzhaod6336002023-05-03 22:48:15 +000074ssize_t preadv(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(preadv64) __INTRODUCED_IN(24);
Elliott Hughescf59e192021-10-13 18:25:21 -070075
76/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000077 * [pwritev(2)](https://man7.org/linux/man-pages/man2/pwritev.2.html) writes
Elliott Hughescf59e192021-10-13 18:25:21 -070078 * to an fd from the `__count` buffers described by `__iov`, starting at offset
79 * `__offset` into the file.
80 *
81 * Returns the number of bytes written on success,
82 * and returns -1 and sets `errno` on failure.
83 *
84 * Available since API level 24.
85 */
zijunzhaod6336002023-05-03 22:48:15 +000086ssize_t pwritev(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(pwritev64) __INTRODUCED_IN(24);
Elliott Hughescf59e192021-10-13 18:25:21 -070087
88/**
89 * Like preadv() but with a 64-bit offset even in a 32-bit process.
90 *
91 * Available since API level 24.
92 */
zijunzhaod6336002023-05-03 22:48:15 +000093ssize_t preadv64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24);
Elliott Hughescf59e192021-10-13 18:25:21 -070094
95/**
96 * Like pwritev() but with a 64-bit offset even in a 32-bit process.
97 *
98 * Available since API level 24.
99 */
zijunzhaod6336002023-05-03 22:48:15 +0000100ssize_t pwritev64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24);
Dan Albert02ce4012024-10-25 19:13:49 +0000101#endif /* __BIONIC_AVAILABILITY_GUARD(24) */
102
Elliott Hughescf59e192021-10-13 18:25:21 -0700103
104/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000105 * [preadv2(2)](https://man7.org/linux/man-pages/man2/preadv2.2.html) reads
Elliott Hughescf59e192021-10-13 18:25:21 -0700106 * from an fd into the `__count` buffers described by `__iov`, starting at
107 * offset `__offset` into the file, with the given flags.
108 *
109 * Returns the number of bytes read on success,
110 * and returns -1 and sets `errno` on failure.
111 *
112 * Available since API level 33.
113 */
Dan Albert02ce4012024-10-25 19:13:49 +0000114
115#if __BIONIC_AVAILABILITY_GUARD(33)
zijunzhaod6336002023-05-03 22:48:15 +0000116ssize_t preadv2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(preadv64v2) __INTRODUCED_IN(33);
Elliott Hughescf59e192021-10-13 18:25:21 -0700117
118/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000119 * [pwritev2(2)](https://man7.org/linux/man-pages/man2/pwritev2.2.html) writes
Elliott Hughescf59e192021-10-13 18:25:21 -0700120 * to an fd from the `__count` buffers described by `__iov`, starting at offset
121 * `__offset` into the file, with the given flags.
122 *
123 * Returns the number of bytes written on success,
124 * and returns -1 and sets `errno` on failure.
125 *
126 * Available since API level 33.
127 */
zijunzhaod6336002023-05-03 22:48:15 +0000128ssize_t pwritev2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(pwritev64v2) __INTRODUCED_IN(33);
Elliott Hughescf59e192021-10-13 18:25:21 -0700129
130/**
131 * Like preadv2() but with a 64-bit offset even in a 32-bit process.
132 *
133 * Available since API level 33.
134 */
zijunzhaod6336002023-05-03 22:48:15 +0000135ssize_t preadv64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33);
Elliott Hughescf59e192021-10-13 18:25:21 -0700136
137/**
138 * Like pwritev2() but with a 64-bit offset even in a 32-bit process.
139 *
140 * Available since API level 33.
141 */
zijunzhaod6336002023-05-03 22:48:15 +0000142ssize_t pwritev64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33);
Dan Albert02ce4012024-10-25 19:13:49 +0000143#endif /* __BIONIC_AVAILABILITY_GUARD(33) */
144
Elliott Hughescf59e192021-10-13 18:25:21 -0700145
146/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000147 * [process_vm_readv(2)](https://man7.org/linux/man-pages/man2/process_vm_readv.2.html)
Elliott Hughescf59e192021-10-13 18:25:21 -0700148 * reads from the address space of another process.
149 *
150 * Returns the number of bytes read on success,
151 * and returns -1 and sets `errno` on failure.
152 *
153 * Available since API level 23.
154 */
Dan Albert02ce4012024-10-25 19:13:49 +0000155
156#if __BIONIC_AVAILABILITY_GUARD(23)
zijunzhaod6336002023-05-03 22:48:15 +0000157ssize_t process_vm_readv(pid_t __pid, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __local_iov, unsigned long __local_iov_count, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23);
Elliott Hughescf59e192021-10-13 18:25:21 -0700158
159/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000160 * [process_vm_writev(2)](https://man7.org/linux/man-pages/man2/process_vm_writev.2.html)
Elliott Hughescf59e192021-10-13 18:25:21 -0700161 * writes to the address space of another process.
162 *
163 * Returns the number of bytes read on success,
164 * and returns -1 and sets `errno` on failure.
165 *
166 * Available since API level 23.
167 */
zijunzhaod6336002023-05-03 22:48:15 +0000168ssize_t process_vm_writev(pid_t __pid, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __local_iov, unsigned long __local_iov_count, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23);
Dan Albert02ce4012024-10-25 19:13:49 +0000169#endif /* __BIONIC_AVAILABILITY_GUARD(23) */
170
Elliott Hughescf59e192021-10-13 18:25:21 -0700171
Elliott Hughesbe57a402015-06-10 17:24:20 -0700172#endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800173
174__END_DECLS