summaryrefslogtreecommitdiffstats
path: root/gl/m4/getaddrinfo.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/getaddrinfo.m4')
-rw-r--r--gl/m4/getaddrinfo.m460
1 files changed, 58 insertions, 2 deletions
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 8e209177..8a63600b 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,14 +1,16 @@
1# getaddrinfo.m4 1# getaddrinfo.m4
2# serial 35 2# serial 39
3dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. 3dnl Copyright (C) 2004-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8AC_DEFUN([gl_GETADDRINFO], 9AC_DEFUN([gl_GETADDRINFO],
9[ 10[
10 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 11 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
11 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H 12 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
13 AC_REQUIRE([AC_CANONICAL_HOST])
12 GETADDRINFO_LIB= 14 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS" 15 gai_saved_LIBS="$LIBS"
14 16
@@ -87,6 +89,60 @@ int getaddrinfo (const char *, const char *, const struct addrinfo *, struct add
87 HAVE_GETADDRINFO=0 89 HAVE_GETADDRINFO=0
88 fi 90 fi
89 fi 91 fi
92 if test $HAVE_GETADDRINFO != 0; then
93 AC_CACHE_CHECK([whether getaddrinfo supports AI_NUMERICHOST and AI_NUMERICSERV],
94 [gl_cv_func_getaddrinfo_works],
95 [AC_RUN_IFELSE(
96 [AC_LANG_PROGRAM([[
97#include <sys/types.h>
98#ifdef HAVE_SYS_SOCKET_H
99#include <sys/socket.h>
100#endif
101#ifdef HAVE_NETDB_H
102#include <netdb.h>
103#endif
104#ifdef HAVE_WS2TCPIP_H
105#include <ws2tcpip.h>
106#endif
107#include <stddef.h>
108#include <string.h>
109 ]], [[
110 int result = 0;
111 struct addrinfo *ai;
112 {
113 struct addrinfo hints;
114 memset (&hints, 0, sizeof (hints));
115 hints.ai_flags = AI_NUMERICHOST;
116 if (getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME)
117 result |= 1;
118 }
119 {
120 struct addrinfo hints;
121 memset (&hints, 0, sizeof (hints));
122 hints.ai_flags = AI_NUMERICSERV;
123 if (getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME)
124 result |= 2;
125 }
126 return result;
127 ]])
128 ],
129 [gl_cv_func_getaddrinfo_works=yes],
130 [gl_cv_func_getaddrinfo_works=no],
131 [case "$host_os" in
132 # Guess no on Solaris.
133 solaris*) gl_cv_func_getaddrinfo_works="guessing no" ;;
134 # Guess no on native Windows.
135 mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
136 # Guess yes otherwise.
137 *) gl_cv_func_getaddrinfo_works="guessing yes" ;;
138 esac
139 ])
140 ])
141 case "$gl_cv_func_getaddrinfo_works" in
142 *yes) ;;
143 *) REPLACE_GETADDRINFO=1 ;;
144 esac
145 fi
90 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO], 146 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
91 [Define to 1 if getaddrinfo exists, or to 0 otherwise.]) 147 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
92 148