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.m446
1 files changed, 44 insertions, 2 deletions
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 8e209177..2931d526 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 38
3dnl Copyright (C) 2004-2024 Free Software Foundation, Inc. 3dnl Copyright (C) 2004-2025 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,46 @@ 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_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 struct addrinfo hints;
111 struct addrinfo *ai;
112 memset (&hints, 0, sizeof (hints));
113 hints.ai_flags = AI_NUMERICSERV;
114 return getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME;
115 ]])
116 ],
117 [gl_cv_func_getaddrinfo_works=yes],
118 [gl_cv_func_getaddrinfo_works=no],
119 [case "$host_os" in
120 # Guess no on native Windows.
121 mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
122 # Guess yes otherwise.
123 *) gl_cv_func_getaddrinfo_works="guessing yes" ;;
124 esac
125 ])
126 ])
127 case "$gl_cv_func_getaddrinfo_works" in
128 *yes) ;;
129 *) REPLACE_GETADDRINFO=1 ;;
130 esac
131 fi
90 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO], 132 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
91 [Define to 1 if getaddrinfo exists, or to 0 otherwise.]) 133 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
92 134