poll2.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 macros for poll functions.
  17. Copyright (C) 2012-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 _SYS_POLL_H
  31. # error "Never include <bits/poll2.h> directly; use <sys/poll.h> instead."
  32. #endif
  33. __BEGIN_DECLS
  34. extern int __REDIRECT (__poll_alias, (struct pollfd *__fds, nfds_t __nfds,
  35. int __timeout), poll);
  36. extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout,
  37. __SIZE_TYPE__ __fdslen)
  38. __attr_access ((__write_only__, 1, 2));
  39. extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
  40. int __timeout, __SIZE_TYPE__ __fdslen),
  41. __poll_chk)
  42. __warnattr ("poll called with fds buffer too small file nfds entries");
  43. __fortify_function __fortified_attr_access (__write_only__, 1, 2)
  44. __attribute_overloadable__ int
  45. poll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
  46. int __timeout)
  47. __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
  48. "poll called with fds buffer "
  49. "too small file nfds entries")
  50. {
  51. return __glibc_fortify (poll, __nfds, sizeof (*__fds),
  52. __glibc_objsize (__fds),
  53. __fds, __nfds, __timeout);
  54. }
  55. #ifdef __USE_GNU
  56. # ifdef __USE_TIME64_REDIRECTS
  57. extern int __REDIRECT (__ppoll64_alias, (struct pollfd *__fds, nfds_t __nfds,
  58. const struct timespec *__timeout,
  59. const __sigset_t *__ss), __ppoll64);
  60. extern int __ppoll64_chk (struct pollfd *__fds, nfds_t __nfds,
  61. const struct timespec *__timeout,
  62. const __sigset_t *__ss, __SIZE_TYPE__ __fdslen)
  63. __attr_access ((__write_only__, 1, 2));
  64. extern int __REDIRECT (__ppoll64_chk_warn, (struct pollfd *__fds, nfds_t __n,
  65. const struct timespec *__timeout,
  66. const __sigset_t *__ss,
  67. __SIZE_TYPE__ __fdslen),
  68. __ppoll64_chk)
  69. __warnattr ("ppoll called with fds buffer too small file nfds entries");
  70. __fortify_function __fortified_attr_access (__write_only__, 1, 2)
  71. __attribute_overloadable__ int
  72. ppoll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
  73. const struct timespec *__timeout, const __sigset_t *__ss)
  74. __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
  75. "ppoll called with fds buffer "
  76. "too small file nfds entries")
  77. {
  78. return __glibc_fortify (ppoll64, __nfds, sizeof (*__fds),
  79. __glibc_objsize (__fds),
  80. __fds, __nfds, __timeout, __ss);
  81. }
  82. # else
  83. extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
  84. const struct timespec *__timeout,
  85. const __sigset_t *__ss), ppoll);
  86. extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds,
  87. const struct timespec *__timeout,
  88. const __sigset_t *__ss, __SIZE_TYPE__ __fdslen)
  89. __attr_access ((__write_only__, 1, 2));
  90. extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
  91. const struct timespec *__timeout,
  92. const __sigset_t *__ss,
  93. __SIZE_TYPE__ __fdslen),
  94. __ppoll_chk)
  95. __warnattr ("ppoll called with fds buffer too small file nfds entries");
  96. __fortify_function __fortified_attr_access (__write_only__, 1, 2)
  97. __attribute_overloadable__ int
  98. ppoll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
  99. const struct timespec *__timeout, const __sigset_t *__ss)
  100. __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
  101. "ppoll called with fds buffer "
  102. "too small file nfds entries")
  103. {
  104. return __glibc_fortify (ppoll, __nfds, sizeof (*__fds),
  105. __glibc_objsize (__fds),
  106. __fds, __nfds, __timeout, __ss);
  107. }
  108. # endif
  109. #endif
  110. __END_DECLS