2 dnl Copyright (C) 2011-2013 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_CHECK_FUNCS_ONCE([pselect])
13 if test $ac_cv_func_pselect = yes; then
14 AC_CACHE_CHECK([whether signature of pselect conforms to POSIX],
18 [[#include <sys/select.h>
20 [[int (*p) (int, fd_set *, fd_set *, fd_set *restrict,
21 struct timespec const *restrict,
22 sigset_t const *restrict) = pselect;
24 [gl_cv_sig_pselect=yes],
25 [gl_cv_sig_pselect=no])])
27 dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds.
28 AC_CACHE_CHECK([whether pselect detects invalid fds],
29 [gl_cv_func_pselect_detects_ebadf],
31 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
32 #include <sys/types.h>
35 # include <sys/select.h>
45 struct timespec timeout;
47 timeout.tv_nsec = 5000;
48 return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF;
49 ]])], [gl_cv_func_pselect_detects_ebadf=yes],
50 [gl_cv_func_pselect_detects_ebadf=no],
53 # Guess yes on glibc systems.
54 *-gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
55 # If we don't know, assume the worst.
56 *) gl_cv_func_pselect_detects_ebadf="guessing no" ;;
60 case $gl_cv_func_pselect_detects_ebadf in
62 *) REPLACE_PSELECT=1 ;;
66 if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then