explicitely test for ws2tcpip.h header, fix library detection on windows for inet_ntop with corrent library, guard includes and definitions with configure results, cleanup header inclusion

This commit is contained in:
Riccardo Mottola 2020-06-09 13:44:42 +02:00
parent 94e10f0447
commit b879e0835b
5 changed files with 41 additions and 11 deletions

View file

@ -785,6 +785,9 @@
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if you have the <ws2tcpip.h> header file. */
#undef HAVE_WS2TCPIP_H
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H

View file

@ -56,12 +56,21 @@
#endif
#ifdef _WIN32
extern const char *inet_ntop(int, const void *, char *, size_t);
extern int inet_pton(int , const char *, void *);
#define OPTLEN int
#else
#define OPTLEN socklen_t
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif // HAVE_WS2TCPIP_H
#if !defined(HAVE_INET_NTOP)
extern const char *inet_ntop(int, const void *, char *, size_t);
#endif
#if !defined(HAVE_INET_NTOP)
extern int inet_pton(int , const char *, void *);
#endif
#define OPTLEN int
#else // _WIN32
#define OPTLEN socklen_t
#endif // _WIN32
unsigned
GSPrivateSockaddrLength(struct sockaddr *addr)

View file

@ -39,17 +39,22 @@
#import "Foundation/NSCoder.h"
#if defined(_WIN32)
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif // HAVE_WS2TCPIP_H
#if !defined(HAVE_INET_NTOP)
extern const char *inet_ntop(int, const void *, char *, size_t);
#endif
#if !defined(HAVE_INET_NTOP)
extern int inet_pton(int , const char *, void *);
#else
#endif
#else /* !_WIN32 */
#include <netdb.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif /* !_WIN32*/
#endif /* !_WIN32 */
#ifndef INADDR_NONE
#define INADDR_NONE -1

14
configure vendored
View file

@ -9721,6 +9721,18 @@ fi
# These used by GSFileHandle.m and distributed objects
# On some systems we need -lnsl ... so check for that case.
#--------------------------------------------------------------------
for ac_header in ws2tcpip.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default"
if test "x$ac_cv_header_ws2tcpip_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_WS2TCPIP_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5
$as_echo_n "checking for library containing inet_ntop... " >&6; }
if ${ac_cv_search_inet_ntop+:} false; then :
@ -9745,7 +9757,7 @@ return inet_ntop ();
return 0;
}
_ACEOF
for ac_lib in '' nsl; do
for ac_lib in '' nsl Ws2_32; do
if test -z "$ac_lib"; then
ac_res="none required"
else

View file

@ -2497,7 +2497,8 @@ AC_SUBST(DEFINE_UINTPTR_T)
# These used by GSFileHandle.m and distributed objects
# On some systems we need -lnsl ... so check for that case.
#--------------------------------------------------------------------
AC_SEARCH_LIBS([inet_ntop],[nsl])
AC_CHECK_HEADERS(ws2tcpip.h)
AC_SEARCH_LIBS([inet_ntop],[nsl Ws2_32])
AC_CHECK_FUNCS(gethostbyaddr_r inet_aton inet_pton inet_ntop sigaction)
USE_ZLIB=0