Work around select() bug on Interix 3.5.
[gnulib.git] / m4 / sys_select_h.m4
1 # sys_select_h.m4 serial 7
2 dnl Copyright (C) 2006-2009 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.
6
7 AC_DEFUN([gl_HEADER_SYS_SELECT],
8 [
9   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
10   AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
11   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
12     [gl_cv_header_sys_select_h_selfcontained],
13     [
14       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
15                                          [[struct timeval b;]])],
16         [gl_cv_header_sys_select_h_selfcontained=yes],
17         [gl_cv_header_sys_select_h_selfcontained=no])
18     ])
19   if test $gl_cv_header_sys_select_h_selfcontained = yes; then
20     SYS_SELECT_H=''
21   else
22     SYS_SELECT_H='sys/select.h'
23     gl_CHECK_NEXT_HEADERS([sys/select.h])
24     if test $ac_cv_header_sys_select_h = yes; then
25       HAVE_SYS_SELECT_H=1
26     else
27       HAVE_SYS_SELECT_H=0
28     fi
29     AC_SUBST([HAVE_SYS_SELECT_H])
30     gl_PREREQ_SYS_H_WINSOCK2
31   fi
32   AC_SUBST([SYS_SELECT_H])
33 ])
34
35 AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
36 [
37   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
38   AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
39   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
40 ])
41
42 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
43 [
44   GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
45   dnl Assume proper GNU behavior unless another module says otherwise.
46   REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
47 ])