lwip: Fix compatibility issues with later versions
The name of the header guard in lwIP's <lwip/opt.h> has changed from '__LWIP_OPT_H__' to 'LWIP_HDR_OPT_H' (bug #35874 in May 2015). Other fixes: - In curl_setup.h, the problem with an old PSDK doesn't apply if lwIP is used. - In memdebug.h, the 'socket' should be undefined first due to lwIP's lwip_socket() macro. - In curl_addrinfo.c lwIP's getaddrinfo() + freeaddrinfo() macros need special handling because they were undef'ed in memdebug.h. - In select.c we can't use preprocessor conditionals inside select if MSVC and select is a macro, as it is with lwIP. http://curl.haxx.se/mail/lib-2015-12/0023.html http://curl.haxx.se/mail/lib-2015-12/0024.html
This commit is contained in:
parent
ec26399bf9
commit
e1b6b2219d
@ -56,7 +56,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)
|
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)
|
||||||
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || defined(__LWIP_OPT_H__))
|
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
|
||||||
|
defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
|
||||||
/* The check above prevents the winsock2 inclusion if winsock.h already was
|
/* The check above prevents the winsock2 inclusion if winsock.h already was
|
||||||
included, since they can't co-exist without problems */
|
included, since they can't co-exist without problems */
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@ -112,7 +113,7 @@ typedef void CURL;
|
|||||||
|
|
||||||
#ifndef curl_socket_typedef
|
#ifndef curl_socket_typedef
|
||||||
/* socket typedef */
|
/* socket typedef */
|
||||||
#if defined(WIN32) && !defined(__LWIP_OPT_H__)
|
#if defined(WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H)
|
||||||
typedef SOCKET curl_socket_t;
|
typedef SOCKET curl_socket_t;
|
||||||
#define CURL_SOCKET_BAD INVALID_SOCKET
|
#define CURL_SOCKET_BAD INVALID_SOCKET
|
||||||
#else
|
#else
|
||||||
|
@ -521,7 +521,11 @@ void
|
|||||||
curl_dofreeaddrinfo(struct addrinfo *freethis,
|
curl_dofreeaddrinfo(struct addrinfo *freethis,
|
||||||
int line, const char *source)
|
int line, const char *source)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_LWIPSOCK
|
||||||
|
lwip_freeaddrinfo(freethis);
|
||||||
|
#else
|
||||||
(freeaddrinfo)(freethis);
|
(freeaddrinfo)(freethis);
|
||||||
|
#endif
|
||||||
curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n",
|
curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n",
|
||||||
source, line, (void *)freethis);
|
source, line, (void *)freethis);
|
||||||
}
|
}
|
||||||
@ -544,7 +548,11 @@ curl_dogetaddrinfo(const char *hostname,
|
|||||||
struct addrinfo **result,
|
struct addrinfo **result,
|
||||||
int line, const char *source)
|
int line, const char *source)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_LWIPSOCK
|
||||||
|
int res=lwip_getaddrinfo(hostname, service, hints, result);
|
||||||
|
#else
|
||||||
int res=(getaddrinfo)(hostname, service, hints, result);
|
int res=(getaddrinfo)(hostname, service, hints, result);
|
||||||
|
#endif
|
||||||
if(0 == res)
|
if(0 == res)
|
||||||
/* success */
|
/* success */
|
||||||
curl_memlog("ADDR %s:%d getaddrinfo() = %p\n",
|
curl_memlog("ADDR %s:%d getaddrinfo() = %p\n",
|
||||||
|
@ -481,9 +481,10 @@
|
|||||||
/*
|
/*
|
||||||
* msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
|
* msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
|
||||||
* defined in ws2tcpip.h as well as to provide IPv6 support.
|
* defined in ws2tcpip.h as well as to provide IPv6 support.
|
||||||
|
* Does not apply if lwIP is used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__POCC__)
|
#if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
|
||||||
# if !defined(HAVE_WS2TCPIP_H) || \
|
# if !defined(HAVE_WS2TCPIP_H) || \
|
||||||
((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
|
((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
|
||||||
# undef HAVE_GETADDRINFO_THREADSAFE
|
# undef HAVE_GETADDRINFO_THREADSAFE
|
||||||
@ -675,7 +676,7 @@ int netware_init(void);
|
|||||||
* Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
|
* Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__LWIP_OPT_H__)
|
#if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
|
||||||
# if defined(SOCKET) || \
|
# if defined(SOCKET) || \
|
||||||
defined(USE_WINSOCK) || \
|
defined(USE_WINSOCK) || \
|
||||||
defined(HAVE_WINSOCK_H) || \
|
defined(HAVE_WINSOCK_H) || \
|
||||||
|
@ -103,6 +103,7 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef socket
|
||||||
#define socket(domain,type,protocol)\
|
#define socket(domain,type,protocol)\
|
||||||
curl_socket(domain, type, protocol, __LINE__, __FILE__)
|
curl_socket(domain, type, protocol, __LINE__, __FILE__)
|
||||||
#undef accept /* for those with accept as a macro */
|
#undef accept /* for those with accept as a macro */
|
||||||
|
20
lib/select.c
20
lib/select.c
@ -316,15 +316,15 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
|||||||
curl_socket_t is unsigned in such cases and thus -1 is the largest
|
curl_socket_t is unsigned in such cases and thus -1 is the largest
|
||||||
value).
|
value).
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
r = select((int)maxfd + 1,
|
r = select((int)maxfd + 1,
|
||||||
#ifndef USE_WINSOCK
|
|
||||||
&fds_read,
|
|
||||||
&fds_write,
|
|
||||||
#else
|
|
||||||
fds_read.fd_count ? &fds_read : NULL,
|
fds_read.fd_count ? &fds_read : NULL,
|
||||||
fds_write.fd_count ? &fds_write : NULL,
|
fds_write.fd_count ? &fds_write : NULL,
|
||||||
#endif
|
|
||||||
&fds_err, ptimeout);
|
&fds_err, ptimeout);
|
||||||
|
#else
|
||||||
|
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
@ -505,19 +505,19 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
pending_tv.tv_sec = 0;
|
pending_tv.tv_sec = 0;
|
||||||
pending_tv.tv_usec = 0;
|
pending_tv.tv_usec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
r = select((int)maxfd + 1,
|
r = select((int)maxfd + 1,
|
||||||
#ifndef USE_WINSOCK
|
|
||||||
&fds_read, &fds_write, &fds_err,
|
|
||||||
#else
|
|
||||||
/* WinSock select() can't handle fd_sets with zero bits set, so
|
/* WinSock select() can't handle fd_sets with zero bits set, so
|
||||||
don't give it such arguments. See the comment about this in
|
don't give it such arguments. See the comment about this in
|
||||||
Curl_check_socket().
|
Curl_check_socket().
|
||||||
*/
|
*/
|
||||||
fds_read.fd_count ? &fds_read : NULL,
|
fds_read.fd_count ? &fds_read : NULL,
|
||||||
fds_write.fd_count ? &fds_write : NULL,
|
fds_write.fd_count ? &fds_write : NULL,
|
||||||
fds_err.fd_count ? &fds_err : NULL,
|
fds_err.fd_count ? &fds_err : NULL, ptimeout);
|
||||||
|
#else
|
||||||
|
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
||||||
#endif
|
#endif
|
||||||
ptimeout);
|
|
||||||
if(r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user