poll.h (1621B)
1 /* 2 * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 */ 15 16 #ifndef _FORTIFY_POLL_H 17 #define _FORTIFY_POLL_H 18 19 #ifndef __cplusplus 20 __extension__ 21 #endif 22 #include_next <poll.h> 23 24 #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 25 #include "fortify-headers.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #undef poll 32 33 _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s) 34 { 35 __typeof__(sizeof 0) __b = __builtin_object_size(__f, 0); 36 37 if (__n > __b / sizeof(struct pollfd)) 38 __builtin_trap(); 39 return __orig_poll(__f, __n, __s); 40 } 41 42 #ifdef _GNU_SOURCE 43 #undef ppoll 44 _FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s, 45 const sigset_t *__m) 46 { 47 __typeof__(sizeof 0) __b = __builtin_object_size(__f, 0); 48 49 if (__n > __b / sizeof(struct pollfd)) 50 __builtin_trap(); 51 return __orig_ppoll(__f, __n, __s, __m); 52 } 53 #endif 54 55 #ifdef __cplusplus 56 } 57 #endif 58 59 #endif 60 61 #endif