vasnwprintf tests: Add test of huge %ls arguments.
[gnulib.git] / m4 / inet_pton.m4
blob28ae9c061617c23c386ae1fe35333c9a79ac0423
1 # inet_pton.m4
2 # serial 20
3 dnl Copyright (C) 2006, 2008-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.
8 AC_DEFUN([gl_FUNC_INET_PTON],
10   AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
12   dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15   AC_REQUIRE([AC_C_RESTRICT])
17   dnl Most platforms that provide inet_pton define it in libc.
18   dnl Solaris 8..10 provide inet_pton in libnsl instead.
19   dnl Solaris 2.6..7 provide inet_pton in libresolv instead.
20   dnl Haiku provides it in -lnetwork.
21   dnl Native Windows provides it in -lws2_32 instead, with a declaration in
22   dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
23   dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
24   HAVE_INET_PTON=1
25   INET_PTON_LIB=
26   gl_PREREQ_SYS_H_WINSOCK2
27   if test $HAVE_WINSOCK2_H = 1; then
28     dnl It needs to be overridden, because the stdcall calling convention
29     dnl is not compliant with POSIX.  Set REPLACE_INET_PTON in order to avoid
30     dnl a name conflict at the linker level, even though the header file
31     dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600.
32     REPLACE_INET_PTON=1
33     AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
34     if test $ac_cv_have_decl_inet_pton = yes; then
35       INET_PTON_LIB="-lws2_32"
36     else
37       HAVE_DECL_INET_PTON=0
38     fi
39   else
40     gl_saved_LIBS=$LIBS
41     AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [],
42       [AC_CHECK_FUNCS([inet_pton])
43        if test $ac_cv_func_inet_pton = no; then
44          HAVE_INET_PTON=0
45        fi
46       ])
47     LIBS=$gl_saved_LIBS
49     if test "$ac_cv_search_inet_pton" != "no" \
50        && test "$ac_cv_search_inet_pton" != "none required"; then
51       INET_PTON_LIB="$ac_cv_search_inet_pton"
52     fi
54     AC_CHECK_HEADERS_ONCE([netdb.h])
55     AC_CHECK_DECLS([inet_pton],,,
56       [[#include <arpa/inet.h>
57         #if HAVE_NETDB_H
58         # include <netdb.h>
59         #endif
60       ]])
61     if test $ac_cv_have_decl_inet_pton = no; then
62       HAVE_DECL_INET_PTON=0
63     fi
64   fi
65   AC_SUBST([INET_PTON_LIB])
68 # Prerequisites of lib/inet_pton.c.
69 AC_DEFUN([gl_PREREQ_INET_PTON], [
70   AC_REQUIRE([gl_SOCKET_FAMILIES])