uio.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 1991-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_UIO_H
  30. #define _SYS_UIO_H 1
  31. #include <features.h>
  32. #include <sys/types.h>
  33. #include <bits/types/struct_iovec.h>
  34. #include <bits/uio_lim.h>
  35. #ifdef __IOV_MAX
  36. # define UIO_MAXIOV __IOV_MAX
  37. #else
  38. # undef UIO_MAXIOV
  39. #endif
  40. __BEGIN_DECLS
  41. /* Read data from file descriptor FD, and put the result in the
  42. buffers described by IOVEC, which is a vector of COUNT 'struct iovec's.
  43. The buffers are filled in the order specified.
  44. Operates just like 'read' (see <unistd.h>) except that data are
  45. put in IOVEC instead of a contiguous buffer.
  46. This function is a cancellation point and therefore not marked with
  47. __THROW. */
  48. extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
  49. __wur __attr_access ((__read_only__, 2, 3));
  50. /* Write data pointed by the buffers described by IOVEC, which
  51. is a vector of COUNT 'struct iovec's, to file descriptor FD.
  52. The data is written in the order specified.
  53. Operates just like 'write' (see <unistd.h>) except that the data
  54. are taken from IOVEC instead of a contiguous buffer.
  55. This function is a cancellation point and therefore not marked with
  56. __THROW. */
  57. extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
  58. __wur __attr_access ((__read_only__, 2, 3));
  59. #ifdef __USE_MISC
  60. # ifndef __USE_FILE_OFFSET64
  61. /* Read data from file descriptor FD at the given position OFFSET
  62. without change the file pointer, and put the result in the buffers
  63. described by IOVEC, which is a vector of COUNT 'struct iovec's.
  64. The buffers are filled in the order specified. Operates just like
  65. 'pread' (see <unistd.h>) except that data are put in IOVEC instead
  66. of a contiguous buffer.
  67. This function is a cancellation point and therefore not marked with
  68. __THROW. */
  69. extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
  70. __off_t __offset)
  71. __wur __attr_access ((__read_only__, 2, 3));
  72. /* Write data pointed by the buffers described by IOVEC, which is a
  73. vector of COUNT 'struct iovec's, to file descriptor FD at the given
  74. position OFFSET without change the file pointer. The data is
  75. written in the order specified. Operates just like 'pwrite' (see
  76. <unistd.h>) except that the data are taken from IOVEC instead of a
  77. contiguous buffer.
  78. This function is a cancellation point and therefore not marked with
  79. __THROW. */
  80. extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
  81. __off_t __offset)
  82. __wur __attr_access ((__read_only__, 2, 3));
  83. # else
  84. # ifdef __REDIRECT
  85. extern ssize_t __REDIRECT (preadv, (int __fd, const struct iovec *__iovec,
  86. int __count, __off64_t __offset),
  87. preadv64)
  88. __wur __attr_access ((__read_only__, 2, 3));
  89. extern ssize_t __REDIRECT (pwritev, (int __fd, const struct iovec *__iovec,
  90. int __count, __off64_t __offset),
  91. pwritev64)
  92. __wur __attr_access ((__read_only__, 2, 3));
  93. # else
  94. # define preadv preadv64
  95. # define pwritev pwritev64
  96. # endif
  97. # endif
  98. # ifdef __USE_LARGEFILE64
  99. /* Read data from file descriptor FD at the given position OFFSET
  100. without change the file pointer, and put the result in the buffers
  101. described by IOVEC, which is a vector of COUNT 'struct iovec's.
  102. The buffers are filled in the order specified. Operates just like
  103. 'pread' (see <unistd.h>) except that data are put in IOVEC instead
  104. of a contiguous buffer.
  105. This function is a cancellation point and therefore not marked with
  106. __THROW. */
  107. extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
  108. __off64_t __offset)
  109. __wur __attr_access ((__read_only__, 2, 3));
  110. /* Write data pointed by the buffers described by IOVEC, which is a
  111. vector of COUNT 'struct iovec's, to file descriptor FD at the given
  112. position OFFSET without change the file pointer. The data is
  113. written in the order specified. Operates just like 'pwrite' (see
  114. <unistd.h>) except that the data are taken from IOVEC instead of a
  115. contiguous buffer.
  116. This function is a cancellation point and therefore not marked with
  117. __THROW. */
  118. extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
  119. __off64_t __offset)
  120. __wur __attr_access ((__read_only__, 2, 3));
  121. # endif
  122. #endif /* Use misc. */
  123. #ifdef __USE_GNU
  124. # ifndef __USE_FILE_OFFSET64
  125. /* Same as preadv but with an additional flag argumenti defined at uio.h. */
  126. extern ssize_t preadv2 (int __fp, const struct iovec *__iovec, int __count,
  127. __off_t __offset, int ___flags)
  128. __wur __attr_access ((__read_only__, 2, 3));
  129. /* Same as preadv but with an additional flag argument defined at uio.h. */
  130. extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count,
  131. __off_t __offset, int __flags) __wur;
  132. # else
  133. # ifdef __REDIRECT
  134. extern ssize_t __REDIRECT (pwritev2, (int __fd, const struct iovec *__iovec,
  135. int __count, __off64_t __offset,
  136. int __flags),
  137. pwritev64v2)
  138. __wur __attr_access ((__read_only__, 2, 3));
  139. extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec,
  140. int __count, __off64_t __offset,
  141. int __flags),
  142. preadv64v2)
  143. __wur __attr_access ((__read_only__, 2, 3));
  144. # else
  145. # define preadv2 preadv64v2
  146. # define pwritev2 pwritev64v2
  147. # endif
  148. # endif
  149. # ifdef __USE_LARGEFILE64
  150. /* Same as preadv but with an additional flag argumenti defined at uio.h. */
  151. extern ssize_t preadv64v2 (int __fp, const struct iovec *__iovec,
  152. int __count, __off64_t __offset,
  153. int ___flags)
  154. __wur __attr_access ((__read_only__, 2, 3));
  155. /* Same as preadv but with an additional flag argument defined at uio.h. */
  156. extern ssize_t pwritev64v2 (int __fd, const struct iovec *__iodev,
  157. int __count, __off64_t __offset,
  158. int __flags)
  159. __wur __attr_access ((__read_only__, 2, 3));
  160. # endif
  161. #endif /* Use GNU. */
  162. __END_DECLS
  163. /* Some operating systems provide system-specific extensions to this
  164. header. */
  165. #ifdef __USE_GNU
  166. # include <bits/uio-ext.h>
  167. #endif
  168. #endif /* sys/uio.h */