Mercurial > hg > octave-kai > gnulib-hg
comparison m4/inet_ntop.m4 @ 15633:c2c292001fc0
inet_ntop: Support for MSVC on Windows Vista or newer.
* lib/arpa_inet.in.h (inet_ntop): Also consider REPLACE_INET_NTOP.
* lib/inet_ntop.c (rpl_inet_ntop): Use a simple wrapper if
HAVE_DECL_INET_NTOP is defined.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Invoke gl_PREREQ_SYS_H_WINSOCK2.
On platforms with <winsock2.h>, test whether inet_ntop is declared in
<ws2tcpip.h>. If so, arrange to replace it.
* m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Initialize
REPLACE_INET_NTOP.
* modules/arpa_inet (Makefile.am): Substitute REPLACE_INET_NTOP.
* modules/inet_ntop (Files): Add m4/sys_socket_h.m4.
(Depends-on, configure.ac): Update condition.
* doc/posix-functions/inet_ntop.texi: Mention the MSVC problem.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 17 Sep 2011 14:56:11 +0200 |
parents | 9d4b273deacd |
children | 54ccb1d64384 |
comparison
equal
deleted
inserted
replaced
15632:c96b3b10e579 | 15633:c2c292001fc0 |
---|---|
1 # inet_ntop.m4 serial 16 | 1 # inet_ntop.m4 serial 17 |
2 dnl Copyright (C) 2005-2006, 2008-2011 Free Software Foundation, Inc. | 2 dnl Copyright (C) 2005-2006, 2008-2011 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 AC_DEFUN([gl_FUNC_INET_NTOP], | 7 AC_DEFUN([gl_FUNC_INET_NTOP], |
8 [ | 8 [ |
9 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. | 9 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. |
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
11 | 11 |
12 AC_REQUIRE([AC_C_RESTRICT]) | |
13 | |
12 dnl Most platforms that provide inet_ntop define it in libc. | 14 dnl Most platforms that provide inet_ntop define it in libc. |
13 dnl Solaris 8..10 provide inet_ntop in libnsl instead. | 15 dnl Solaris 8..10 provide inet_ntop in libnsl instead. |
16 dnl Native Windows provides it in -lws2_32 instead, with a declaration in | |
17 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl | |
18 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). | |
14 HAVE_INET_NTOP=1 | 19 HAVE_INET_NTOP=1 |
15 gl_save_LIBS=$LIBS | 20 INET_NTOP_LIB= |
16 AC_SEARCH_LIBS([inet_ntop], [nsl], [], | 21 gl_PREREQ_SYS_H_WINSOCK2 |
17 [AC_CHECK_FUNCS([inet_ntop]) | 22 if test $HAVE_WINSOCK2_H = 1; then |
18 if test $ac_cv_func_inet_ntop = no; then | 23 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) |
19 HAVE_INET_NTOP=0 | 24 if test $ac_cv_have_decl_inet_ntop = yes; then |
20 fi | 25 dnl It needs to be overridden, because the stdcall calling convention |
21 ]) | 26 dnl is not compliant with POSIX. |
22 LIBS=$gl_save_LIBS | 27 REPLACE_INET_NTOP=1 |
28 INET_NTOP_LIB="-lws2_32" | |
29 else | |
30 HAVE_DECL_INET_NTOP=0 | |
31 HAVE_INET_NTOP=0 | |
32 fi | |
33 else | |
34 gl_save_LIBS=$LIBS | |
35 AC_SEARCH_LIBS([inet_ntop], [nsl], [], | |
36 [AC_CHECK_FUNCS([inet_ntop]) | |
37 if test $ac_cv_func_inet_ntop = no; then | |
38 HAVE_INET_NTOP=0 | |
39 fi | |
40 ]) | |
41 LIBS=$gl_save_LIBS | |
23 | 42 |
24 INET_NTOP_LIB= | 43 if test "$ac_cv_search_inet_ntop" != "no" \ |
25 if test "$ac_cv_search_inet_ntop" != "no" && | 44 && test "$ac_cv_search_inet_ntop" != "none required"; then |
26 test "$ac_cv_search_inet_ntop" != "none required"; then | 45 INET_NTOP_LIB="$ac_cv_search_inet_ntop" |
27 INET_NTOP_LIB="$ac_cv_search_inet_ntop" | 46 fi |
47 | |
48 AC_CHECK_HEADERS_ONCE([netdb.h]) | |
49 AC_CHECK_DECLS([inet_ntop],,, | |
50 [[#include <arpa/inet.h> | |
51 #if HAVE_NETDB_H | |
52 # include <netdb.h> | |
53 #endif | |
54 ]]) | |
55 if test $ac_cv_have_decl_inet_ntop = no; then | |
56 HAVE_DECL_INET_NTOP=0 | |
57 fi | |
28 fi | 58 fi |
29 AC_SUBST([INET_NTOP_LIB]) | 59 AC_SUBST([INET_NTOP_LIB]) |
30 | |
31 AC_CHECK_HEADERS_ONCE([netdb.h]) | |
32 AC_CHECK_DECLS([inet_ntop],,, | |
33 [[#include <arpa/inet.h> | |
34 #if HAVE_NETDB_H | |
35 # include <netdb.h> | |
36 #endif | |
37 ]]) | |
38 if test $ac_cv_have_decl_inet_ntop = no; then | |
39 HAVE_DECL_INET_NTOP=0 | |
40 AC_REQUIRE([AC_C_RESTRICT]) | |
41 fi | |
42 ]) | 60 ]) |
43 | 61 |
44 # Prerequisites of lib/inet_ntop.c. | 62 # Prerequisites of lib/inet_ntop.c. |
45 AC_DEFUN([gl_PREREQ_INET_NTOP], [ | 63 AC_DEFUN([gl_PREREQ_INET_NTOP], [ |
46 AC_REQUIRE([gl_SOCKET_FAMILIES]) | 64 AC_REQUIRE([gl_SOCKET_FAMILIES]) |