2 dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_PSELECT],
9 AC_REQUIRE([gl_HEADER_SYS_SELECT])
10 AC_REQUIRE([AC_C_RESTRICT])
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_CHECK_FUNCS_ONCE([pselect])
14 if test $ac_cv_func_pselect = yes; then
15 AC_CACHE_CHECK([whether signature of pselect conforms to POSIX],
19 [[#include <sys/select.h>
21 [[int (*p) (int, fd_set *, fd_set *, fd_set *restrict,
22 struct timespec const *restrict,
23 sigset_t const *restrict) = pselect;
25 [gl_cv_sig_pselect=yes],
26 [gl_cv_sig_pselect=no])])
28 dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds.
29 AC_CACHE_CHECK([whether pselect detects invalid fds],
30 [gl_cv_func_pselect_detects_ebadf],
32 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
33 #include <sys/types.h>
36 # include <sys/select.h>
46 struct timespec timeout;
48 timeout.tv_nsec = 5000;
49 return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF;
50 ]])], [gl_cv_func_pselect_detects_ebadf=yes],
51 [gl_cv_func_pselect_detects_ebadf=no],
54 # Guess yes on glibc systems.
55 *-gnu* | gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
56 # If we don't know, assume the worst.
57 *) gl_cv_func_pselect_detects_ebadf="guessing no" ;;
61 case $gl_cv_func_pselect_detects_ebadf in
63 *) REPLACE_PSELECT=1 ;;
67 if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then