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