From fb43df0ba64a653fce7af084b789933d2a1fda41 Mon Sep 17 00:00:00 2001 From: Stephane Fillod Date: Sat, 23 Jun 2012 16:16:12 +0200 Subject: [PATCH] Properly detect getaddrinfo() under newer mingw-w64 --- lib/getaddrinfo.c | 4 ++-- macros/hl_getaddrinfo.m4 | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 09647c74a..3cf75ca12 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -122,10 +122,10 @@ void freeaddrinfo(struct addrinfo *res) } #endif /* !HAVE_GETADDRINFO */ -#if !defined(HAVE_GAI_STRERROR) && !defined(gai_strerror) +#if !defined(HAVE_DECL_GAI_STRERROR) && !defined(gai_strerror) const char *gai_strerror(int errcode) { return strerror(errcode); } -#endif /* !HAVE_GAI_STRERROR */ +#endif /* !HAVE_DECL_GAI_STRERROR */ diff --git a/macros/hl_getaddrinfo.m4 b/macros/hl_getaddrinfo.m4 index 05fa594a5..57d7b1e52 100644 --- a/macros/hl_getaddrinfo.m4 +++ b/macros/hl_getaddrinfo.m4 @@ -33,7 +33,37 @@ AC_CHECK_TYPES([struct addrinfo],[],[],[ #endif ]) -AC_CHECK_FUNCS([getaddrinfo gai_strerror]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + #if HAVE_NETDB_H + # include + #endif + #ifdef HAVE_SYS_SOCKET_H + # include + #elif HAVE_WS2TCPIP_H + # include + #endif + #include + ]], + [[getaddrinfo("", "", NULL, NULL);]])], + [ac_cv_func_getaddrinfo=yes + AC_DEFINE(HAVE_GETADDRINFO,[1],[Define if getaddrinfo is available])], + [ac_cv_func_getaddrinfo=no]) + + +AC_CHECK_DECLS([gai_strerror], [], [], [[ + #include + #ifdef HAVE_SYS_SOCKET_H + #include + #endif + #ifdef HAVE_NETDB_H + #include + #endif + #ifdef HAVE_WS2TCPIP_H + #include + #endif + #include + ]]) dnl Checks for replacements AC_REPLACE_FUNCS([getaddrinfo]) @@ -96,9 +126,9 @@ int getaddrinfo(const char *node, const char *service, void freeaddrinfo(struct addrinfo *res); #endif -#if !defined(HAVE_GAI_STRERROR) && !defined(gai_strerror) +#if !defined(HAVE_DECL_GAI_STRERROR) && !defined(gai_strerror) const char *gai_strerror(int errcode); -#endif /* !HAVE_GAI_STRERROR */ +#endif /* !HAVE_DECL_GAI_STRERROR */ #ifdef __cplusplus }