3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
9 AC_DEFUN([gl_FUNC_PSELECT],
11 AC_REQUIRE([gl_SYS_SELECT_H])
12 AC_REQUIRE([AC_C_RESTRICT])
13 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
14 AC_CHECK_FUNCS_ONCE([pselect])
16 if test $ac_cv_func_pselect = yes; then
17 AC_CACHE_CHECK([whether signature of pselect conforms to POSIX],
21 [[#include <sys/select.h>
23 [[int (*p) (int, fd_set *, fd_set *, fd_set *restrict,
24 struct timespec const *restrict,
25 sigset_t const *restrict) = pselect;
27 [gl_cv_sig_pselect=yes],
28 [gl_cv_sig_pselect=no])])
30 dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds.
31 AC_CACHE_CHECK([whether pselect detects invalid fds],
32 [gl_cv_func_pselect_detects_ebadf],
34 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
35 #include <sys/types.h>
38 # include <sys/select.h>
49 struct timespec timeout;
51 timeout.tv_nsec = 5000;
52 return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF;
53 ]])], [gl_cv_func_pselect_detects_ebadf=yes],
54 [gl_cv_func_pselect_detects_ebadf=no],
57 # Guess yes on Linux systems.
58 linux-* | linux) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
59 # Guess yes on systems that emulate the Linux system calls.
60 midipix*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
61 # Guess yes on glibc systems.
62 *-gnu* | gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
63 # If we don't know, obey --enable-cross-guesses.
64 *) gl_cv_func_pselect_detects_ebadf="$gl_cross_guess_normal" ;;
68 case $gl_cv_func_pselect_detects_ebadf in
70 *) REPLACE_PSELECT=1 ;;
74 if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then