xref: /aosp_15_r20/bionic/libc/include/sys/uio.h (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2008 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  * All rights reserved.
4*8d67ca89SAndroid Build Coastguard Worker  *
5*8d67ca89SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
6*8d67ca89SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
7*8d67ca89SAndroid Build Coastguard Worker  * are met:
8*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions of source code must retain the above copyright
9*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
10*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions in binary form must reproduce the above copyright
11*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in
12*8d67ca89SAndroid Build Coastguard Worker  *    the documentation and/or other materials provided with the
13*8d67ca89SAndroid Build Coastguard Worker  *    distribution.
14*8d67ca89SAndroid Build Coastguard Worker  *
15*8d67ca89SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16*8d67ca89SAndroid Build Coastguard Worker  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17*8d67ca89SAndroid Build Coastguard Worker  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18*8d67ca89SAndroid Build Coastguard Worker  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19*8d67ca89SAndroid Build Coastguard Worker  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20*8d67ca89SAndroid Build Coastguard Worker  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21*8d67ca89SAndroid Build Coastguard Worker  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22*8d67ca89SAndroid Build Coastguard Worker  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23*8d67ca89SAndroid Build Coastguard Worker  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24*8d67ca89SAndroid Build Coastguard Worker  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25*8d67ca89SAndroid Build Coastguard Worker  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*8d67ca89SAndroid Build Coastguard Worker  * SUCH DAMAGE.
27*8d67ca89SAndroid Build Coastguard Worker  */
28*8d67ca89SAndroid Build Coastguard Worker 
29*8d67ca89SAndroid Build Coastguard Worker #pragma once
30*8d67ca89SAndroid Build Coastguard Worker 
31*8d67ca89SAndroid Build Coastguard Worker /**
32*8d67ca89SAndroid Build Coastguard Worker  * @file sys/uio.h
33*8d67ca89SAndroid Build Coastguard Worker  * @brief Multi-buffer ("vector") I/O operations using `struct iovec`.
34*8d67ca89SAndroid Build Coastguard Worker  */
35*8d67ca89SAndroid Build Coastguard Worker 
36*8d67ca89SAndroid Build Coastguard Worker #include <sys/cdefs.h>
37*8d67ca89SAndroid Build Coastguard Worker #include <sys/types.h>
38*8d67ca89SAndroid Build Coastguard Worker #include <linux/uio.h>
39*8d67ca89SAndroid Build Coastguard Worker 
40*8d67ca89SAndroid Build Coastguard Worker __BEGIN_DECLS
41*8d67ca89SAndroid Build Coastguard Worker 
42*8d67ca89SAndroid Build Coastguard Worker /**
43*8d67ca89SAndroid Build Coastguard Worker  * [readv(2)](https://man7.org/linux/man-pages/man2/readv.2.html) reads
44*8d67ca89SAndroid Build Coastguard Worker  * from an fd into the `__count` buffers described by `__iov`.
45*8d67ca89SAndroid Build Coastguard Worker  *
46*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes read on success,
47*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
48*8d67ca89SAndroid Build Coastguard Worker  */
49*8d67ca89SAndroid Build Coastguard Worker ssize_t readv(int __fd, const struct iovec* _Nonnull __iov, int __count);
50*8d67ca89SAndroid Build Coastguard Worker 
51*8d67ca89SAndroid Build Coastguard Worker /**
52*8d67ca89SAndroid Build Coastguard Worker  * [writev(2)](https://man7.org/linux/man-pages/man2/writev.2.html) writes
53*8d67ca89SAndroid Build Coastguard Worker  * to an fd from the `__count` buffers described by `__iov`.
54*8d67ca89SAndroid Build Coastguard Worker  *
55*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes written on success,
56*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
57*8d67ca89SAndroid Build Coastguard Worker  */
58*8d67ca89SAndroid Build Coastguard Worker ssize_t writev(int __fd, const struct iovec* _Nonnull __iov, int __count);
59*8d67ca89SAndroid Build Coastguard Worker 
60*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_GNU)
61*8d67ca89SAndroid Build Coastguard Worker 
62*8d67ca89SAndroid Build Coastguard Worker /**
63*8d67ca89SAndroid Build Coastguard Worker  * [preadv(2)](https://man7.org/linux/man-pages/man2/preadv.2.html) reads
64*8d67ca89SAndroid Build Coastguard Worker  * from an fd into the `__count` buffers described by `__iov`, starting at
65*8d67ca89SAndroid Build Coastguard Worker  * offset `__offset` into the file.
66*8d67ca89SAndroid Build Coastguard Worker  *
67*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes read on success,
68*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
69*8d67ca89SAndroid Build Coastguard Worker  *
70*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 24.
71*8d67ca89SAndroid Build Coastguard Worker  */
72*8d67ca89SAndroid Build Coastguard Worker 
73*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(24)
74*8d67ca89SAndroid Build Coastguard Worker ssize_t preadv(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(preadv64) __INTRODUCED_IN(24);
75*8d67ca89SAndroid Build Coastguard Worker 
76*8d67ca89SAndroid Build Coastguard Worker /**
77*8d67ca89SAndroid Build Coastguard Worker  * [pwritev(2)](https://man7.org/linux/man-pages/man2/pwritev.2.html) writes
78*8d67ca89SAndroid Build Coastguard Worker  * to an fd from the `__count` buffers described by `__iov`, starting at offset
79*8d67ca89SAndroid Build Coastguard Worker  * `__offset` into the file.
80*8d67ca89SAndroid Build Coastguard Worker  *
81*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes written on success,
82*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
83*8d67ca89SAndroid Build Coastguard Worker  *
84*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 24.
85*8d67ca89SAndroid Build Coastguard Worker  */
86*8d67ca89SAndroid Build Coastguard Worker ssize_t pwritev(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(pwritev64) __INTRODUCED_IN(24);
87*8d67ca89SAndroid Build Coastguard Worker 
88*8d67ca89SAndroid Build Coastguard Worker /**
89*8d67ca89SAndroid Build Coastguard Worker  * Like preadv() but with a 64-bit offset even in a 32-bit process.
90*8d67ca89SAndroid Build Coastguard Worker  *
91*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 24.
92*8d67ca89SAndroid Build Coastguard Worker  */
93*8d67ca89SAndroid Build Coastguard Worker ssize_t preadv64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24);
94*8d67ca89SAndroid Build Coastguard Worker 
95*8d67ca89SAndroid Build Coastguard Worker /**
96*8d67ca89SAndroid Build Coastguard Worker  * Like pwritev() but with a 64-bit offset even in a 32-bit process.
97*8d67ca89SAndroid Build Coastguard Worker  *
98*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 24.
99*8d67ca89SAndroid Build Coastguard Worker  */
100*8d67ca89SAndroid Build Coastguard Worker ssize_t pwritev64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24);
101*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(24) */
102*8d67ca89SAndroid Build Coastguard Worker 
103*8d67ca89SAndroid Build Coastguard Worker 
104*8d67ca89SAndroid Build Coastguard Worker /**
105*8d67ca89SAndroid Build Coastguard Worker  * [preadv2(2)](https://man7.org/linux/man-pages/man2/preadv2.2.html) reads
106*8d67ca89SAndroid Build Coastguard Worker  * from an fd into the `__count` buffers described by `__iov`, starting at
107*8d67ca89SAndroid Build Coastguard Worker  * offset `__offset` into the file, with the given flags.
108*8d67ca89SAndroid Build Coastguard Worker  *
109*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes read on success,
110*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
111*8d67ca89SAndroid Build Coastguard Worker  *
112*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 33.
113*8d67ca89SAndroid Build Coastguard Worker  */
114*8d67ca89SAndroid Build Coastguard Worker 
115*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(33)
116*8d67ca89SAndroid Build Coastguard Worker ssize_t preadv2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(preadv64v2) __INTRODUCED_IN(33);
117*8d67ca89SAndroid Build Coastguard Worker 
118*8d67ca89SAndroid Build Coastguard Worker /**
119*8d67ca89SAndroid Build Coastguard Worker  * [pwritev2(2)](https://man7.org/linux/man-pages/man2/pwritev2.2.html) writes
120*8d67ca89SAndroid Build Coastguard Worker  * to an fd from the `__count` buffers described by `__iov`, starting at offset
121*8d67ca89SAndroid Build Coastguard Worker  * `__offset` into the file, with the given flags.
122*8d67ca89SAndroid Build Coastguard Worker  *
123*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes written on success,
124*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
125*8d67ca89SAndroid Build Coastguard Worker  *
126*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 33.
127*8d67ca89SAndroid Build Coastguard Worker  */
128*8d67ca89SAndroid Build Coastguard Worker ssize_t pwritev2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(pwritev64v2) __INTRODUCED_IN(33);
129*8d67ca89SAndroid Build Coastguard Worker 
130*8d67ca89SAndroid Build Coastguard Worker /**
131*8d67ca89SAndroid Build Coastguard Worker  * Like preadv2() but with a 64-bit offset even in a 32-bit process.
132*8d67ca89SAndroid Build Coastguard Worker  *
133*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 33.
134*8d67ca89SAndroid Build Coastguard Worker  */
135*8d67ca89SAndroid Build Coastguard Worker ssize_t preadv64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33);
136*8d67ca89SAndroid Build Coastguard Worker 
137*8d67ca89SAndroid Build Coastguard Worker /**
138*8d67ca89SAndroid Build Coastguard Worker  * Like pwritev2() but with a 64-bit offset even in a 32-bit process.
139*8d67ca89SAndroid Build Coastguard Worker  *
140*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 33.
141*8d67ca89SAndroid Build Coastguard Worker  */
142*8d67ca89SAndroid Build Coastguard Worker ssize_t pwritev64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33);
143*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(33) */
144*8d67ca89SAndroid Build Coastguard Worker 
145*8d67ca89SAndroid Build Coastguard Worker 
146*8d67ca89SAndroid Build Coastguard Worker /**
147*8d67ca89SAndroid Build Coastguard Worker  * [process_vm_readv(2)](https://man7.org/linux/man-pages/man2/process_vm_readv.2.html)
148*8d67ca89SAndroid Build Coastguard Worker  * reads from the address space of another process.
149*8d67ca89SAndroid Build Coastguard Worker  *
150*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes read on success,
151*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
152*8d67ca89SAndroid Build Coastguard Worker  *
153*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 23.
154*8d67ca89SAndroid Build Coastguard Worker  */
155*8d67ca89SAndroid Build Coastguard Worker 
156*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(23)
157*8d67ca89SAndroid Build Coastguard Worker ssize_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);
158*8d67ca89SAndroid Build Coastguard Worker 
159*8d67ca89SAndroid Build Coastguard Worker /**
160*8d67ca89SAndroid Build Coastguard Worker  * [process_vm_writev(2)](https://man7.org/linux/man-pages/man2/process_vm_writev.2.html)
161*8d67ca89SAndroid Build Coastguard Worker  * writes to the address space of another process.
162*8d67ca89SAndroid Build Coastguard Worker  *
163*8d67ca89SAndroid Build Coastguard Worker  * Returns the number of bytes read on success,
164*8d67ca89SAndroid Build Coastguard Worker  * and returns -1 and sets `errno` on failure.
165*8d67ca89SAndroid Build Coastguard Worker  *
166*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 23.
167*8d67ca89SAndroid Build Coastguard Worker  */
168*8d67ca89SAndroid Build Coastguard Worker ssize_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);
169*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(23) */
170*8d67ca89SAndroid Build Coastguard Worker 
171*8d67ca89SAndroid Build Coastguard Worker 
172*8d67ca89SAndroid Build Coastguard Worker #endif
173*8d67ca89SAndroid Build Coastguard Worker 
174*8d67ca89SAndroid Build Coastguard Worker __END_DECLS
175