Debian Codegraph @

m4/sys_select_h.m4

raw
1 # sys_select_h.m4
2 # serial 23
3 dnl Copyright (C) 2006-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN_ONCE([gl_SYS_SELECT_H],
10 [
11 AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
12 AC_REQUIRE([AC_C_RESTRICT])
13 AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
14 [gl_cv_header_sys_select_h_selfcontained],
15 [
16 dnl Test against two bugs:
17 dnl 1. On many platforms, <sys/select.h> assumes prior inclusion of
18 dnl <sys/types.h>.
19 dnl 2. On OSF/1 4.0, <sys/select.h> provides only a forward declaration
20 dnl of 'struct timeval', and no definition of this type.
21 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
22 [[struct timeval b;]])],
23 [gl_cv_header_sys_select_h_selfcontained=yes],
24 [gl_cv_header_sys_select_h_selfcontained=no])
25 dnl Test against another bug:
26 dnl 3. On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
27 dnl that relies on memset(), but without including <string.h>.
28 if test $gl_cv_header_sys_select_h_selfcontained = yes; then
29 AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM([[#include <sys/select.h>]],
31 [[int memset; int bzero;]])
32 ],
33 [AC_LINK_IFELSE(
34 [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
35 #undef memset
36 #define memset nonexistent_memset
37 extern
38 #ifdef __cplusplus
39 "C"
40 #endif
41 void *memset (void *, int, unsigned long);
42 #undef bzero
43 #define bzero nonexistent_bzero
44 extern
45 #ifdef __cplusplus
46 "C"
47 #endif
48 void bzero (void *, unsigned long);
49 fd_set fds;
50 FD_ZERO (&fds);
51 ]])
52 ],
53 [],
54 [gl_cv_header_sys_select_h_selfcontained=no])
55 ])
56 fi
57 ])
58 dnl <sys/select.h> is always overridden, because of GNULIB_POSIXCHECK.
59 gl_CHECK_NEXT_HEADERS([sys/select.h])
60 if test $ac_cv_header_sys_select_h = yes; then
61 HAVE_SYS_SELECT_H=1
62 else
63 HAVE_SYS_SELECT_H=0
64 fi
65 AC_SUBST([HAVE_SYS_SELECT_H])
66 gl_PREREQ_SYS_H_WINSOCK2
67
68 dnl Check for declarations of anything we want to poison if the
69 dnl corresponding gnulib module is not in use.
70 gl_WARN_ON_USE_PREPARE([[
71 /* Some systems require prerequisite headers. */
72 #include <sys/types.h>
73 #if !(defined __GLIBC__ && !defined __UCLIBC__) && HAVE_SYS_TIME_H
74 # include <sys/time.h>
75 #endif
76 #include <sys/select.h>
77 ]], [pselect select])
78 ])
79
80 # gl_SYS_SELECT_MODULE_INDICATOR([modulename])
81 # sets the shell variable that indicates the presence of the given module
82 # to a C preprocessor expression that will evaluate to 1.
83 # This macro invocation must not occur in macros that are AC_REQUIREd.
84 AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
85 [
86 dnl Ensure to expand the default settings once only.
87 gl_SYS_SELECT_H_REQUIRE_DEFAULTS
88 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
89 dnl Define it also as a C macro, for the benefit of the unit tests.
90 gl_MODULE_INDICATOR_FOR_TESTS([$1])
91 ])
92
93 # Initializes the default values for AC_SUBSTed shell variables.
94 # This macro must not be AC_REQUIREd. It must only be invoked, and only
95 # outside of macros or in macros that are not AC_REQUIREd.
96 AC_DEFUN([gl_SYS_SELECT_H_REQUIRE_DEFAULTS],
97 [
98 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS], [
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PSELECT])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SELECT])
101 ])
102 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS])
103 AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
104 ])
105
106 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
107 [
108 dnl Assume proper GNU behavior unless another module says otherwise.
109 HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT])
110 REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT])
111 REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
112 ])