mirror of
https://github.com/curl/curl.git
synced 2026-08-03 00:20:36 +03:00
windows: simplify detecting and using system headers
- autotools, cmake: assume that if we detect Windows, `windows.h`, `winsock2.h` and `ws2tcpip.h` do exist. - lib: fix 3 outlier `#if` conditions to use `USE_WINSOCK` instead of looking for `winsock2.h`. - autotools: merge 3 Windows check methods into one. - move Watt-32 and lwIP socket support to `setup-win32.h` from `config-win32.h`. It opens up using these with all build tools. Also merge logic with Windows Sockets. - fix to assume Windows sockets with the mingw32ce toolchain. Follow-up to:2748c64d60- cmake: delete unused variable `signature_call_conv` sinceeb33ccd533. - autotools: simplify `CURL_CHECK_WIN32_LARGEFILE` detection. - examples/externalsocket: fix header order. - cmake/OtherTests.cmake: delete Windows-specific `_source_epilogue` that wasn't used anymore. - cmake/OtherTests.cmake: set `WIN32_LEAN_AND_MEAN` for test `SIZEOF_STRUCT_SOCKADDR_STORAGE`. After this patch curl universally uses `_WIN32` to guard Windows-specific logic. It guards Windows Sockets-specific logic with `USE_WINSOCK` (this might need further work). Reviewed-by: Jay Satiro Closes #12495
This commit is contained in:
parent
3829759bd0
commit
c1bc090d65
15 changed files with 125 additions and 369 deletions
|
|
@ -137,14 +137,14 @@ static void nosigpipe(struct Curl_easy *data,
|
|||
#define nosigpipe(x,y) Curl_nop_stmt
|
||||
#endif
|
||||
|
||||
#if defined(__DragonFly__) || defined(HAVE_WINSOCK2_H)
|
||||
#if defined(__DragonFly__) || defined(USE_WINSOCK)
|
||||
/* DragonFlyBSD and Windows use millisecond units */
|
||||
#define KEEPALIVE_FACTOR(x) (x *= 1000)
|
||||
#else
|
||||
#define KEEPALIVE_FACTOR(x)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_WINSOCK2_H) && !defined(SIO_KEEPALIVE_VALS)
|
||||
#if defined(USE_WINSOCK) && !defined(SIO_KEEPALIVE_VALS)
|
||||
#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
|
||||
|
||||
struct tcp_keepalive {
|
||||
|
|
|
|||
|
|
@ -97,15 +97,6 @@
|
|||
#define HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <windows.h> header file. */
|
||||
#define HAVE_WINDOWS_H 1
|
||||
|
||||
/* Define if you have the <winsock2.h> header file. */
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
|
||||
/* Define if you have the <ws2tcpip.h> header file. */
|
||||
#define HAVE_WS2TCPIP_H 1
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
#if defined(__MINGW32__)
|
||||
#define HAVE_LIBGEN_H 1
|
||||
|
|
@ -292,52 +283,6 @@
|
|||
/* Define to the size of `curl_off_t', as computed by sizeof. */
|
||||
#define SIZEOF_CURL_OFF_T 8
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* BSD-style lwIP TCP/IP stack SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
/* Define to use BSD-style lwIP TCP/IP stack. */
|
||||
/* #define USE_LWIPSOCK 1 */
|
||||
|
||||
#ifdef USE_LWIPSOCK
|
||||
# undef USE_WINSOCK
|
||||
# undef HAVE_WINSOCK2_H
|
||||
# undef HAVE_WS2TCPIP_H
|
||||
# undef HAVE_GETHOSTNAME
|
||||
# undef LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
# undef RECV_TYPE_ARG1
|
||||
# undef RECV_TYPE_ARG3
|
||||
# undef SEND_TYPE_ARG1
|
||||
# undef SEND_TYPE_ARG3
|
||||
# define HAVE_GETHOSTBYNAME_R
|
||||
# define HAVE_GETHOSTBYNAME_R_6
|
||||
# define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||
# define RECV_TYPE_ARG1 int
|
||||
# define RECV_TYPE_ARG3 size_t
|
||||
# define SEND_TYPE_ARG1 int
|
||||
# define SEND_TYPE_ARG3 size_t
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Watt-32 tcp/ip SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
#ifdef USE_WATT32
|
||||
#include <tcp.h>
|
||||
#undef byte
|
||||
#undef word
|
||||
#undef USE_WINSOCK
|
||||
#undef HAVE_WINSOCK2_H
|
||||
#undef HAVE_WS2TCPIP_H
|
||||
#define HAVE_SYS_IOCTL_H
|
||||
#define HAVE_SYS_SOCKET_H
|
||||
#define HAVE_NETINET_IN_H
|
||||
#define HAVE_NETDB_H
|
||||
#define HAVE_ARPA_INET_H
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* COMPILER SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -85,15 +85,6 @@
|
|||
#define HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <windows.h> header file. */
|
||||
#define HAVE_WINDOWS_H 1
|
||||
|
||||
/* Define if you have the <winsock2.h> header file. */
|
||||
#define HAVE_WINSOCK2_H 1
|
||||
|
||||
/* Define if you have the <ws2tcpip.h> header file. */
|
||||
#define HAVE_WS2TCPIP_H 1
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* OTHER HEADER INFO */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -599,18 +599,9 @@
|
|||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#cmakedefine HAVE_UTIME_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
#cmakedefine HAVE_WINDOWS_H 1
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
#cmakedefine HAVE_WINSOCK2_H 1
|
||||
|
||||
/* Define this symbol if your OS supports changing the contents of argv */
|
||||
#cmakedefine HAVE_WRITABLE_ARGV 1
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
#cmakedefine HAVE_WS2TCPIP_H 1
|
||||
|
||||
/* Define to 1 if you need the lber.h header file even with ldap.h */
|
||||
#cmakedefine NEED_LBER_H 1
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@
|
|||
* Windows setup file includes some system headers.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifdef _WIN32
|
||||
# include "setup-win32.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -725,10 +725,7 @@
|
|||
*/
|
||||
|
||||
#if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
|
||||
# if defined(SOCKET) || \
|
||||
defined(USE_WINSOCK) || \
|
||||
defined(HAVE_WINSOCK2_H) || \
|
||||
defined(HAVE_WS2TCPIP_H)
|
||||
# if defined(SOCKET) || defined(USE_WINSOCK)
|
||||
# error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ int Curl_inet_pton(int, const char *, void *);
|
|||
#ifdef HAVE_INET_PTON
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#elif defined(HAVE_WS2TCPIP_H)
|
||||
#elif defined(USE_WINSOCK)
|
||||
/* inet_pton() exists in Vista or later */
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -24,18 +24,53 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
#undef USE_WINSOCK
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* Watt-32 TCP/IP SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
#ifdef USE_WATT32
|
||||
# include <tcp.h>
|
||||
# undef byte
|
||||
# undef word
|
||||
# define HAVE_SYS_IOCTL_H
|
||||
# define HAVE_SYS_SOCKET_H
|
||||
# define HAVE_NETINET_IN_H
|
||||
# define HAVE_NETDB_H
|
||||
# define HAVE_ARPA_INET_H
|
||||
# define SOCKET int
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* BSD-style lwIP TCP/IP stack SPECIFIC */
|
||||
/* ---------------------------------------------------------------- */
|
||||
#elif defined(USE_LWIPSOCK)
|
||||
/* Define to use BSD-style lwIP TCP/IP stack. */
|
||||
/* #define USE_LWIPSOCK 1 */
|
||||
# undef HAVE_GETHOSTNAME
|
||||
# undef LWIP_POSIX_SOCKETS_IO_NAMES
|
||||
# undef RECV_TYPE_ARG1
|
||||
# undef RECV_TYPE_ARG3
|
||||
# undef SEND_TYPE_ARG1
|
||||
# undef SEND_TYPE_ARG3
|
||||
# define HAVE_GETHOSTBYNAME_R
|
||||
# define HAVE_GETHOSTBYNAME_R_6
|
||||
# define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||
# define RECV_TYPE_ARG1 int
|
||||
# define RECV_TYPE_ARG3 size_t
|
||||
# define SEND_TYPE_ARG1 int
|
||||
# define SEND_TYPE_ARG3 size_t
|
||||
#elif defined(_WIN32)
|
||||
# define USE_WINSOCK 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Include header files for windows builds before redefining anything.
|
||||
* Use this preprocessor block only to include or exclude windows.h,
|
||||
* winsock2.h or ws2tcpip.h. Any other windows thing belongs
|
||||
* to any other further and independent block. Under Cygwin things work
|
||||
* just as under linux (e.g. <sys/socket.h>) and the winsock headers should
|
||||
* never be included when __CYGWIN__ is defined. configure script takes
|
||||
* care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK2_H,
|
||||
* neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
|
||||
* never be included when __CYGWIN__ is defined.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifdef _WIN32
|
||||
# if defined(UNICODE) && !defined(_UNICODE)
|
||||
# error "UNICODE is defined but _UNICODE is not defined"
|
||||
# endif
|
||||
|
|
@ -53,12 +88,8 @@
|
|||
# ifndef NOGDI
|
||||
# define NOGDI
|
||||
# endif
|
||||
# ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# ifdef HAVE_WS2TCPIP_H
|
||||
# include <ws2tcpip.h>
|
||||
# endif
|
||||
# endif
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <windows.h>
|
||||
# include <winerror.h>
|
||||
# include <tchar.h>
|
||||
|
|
@ -67,17 +98,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
|
||||
* undefine USE_WINSOCK.
|
||||
*/
|
||||
|
||||
#undef USE_WINSOCK
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# define USE_WINSOCK 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define _WIN32_WINNT_[OS] symbols because not all Windows build systems have
|
||||
* those symbols to compare against, and even those that do may be missing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue