diff options
Diffstat (limited to 'gl/m4/sys_socket_h.m4')
-rw-r--r-- | gl/m4/sys_socket_h.m4 | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index 9486377..98a1041 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 | |||
@@ -1,12 +1,12 @@ | |||
1 | # sys_socket_h.m4 serial 23 | 1 | # sys_socket_h.m4 serial 29 |
2 | dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | dnl From Simon Josefsson. | 7 | dnl From Simon Josefsson. |
8 | 8 | ||
9 | AC_DEFUN([gl_HEADER_SYS_SOCKET], | 9 | AC_DEFUN_ONCE([gl_SYS_SOCKET_H], |
10 | [ | 10 | [ |
11 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) | 11 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) |
12 | AC_REQUIRE([AC_CANONICAL_HOST]) | 12 | AC_REQUIRE([AC_CANONICAL_HOST]) |
@@ -22,6 +22,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], | |||
22 | ;; | 22 | ;; |
23 | esac | 23 | esac |
24 | 24 | ||
25 | GL_GENERATE_SYS_SOCKET_H=false | ||
25 | AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], | 26 | AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], |
26 | [gl_cv_header_sys_socket_h_selfcontained], | 27 | [gl_cv_header_sys_socket_h_selfcontained], |
27 | [ | 28 | [ |
@@ -44,7 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], | |||
44 | [gl_cv_header_sys_socket_h_shut=no]) | 45 | [gl_cv_header_sys_socket_h_shut=no]) |
45 | ]) | 46 | ]) |
46 | if test $gl_cv_header_sys_socket_h_shut = no; then | 47 | if test $gl_cv_header_sys_socket_h_shut = no; then |
47 | SYS_SOCKET_H='sys/socket.h' | 48 | GL_GENERATE_SYS_SOCKET_H=true |
48 | fi | 49 | fi |
49 | fi | 50 | fi |
50 | fi | 51 | fi |
@@ -83,7 +84,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], | |||
83 | fi | 84 | fi |
84 | if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ | 85 | if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ |
85 | || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then | 86 | || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then |
86 | SYS_SOCKET_H='sys/socket.h' | 87 | GL_GENERATE_SYS_SOCKET_H=true |
87 | fi | 88 | fi |
88 | gl_PREREQ_SYS_H_WINSOCK2 | 89 | gl_PREREQ_SYS_H_WINSOCK2 |
89 | 90 | ||
@@ -95,6 +96,8 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], | |||
95 | #include <sys/socket.h> | 96 | #include <sys/socket.h> |
96 | ]], [socket connect accept bind getpeername getsockname getsockopt | 97 | ]], [socket connect accept bind getpeername getsockname getsockopt |
97 | listen recv send recvfrom sendto setsockopt shutdown accept4]) | 98 | listen recv send recvfrom sendto setsockopt shutdown accept4]) |
99 | |||
100 | AC_REQUIRE([AC_C_RESTRICT]) | ||
98 | ]) | 101 | ]) |
99 | 102 | ||
100 | AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], | 103 | AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], |
@@ -104,17 +107,11 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], | |||
104 | gl_CHECK_NEXT_HEADERS([sys/socket.h]) | 107 | gl_CHECK_NEXT_HEADERS([sys/socket.h]) |
105 | if test $ac_cv_header_sys_socket_h = yes; then | 108 | if test $ac_cv_header_sys_socket_h = yes; then |
106 | HAVE_SYS_SOCKET_H=1 | 109 | HAVE_SYS_SOCKET_H=1 |
107 | HAVE_WS2TCPIP_H=0 | ||
108 | else | 110 | else |
109 | HAVE_SYS_SOCKET_H=0 | 111 | HAVE_SYS_SOCKET_H=0 |
110 | if test $ac_cv_header_ws2tcpip_h = yes; then | ||
111 | HAVE_WS2TCPIP_H=1 | ||
112 | else | ||
113 | HAVE_WS2TCPIP_H=0 | ||
114 | fi | ||
115 | fi | 112 | fi |
116 | AC_SUBST([HAVE_SYS_SOCKET_H]) | 113 | AC_SUBST([HAVE_SYS_SOCKET_H]) |
117 | AC_SUBST([HAVE_WS2TCPIP_H]) | 114 | gl_PREREQ_SYS_H_WS2TCPIP |
118 | ]) | 115 | ]) |
119 | 116 | ||
120 | # Common prerequisites of the <sys/socket.h> replacement and of the | 117 | # Common prerequisites of the <sys/socket.h> replacement and of the |
@@ -142,32 +139,65 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2], | |||
142 | AC_SUBST([HAVE_WINSOCK2_H]) | 139 | AC_SUBST([HAVE_WINSOCK2_H]) |
143 | ]) | 140 | ]) |
144 | 141 | ||
142 | # Common prerequisites of the <sys/socket.h> replacement and of the | ||
143 | # <arpa/inet.h> replacement. | ||
144 | # Sets and substitutes HAVE_WS2TCPIP_H. | ||
145 | AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP], | ||
146 | [ | ||
147 | AC_REQUIRE([gl_CHECK_SOCKET_HEADERS]) | ||
148 | if test $ac_cv_header_sys_socket_h = yes; then | ||
149 | HAVE_WS2TCPIP_H=0 | ||
150 | else | ||
151 | if test $ac_cv_header_ws2tcpip_h = yes; then | ||
152 | HAVE_WS2TCPIP_H=1 | ||
153 | else | ||
154 | HAVE_WS2TCPIP_H=0 | ||
155 | fi | ||
156 | fi | ||
157 | AC_SUBST([HAVE_WS2TCPIP_H]) | ||
158 | ]) | ||
159 | |||
160 | # gl_SYS_SOCKET_MODULE_INDICATOR([modulename]) | ||
161 | # sets the shell variable that indicates the presence of the given module | ||
162 | # to a C preprocessor expression that will evaluate to 1. | ||
163 | # This macro invocation must not occur in macros that are AC_REQUIREd. | ||
145 | AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], | 164 | AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], |
146 | [ | 165 | [ |
147 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | 166 | dnl Ensure to expand the default settings once only. |
148 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) | 167 | gl_SYS_SOCKET_H_REQUIRE_DEFAULTS |
149 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | 168 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
150 | dnl Define it also as a C macro, for the benefit of the unit tests. | 169 | dnl Define it also as a C macro, for the benefit of the unit tests. |
151 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | 170 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
152 | ]) | 171 | ]) |
153 | 172 | ||
173 | # Initializes the default values for AC_SUBSTed shell variables. | ||
174 | # This macro must not be AC_REQUIREd. It must only be invoked, and only | ||
175 | # outside of macros or in macros that are not AC_REQUIREd. | ||
176 | AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS], | ||
177 | [ | ||
178 | m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [ | ||
179 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET]) | ||
180 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT]) | ||
181 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT]) | ||
182 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND]) | ||
183 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME]) | ||
184 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME]) | ||
185 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT]) | ||
186 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN]) | ||
187 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV]) | ||
188 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND]) | ||
189 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM]) | ||
190 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO]) | ||
191 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT]) | ||
192 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN]) | ||
193 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4]) | ||
194 | ]) | ||
195 | m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS]) | ||
196 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) | ||
197 | ]) | ||
198 | |||
154 | AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], | 199 | AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], |
155 | [ | 200 | [ |
156 | GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET]) | ||
157 | GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT]) | ||
158 | GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT]) | ||
159 | GNULIB_BIND=0; AC_SUBST([GNULIB_BIND]) | ||
160 | GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME]) | ||
161 | GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME]) | ||
162 | GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT]) | ||
163 | GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN]) | ||
164 | GNULIB_RECV=0; AC_SUBST([GNULIB_RECV]) | ||
165 | GNULIB_SEND=0; AC_SUBST([GNULIB_SEND]) | ||
166 | GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM]) | ||
167 | GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO]) | ||
168 | GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT]) | ||
169 | GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) | ||
170 | GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4]) | ||
171 | HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) | 201 | HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) |
172 | HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; | 202 | HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; |
173 | AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) | 203 | AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) |