source: trunk/src/sed/m4/pselect.m4@ 3670

Last change on this file since 3670 was 3611, checked in by bird, 10 months ago

vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)

File size: 2.4 KB
Line 
1# pselect.m4 serial 10
2dnl Copyright (C) 2011-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_PSELECT],
8[
9 AC_REQUIRE([gl_SYS_SELECT_H])
10 AC_REQUIRE([AC_C_RESTRICT])
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_CHECK_FUNCS_ONCE([pselect])
13
14 if test $ac_cv_func_pselect = yes; then
15 AC_CACHE_CHECK([whether signature of pselect conforms to POSIX],
16 [gl_cv_sig_pselect],
17 [AC_LINK_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#include <sys/select.h>
20 ]],
21 [[int (*p) (int, fd_set *, fd_set *, fd_set *restrict,
22 struct timespec const *restrict,
23 sigset_t const *restrict) = pselect;
24 return !p;]])],
25 [gl_cv_sig_pselect=yes],
26 [gl_cv_sig_pselect=no])])
27
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],
31 [
32 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
33#include <sys/types.h>
34#include <sys/time.h>
35#if HAVE_SYS_SELECT_H
36# include <sys/select.h>
37#endif
38#include <unistd.h>
39#include <errno.h>
40]GL_MDA_DEFINES],
41[[
42 fd_set set;
43 dup2(0, 16);
44 FD_ZERO(&set);
45 FD_SET(16, &set);
46 close(16);
47 struct timespec timeout;
48 timeout.tv_sec = 0;
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],
53 [
54 case "$host_os" in
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" ;;
61 esac
62 ])
63 ])
64 case $gl_cv_func_pselect_detects_ebadf in
65 *yes) ;;
66 *) REPLACE_PSELECT=1 ;;
67 esac
68 fi
69
70 if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then
71 REPLACE_PSELECT=1
72 fi
73])
Note: See TracBrowser for help on using the repository browser.