unistd-decl.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. /* Checking routines for unistd functions. Declaration only.
  17. Copyright (C) 2023-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _BITS_UNISTD_DECL_H
  31. #define _BITS_UNISTD_DECL_H 1
  32. #ifndef _UNISTD_H
  33. # error "Never include <bits/unistd-decl.h> directly; use <unistd.h> instead."
  34. #endif
  35. extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
  36. size_t __buflen)
  37. __wur __attr_access ((__write_only__, 2, 3));
  38. extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void *__buf,
  39. size_t __nbytes), read)
  40. __wur __attr_access ((__write_only__, 2, 3));
  41. extern ssize_t __REDIRECT (__read_chk_warn,
  42. (int __fd, void *__buf, size_t __nbytes,
  43. size_t __buflen), __read_chk)
  44. __wur __warnattr ("read called with bigger length than size of "
  45. "the destination buffer");
  46. #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
  47. extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
  48. __off_t __offset, size_t __bufsize)
  49. __wur __attr_access ((__write_only__, 2, 3));
  50. extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
  51. __off64_t __offset, size_t __bufsize)
  52. __wur __attr_access ((__write_only__, 2, 3));
  53. extern ssize_t __REDIRECT (__pread_alias,
  54. (int __fd, void *__buf, size_t __nbytes,
  55. __off_t __offset), pread)
  56. __wur __attr_access ((__write_only__, 2, 3));
  57. extern ssize_t __REDIRECT (__pread64_alias,
  58. (int __fd, void *__buf, size_t __nbytes,
  59. __off64_t __offset), pread64)
  60. __wur __attr_access ((__write_only__, 2, 3));
  61. extern ssize_t __REDIRECT (__pread_chk_warn,
  62. (int __fd, void *__buf, size_t __nbytes,
  63. __off_t __offset, size_t __bufsize), __pread_chk)
  64. __wur __warnattr ("pread called with bigger length than size of "
  65. "the destination buffer");
  66. extern ssize_t __REDIRECT (__pread64_chk_warn,
  67. (int __fd, void *__buf, size_t __nbytes,
  68. __off64_t __offset, size_t __bufsize),
  69. __pread64_chk)
  70. __wur __warnattr ("pread64 called with bigger length than size of "
  71. "the destination buffer");
  72. #endif
  73. #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
  74. extern ssize_t __readlink_chk (const char *__restrict __path,
  75. char *__restrict __buf, size_t __len,
  76. size_t __buflen)
  77. __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
  78. extern ssize_t __REDIRECT_NTH (__readlink_alias,
  79. (const char *__restrict __path,
  80. char *__restrict __buf, size_t __len), readlink)
  81. __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
  82. extern ssize_t __REDIRECT_NTH (__readlink_chk_warn,
  83. (const char *__restrict __path,
  84. char *__restrict __buf, size_t __len,
  85. size_t __buflen), __readlink_chk)
  86. __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length "
  87. "than size of destination buffer");
  88. #endif
  89. #ifdef __USE_ATFILE
  90. extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
  91. char *__restrict __buf, size_t __len,
  92. size_t __buflen)
  93. __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
  94. extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
  95. (int __fd, const char *__restrict __path,
  96. char *__restrict __buf, size_t __len),
  97. readlinkat)
  98. __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
  99. extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn,
  100. (int __fd, const char *__restrict __path,
  101. char *__restrict __buf, size_t __len,
  102. size_t __buflen), __readlinkat_chk)
  103. __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger "
  104. "length than size of destination "
  105. "buffer");
  106. #endif
  107. extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
  108. __THROW __wur;
  109. extern char *__REDIRECT_NTH (__getcwd_alias,
  110. (char *__buf, size_t __size), getcwd) __wur;
  111. extern char *__REDIRECT_NTH (__getcwd_chk_warn,
  112. (char *__buf, size_t __size, size_t __buflen),
  113. __getcwd_chk)
  114. __wur __warnattr ("getcwd caller with bigger length than size of "
  115. "destination buffer");
  116. #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
  117. extern char *__getwd_chk (char *__buf, size_t buflen)
  118. __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
  119. extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
  120. __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
  121. "doesn't specify buffer size");
  122. #endif
  123. extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
  124. size_t __buflen) __THROW
  125. __attr_access ((__write_only__, 2, 3));
  126. extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
  127. size_t __len), confstr)
  128. __attr_access ((__write_only__, 2, 3));
  129. extern size_t __REDIRECT_NTH (__confstr_chk_warn,
  130. (int __name, char *__buf, size_t __len,
  131. size_t __buflen), __confstr_chk)
  132. __warnattr ("confstr called with bigger length than size of destination "
  133. "buffer");
  134. extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
  135. __THROW __wur __attr_access ((__write_only__, 2, 1));
  136. extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
  137. getgroups) __wur __attr_access ((__write_only__, 2, 1));
  138. extern int __REDIRECT_NTH (__getgroups_chk_warn,
  139. (int __size, __gid_t __list[], size_t __listlen),
  140. __getgroups_chk)
  141. __wur __warnattr ("getgroups called with bigger group count than what "
  142. "can fit into destination buffer");
  143. extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
  144. size_t __nreal) __THROW __nonnull ((2))
  145. __attr_access ((__write_only__, 2, 3));
  146. extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
  147. size_t __buflen), ttyname_r)
  148. __nonnull ((2));
  149. extern int __REDIRECT_NTH (__ttyname_r_chk_warn,
  150. (int __fd, char *__buf, size_t __buflen,
  151. size_t __nreal), __ttyname_r_chk)
  152. __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
  153. "size of destination buffer");
  154. #ifdef __USE_POSIX199506
  155. extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
  156. __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
  157. extern int __REDIRECT_FORTIFY (__getlogin_r_alias, (char *__buf, size_t __buflen),
  158. getlogin_r) __nonnull ((1));
  159. extern int __REDIRECT (__getlogin_r_chk_warn,
  160. (char *__buf, size_t __buflen, size_t __nreal),
  161. __getlogin_r_chk)
  162. __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
  163. "size of destination buffer");
  164. #endif
  165. #if defined __USE_MISC || defined __USE_UNIX98
  166. extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
  167. __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
  168. extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
  169. gethostname)
  170. __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
  171. extern int __REDIRECT_NTH (__gethostname_chk_warn,
  172. (char *__buf, size_t __buflen, size_t __nreal),
  173. __gethostname_chk)
  174. __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
  175. "size of destination buffer");
  176. #endif
  177. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
  178. extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
  179. __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
  180. extern int __REDIRECT_FORTIFY_NTH (__getdomainname_alias, (char *__buf,
  181. size_t __buflen),
  182. getdomainname) __nonnull ((1))
  183. __wur __attr_access ((__write_only__, 1, 2));
  184. extern int __REDIRECT_NTH (__getdomainname_chk_warn,
  185. (char *__buf, size_t __buflen, size_t __nreal),
  186. __getdomainname_chk)
  187. __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger "
  188. "buflen than size of destination "
  189. "buffer");
  190. #endif
  191. #endif /* bits/unistd-decl.h. */