2 dnl Copyright (C) 2011-2020 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>
47 struct timespec timeout;
49 timeout.tv_nsec = 5000;
50 return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF;
51 ]])], [gl_cv_func_pselect_detects_ebadf=yes],
52 [gl_cv_func_pselect_detects_ebadf=no],
55 # Guess yes on Linux systems.
56 linux-* | linux) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
57 # Guess yes on glibc systems.
58 *-gnu* | gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
59 # If we don't know, obey --enable-cross-guesses.
60 *) gl_cv_func_pselect_detects_ebadf="$gl_cross_guess_normal" ;;
64 case $gl_cv_func_pselect_detects_ebadf in
66 *) REPLACE_PSELECT=1 ;;
70 if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then