1 # sys_select_h.m4 serial 14
2 dnl Copyright (C) 2006-2010 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_HEADER_SYS_SELECT],
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],
14 dnl Test against two bugs:
15 dnl 1. On many platforms, <sys/select.h> assumes prior inclusion of
17 dnl 2. On OSF/1 4.0, <sys/select.h> provides only a forward declaration
18 dnl of 'struct timeval', and no definition of this type.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
20 [[struct timeval b;]])],
21 [gl_cv_header_sys_select_h_selfcontained=yes],
22 [gl_cv_header_sys_select_h_selfcontained=no])
23 dnl Test against another bug:
24 dnl 3. On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
25 dnl that relies on memset(), but without including <string.h>.
26 if test $gl_cv_header_sys_select_h_selfcontained = yes; then
28 [AC_LANG_PROGRAM([[#include <sys/select.h>]],
29 [[int memset; int bzero;]])
32 [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
34 #define memset nonexistent_memset
35 extern void *memset (void *, int, unsigned long);
37 #define bzero nonexistent_bzero
38 extern void bzero (void *, unsigned long);
44 [gl_cv_header_sys_select_h_selfcontained=no])
48 AC_CHECK_HEADERS_ONCE([sys/select.h])
49 dnl <sys/select.h> is always overridden, because of GNULIB_POSIXCHECK.
50 gl_CHECK_NEXT_HEADERS([sys/select.h])
51 if test $ac_cv_header_sys_select_h = yes; then
56 AC_SUBST([HAVE_SYS_SELECT_H])
57 gl_PREREQ_SYS_H_WINSOCK2
59 dnl Check for declarations of anything we want to poison if the
60 dnl corresponding gnulib module is not in use.
61 gl_WARN_ON_USE_PREPARE([[
62 /* Some systems require prerequisite headers. */
63 #include <sys/types.h>
64 #if !defined __GLIBC__ && HAVE_SYS_TIME_H
65 # include <sys/time.h>
67 #include <sys/select.h>
71 AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
73 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
74 AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
75 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
76 dnl Define it also as a C macro, for the benefit of the unit tests.
77 gl_MODULE_INDICATOR_FOR_TESTS([$1])
80 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
82 GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
83 dnl Assume proper GNU behavior unless another module says otherwise.
84 REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])