summaryrefslogtreecommitdiff
path: root/include/poll.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/poll.h')
-rw-r--r--include/poll.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/poll.h b/include/poll.h
new file mode 100644
index 0000000..54fc4ab
--- /dev/null
+++ b/include/poll.h
@@ -0,0 +1,25 @@
1#ifndef FORTIFY_POLL_H_
2#define FORTIFY_POLL_H_
3
4#include_next <stddef.h>
5#include_next <poll.h>
6
7#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
8
9static inline __attribute__ ((always_inline))
10int
11__fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout)
12{
13 size_t bos = __builtin_object_size(fds, 0);
14
15 if (bos != -1 && nfds > bos / sizeof(struct pollfd))
16 __builtin_trap();
17 return poll(fds, nfds, timeout);
18}
19
20#undef poll
21#define poll(fds, nfds, timeout) __fortify_poll(fds, nfds, timeout)
22
23#endif
24
25#endif