Debian Codegraph @

m4/sys_select_h.m4

raw
1 # sys_select_h.m4
2 # serial 24
3 dnl Copyright (C) 2006-2026 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 a bug:
17 dnl 1. On many platforms, <sys/select.h> assumes prior inclusion of
18 dnl <sys/types.h>.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]], [])],
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 2. 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
26 AC_COMPILE_IFELSE(
27 [AC_LANG_PROGRAM([[#include <sys/select.h>]],
28 [[int memset; int bzero;]])
29 ],
30 [AC_LINK_IFELSE(
31 [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
32 #undef memset
33 #define memset nonexistent_memset
34 extern
35 #ifdef __cplusplus
36 "C"
37 #endif
38 void *memset (void *, int, unsigned long);
39 #undef bzero
40 #define bzero nonexistent_bzero
41 extern
42 #ifdef __cplusplus
43 "C"
44 #endif
45 void bzero (void *, unsigned long);
46 fd_set fds;
47 FD_ZERO (&fds);
48 ]])
49 ],
50 [],
51 [gl_cv_header_sys_select_h_selfcontained=no])
52 ])
53 fi
54 ])
55 dnl <sys/select.h> is always overridden, because of GNULIB_POSIXCHECK.
56 gl_CHECK_NEXT_HEADERS([sys/select.h])
57 if test $ac_cv_header_sys_select_h = yes; then
58 HAVE_SYS_SELECT_H=1
59 else
60 HAVE_SYS_SELECT_H=0
61 fi
62 AC_SUBST([HAVE_SYS_SELECT_H])
63 gl_PREREQ_SYS_H_WINSOCK2
64
65 dnl Check for declarations of anything we want to poison if the
66 dnl corresponding gnulib module is not in use.
67 gl_WARN_ON_USE_PREPARE([[
68 /* Some systems require prerequisite headers. */
69 #include <sys/types.h>
70 #if !(defined __GLIBC__ && !defined __UCLIBC__) && HAVE_SYS_TIME_H
71 # include <sys/time.h>
72 #endif
73 #include <sys/select.h>
74 ]], [pselect select])
75 ])
76
77 # gl_SYS_SELECT_MODULE_INDICATOR([modulename])
78 # sets the shell variable that indicates the presence of the given module
79 # to a C preprocessor expression that will evaluate to 1.
80 # This macro invocation must not occur in macros that are AC_REQUIREd.
81 AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
82 [
83 dnl Ensure to expand the default settings once only.
84 gl_SYS_SELECT_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88 ])
89
90 # Initializes the default values for AC_SUBSTed shell variables.
91 # This macro must not be AC_REQUIREd. It must only be invoked, and only
92 # outside of macros or in macros that are not AC_REQUIREd.
93 AC_DEFUN([gl_SYS_SELECT_H_REQUIRE_DEFAULTS],
94 [
95 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS], [
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PSELECT])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SELECT])
98 ])
99 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SELECT_H_MODULE_INDICATOR_DEFAULTS])
100 AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
101 ])
102
103 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
104 [
105 dnl Assume proper GNU behavior unless another module says otherwise.
106 HAVE_PSELECT=1; AC_SUBST([HAVE_PSELECT])
107 REPLACE_PSELECT=0; AC_SUBST([REPLACE_PSELECT])
108 REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
109 ])