master
1/* Checking macros for poll functions.
2 Copyright (C) 2012-2025 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_POLL_H
20# error "Never include <bits/poll2.h> directly; use <sys/poll.h> instead."
21#endif
22
23
24__BEGIN_DECLS
25
26extern int __REDIRECT (__poll_alias, (struct pollfd *__fds, nfds_t __nfds,
27 int __timeout), poll);
28extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout,
29 __SIZE_TYPE__ __fdslen)
30 __attr_access ((__write_only__, 1, 2));
31extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
32 int __timeout, __SIZE_TYPE__ __fdslen),
33 __poll_chk)
34 __warnattr ("poll called with fds buffer too small file nfds entries");
35
36__fortify_function __fortified_attr_access (__write_only__, 1, 2)
37__attribute_overloadable__ int
38poll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
39 int __timeout)
40 __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
41 "poll called with fds buffer "
42 "too small file nfds entries")
43{
44 return __glibc_fortify (poll, __nfds, sizeof (*__fds),
45 __glibc_objsize (__fds),
46 __fds, __nfds, __timeout);
47}
48
49
50#ifdef __USE_GNU
51# ifdef __USE_TIME64_REDIRECTS
52extern int __REDIRECT (__ppoll64_alias, (struct pollfd *__fds, nfds_t __nfds,
53 const struct timespec *__timeout,
54 const __sigset_t *__ss), __ppoll64);
55extern int __ppoll64_chk (struct pollfd *__fds, nfds_t __nfds,
56 const struct timespec *__timeout,
57 const __sigset_t *__ss, __SIZE_TYPE__ __fdslen)
58 __attr_access ((__write_only__, 1, 2));
59extern int __REDIRECT (__ppoll64_chk_warn, (struct pollfd *__fds, nfds_t __n,
60 const struct timespec *__timeout,
61 const __sigset_t *__ss,
62 __SIZE_TYPE__ __fdslen),
63 __ppoll64_chk)
64 __warnattr ("ppoll called with fds buffer too small file nfds entries");
65
66__fortify_function __fortified_attr_access (__write_only__, 1, 2)
67__attribute_overloadable__ int
68ppoll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
69 const struct timespec *__timeout, const __sigset_t *__ss)
70 __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
71 "ppoll called with fds buffer "
72 "too small file nfds entries")
73{
74 return __glibc_fortify (ppoll64, __nfds, sizeof (*__fds),
75 __glibc_objsize (__fds),
76 __fds, __nfds, __timeout, __ss);
77}
78# else
79extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
80 const struct timespec *__timeout,
81 const __sigset_t *__ss), ppoll);
82extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds,
83 const struct timespec *__timeout,
84 const __sigset_t *__ss, __SIZE_TYPE__ __fdslen)
85 __attr_access ((__write_only__, 1, 2));
86extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
87 const struct timespec *__timeout,
88 const __sigset_t *__ss,
89 __SIZE_TYPE__ __fdslen),
90 __ppoll_chk)
91 __warnattr ("ppoll called with fds buffer too small file nfds entries");
92
93__fortify_function __fortified_attr_access (__write_only__, 1, 2)
94__attribute_overloadable__ int
95ppoll (__fortify_clang_overload_arg (struct pollfd *, ,__fds), nfds_t __nfds,
96 const struct timespec *__timeout, const __sigset_t *__ss)
97 __fortify_clang_warning_only_if_bos_lt2 (__nfds, __fds, sizeof (*__fds),
98 "ppoll called with fds buffer "
99 "too small file nfds entries")
100{
101 return __glibc_fortify (ppoll, __nfds, sizeof (*__fds),
102 __glibc_objsize (__fds),
103 __fds, __nfds, __timeout, __ss);
104}
105# endif
106#endif
107
108__END_DECLS