summaryrefslogtreecommitdiff
path: root/include/poll.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/poll.h')
-rw-r--r--include/poll.h29
1 files changed, 12 insertions, 17 deletions
diff --git a/include/poll.h b/include/poll.h
index 5490b94..93976dd 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -6,40 +6,35 @@
6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 6#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
7 7
8#ifndef __cplusplus 8#ifndef __cplusplus
9#undef poll
9 10
10static inline __attribute__ ((always_inline)) 11extern int __poll_orig(struct pollfd *, nfds_t, int)
11int 12 __asm__(__USER_LABEL_PREFIX__ "poll");
12__fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout) 13extern __inline __attribute__((__always_inline__,__gnu_inline__))
14int poll(struct pollfd *fds, nfds_t nfds, int timeout)
13{ 15{
14 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); 16 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
15 17
16 if (nfds > bos / sizeof(struct pollfd)) 18 if (nfds > bos / sizeof(struct pollfd))
17 __builtin_trap(); 19 __builtin_trap();
18 return poll(fds, nfds, timeout); 20 return __poll_orig(fds, nfds, timeout);
19} 21}
20 22
21#ifdef _GNU_SOURCE 23#ifdef _GNU_SOURCE
22static inline __attribute__ ((always_inline)) 24#undef ppoll
23int 25extern int __ppoll_orig(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *)
24__fortify_ppoll(struct pollfd *fds, nfds_t nfds, 26 __asm__(__USER_LABEL_PREFIX__ "ppoll");
25 const struct timespec *timeout, const sigset_t *mask) 27extern __inline __attribute__((__always_inline__,__gnu_inline__))
28int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *mask)
26{ 29{
27 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0); 30 __typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
28 31
29 if (nfds > bos / sizeof(struct pollfd)) 32 if (nfds > bos / sizeof(struct pollfd))
30 __builtin_trap(); 33 __builtin_trap();
31 return ppoll(fds, nfds, timeout, mask); 34 return __ppoll_orig(fds, nfds, timeout, mask);
32} 35}
33#endif 36#endif
34 37
35#undef poll
36#define poll(fds, nfds, timeout) __fortify_poll(fds, nfds, timeout)
37
38#ifdef _GNU_SOURCE
39#undef ppoll
40#define ppoll(fds, nfds, timeout, mask) __fortify_ppoll(fds, nfds, timeout, mask)
41#endif
42
43#endif 38#endif
44 39
45#endif 40#endif