xref: /freebsd/include/ssp/poll.h (revision 74ecdf86d8d2a94a4bfcf094a2e21b4747e4907f)
188276dfbSKyle Evans /*-
288276dfbSKyle Evans  * SPDX-License-Identifier: BSD-2-Clause
388276dfbSKyle Evans  *
488276dfbSKyle Evans  * Copyright (c) 2024, Klara, Inc.
588276dfbSKyle Evans  *
688276dfbSKyle Evans  * Redistribution and use in source and binary forms, with or without
788276dfbSKyle Evans  * modification, are permitted provided that the following conditions
888276dfbSKyle Evans  * are met:
988276dfbSKyle Evans  * 1. Redistributions of source code must retain the above copyright
1088276dfbSKyle Evans  *    notice, this list of conditions and the following disclaimer.
1188276dfbSKyle Evans  * 2. Redistributions in binary form must reproduce the above copyright
1288276dfbSKyle Evans  *    notice, this list of conditions and the following disclaimer in the
1388276dfbSKyle Evans  *    documentation and/or other materials provided with the distribution.
1488276dfbSKyle Evans  *
1588276dfbSKyle Evans  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1688276dfbSKyle Evans  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1788276dfbSKyle Evans  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1888276dfbSKyle Evans  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1988276dfbSKyle Evans  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2088276dfbSKyle Evans  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2188276dfbSKyle Evans  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2288276dfbSKyle Evans  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2388276dfbSKyle Evans  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2488276dfbSKyle Evans  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2588276dfbSKyle Evans  * POSSIBILITY OF SUCH DAMAGE.
2688276dfbSKyle Evans  */
2788276dfbSKyle Evans #ifndef _SSP_POLL_H_
2888276dfbSKyle Evans #define _SSP_POLL_H_
2988276dfbSKyle Evans 
3088276dfbSKyle Evans #include <ssp/ssp.h>
3188276dfbSKyle Evans 
3288276dfbSKyle Evans #if __SSP_FORTIFY_LEVEL > 0
3388276dfbSKyle Evans 
3488276dfbSKyle Evans __BEGIN_DECLS
3588276dfbSKyle Evans 
3688276dfbSKyle Evans __ssp_redirect_raw_impl(int, poll, poll,
3788276dfbSKyle Evans     (struct pollfd fds[], nfds_t nfds, int timeout))
3888276dfbSKyle Evans {
3988276dfbSKyle Evans 	if (__ssp_bos(fds) / sizeof(fds[0]) < nfds)
4088276dfbSKyle Evans 		__chk_fail();
4188276dfbSKyle Evans 
4288276dfbSKyle Evans 	return (__ssp_real(poll)(fds, nfds, timeout));
4388276dfbSKyle Evans }
4488276dfbSKyle Evans 
45*74ecdf86SKyle Evans #if __POSIX_VISIBLE >= 202405
4688276dfbSKyle Evans __ssp_redirect_raw_impl(int, ppoll, ppoll,
4788276dfbSKyle Evans     (struct pollfd fds[], nfds_t nfds,
4888276dfbSKyle Evans     const struct timespec *__restrict timeout,
4988276dfbSKyle Evans     const sigset_t *__restrict newsigmask))
5088276dfbSKyle Evans {
5188276dfbSKyle Evans 	if (__ssp_bos(fds) / sizeof(fds[0]) < nfds)
5288276dfbSKyle Evans 		__chk_fail();
5388276dfbSKyle Evans 
5488276dfbSKyle Evans 	return (__ssp_real(ppoll)(fds, nfds, timeout, newsigmask));
5588276dfbSKyle Evans }
56*74ecdf86SKyle Evans #endif	/* __POSIX_VISIBLE >= 202405 */
5788276dfbSKyle Evans __END_DECLS
5888276dfbSKyle Evans 
5988276dfbSKyle Evans #endif /* __SSP_FORTIFY_LEVEL > 0 */
6088276dfbSKyle Evans #endif /* _SSP_POLL_H_ */
61