w32: Modernize for MinGW 6.0.0, and clean up
We provide gettimeofday() only #ifdef _MSC_VER, but declare it unconditionally in our own sys/time.h. This is asking for trouble. Declare it only #ifdef _MSC_VER, else pull in MinGW's sys/time.h with #include_next. Likewise, define macros ftruncate(), S_IRUSR & friends in our own unistd.h only #ifdef _MSC_VER, else pull in MinGW's unistd.h with #include_next. The #include <getopt.h> is now useless, drop. src/lib/commands/info.c relies on sys/time.h including windows.h. Unclean, and no longer the case with MinGW. Include it directly. MinGW provides EWOULDBLOCK. Drop our replacement. MinGW provides inet_ntop() in ws2tcpip.h, but only if feature test macro _WIN32_WINNT >= 0x600, i.e. Windows Vista or later. It defaults to 0x0502 (Windows Server 2003). Make configure #define _WIN32_WINNT 0x0601 in config.h. This requests Windows 7. Trying to support Vista feels unwise. Include ws2tcpip.h, and drop our replacement. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
598669673e
commit
a164390d1f
8 changed files with 26 additions and 53 deletions
|
@ -232,43 +232,6 @@ w32_socket(int domain, int type, int protocol)
|
|||
return W32_SOCKET_TO_FD(sock);
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
const char *
|
||||
inet_ntop(int af, const void *src, char *dst, socklen_t len)
|
||||
{
|
||||
struct sockaddr *sa;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
size_t salen;
|
||||
|
||||
if (af == AF_INET) {
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = af;
|
||||
memcpy(&sin.sin_addr, src, sizeof(sin.sin_addr));
|
||||
sa = (struct sockaddr *)&sin;
|
||||
salen = sizeof(sin);
|
||||
} else if (af == AF_INET6) {
|
||||
memset(&sin6, 0, sizeof(sin6));
|
||||
sin6.sin6_family = af;
|
||||
memcpy(&sin6.sin6_addr, src, sizeof(sin6.sin6_addr));
|
||||
sa = (struct sockaddr *)&sin6;
|
||||
salen = sizeof(sin6);
|
||||
} else {
|
||||
WSASetLastError(WSAEAFNOSUPPORT);
|
||||
w32_set_winsock_errno();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (getnameinfo(sa, salen, dst, len, NULL, 0, NI_NUMERICHOST)) {
|
||||
WSASetLastError(WSAEAFNOSUPPORT);
|
||||
w32_set_winsock_errno();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* POSIX equivalent for fcntl().
|
||||
* Horrible hacks, just good enough support Empire's use of fcntl().
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue