glob.c: Silence warning about void pointer arithmetic
[gnulib.git] / m4 / inet_ntop.m4
blob9532647ccef596eccf7948f43634006a99b26ffc
1 # inet_ntop.m4 serial 20
2 dnl Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_INET_NTOP],
9   AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
11   dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14   AC_REQUIRE([AC_C_RESTRICT])
16   dnl Most platforms that provide inet_ntop define it in libc.
17   dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18   dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19   dnl Haiku provides it in -lnetwork.
20   dnl Native Windows provides it in -lws2_32 instead, with a declaration in
21   dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
22   dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
23   HAVE_INET_NTOP=1
24   INET_NTOP_LIB=
25   gl_PREREQ_SYS_H_WINSOCK2
26   if test $HAVE_WINSOCK2_H = 1; then
27     AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
28     if test $ac_cv_have_decl_inet_ntop = yes; then
29       dnl It needs to be overridden, because the stdcall calling convention
30       dnl is not compliant with POSIX.
31       REPLACE_INET_NTOP=1
32       INET_NTOP_LIB="-lws2_32"
33     else
34       HAVE_DECL_INET_NTOP=0
35       HAVE_INET_NTOP=0
36     fi
37   else
38     gl_save_LIBS=$LIBS
39     AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
40       [AC_CHECK_FUNCS([inet_ntop])
41        if test $ac_cv_func_inet_ntop = no; then
42          HAVE_INET_NTOP=0
43        fi
44       ])
45     LIBS=$gl_save_LIBS
47     if test "$ac_cv_search_inet_ntop" != "no" \
48        && test "$ac_cv_search_inet_ntop" != "none required"; then
49       INET_NTOP_LIB="$ac_cv_search_inet_ntop"
50     fi
52     AC_CHECK_HEADERS_ONCE([netdb.h])
53     AC_CHECK_DECLS([inet_ntop],,,
54       [[#include <arpa/inet.h>
55         #if HAVE_NETDB_H
56         # include <netdb.h>
57         #endif
58       ]])
59     if test $ac_cv_have_decl_inet_ntop = no; then
60       HAVE_DECL_INET_NTOP=0
61     fi
62   fi
63   AC_SUBST([INET_NTOP_LIB])
66 # Prerequisites of lib/inet_ntop.c.
67 AC_DEFUN([gl_PREREQ_INET_NTOP], [
68   AC_REQUIRE([gl_SOCKET_FAMILIES])