Use wxTimeVal_t instead of timeval to fix 64 bit Cygwin problems

Due to the same problem with sizeof(long) mismatch as in the previous
commit, we can't use struct timeval, with its long fields, in 64 bit
Cygwin builds, and need to use __ms_timeval instead.

Add wxTimeVal_t type to hide this difference and update all code
compiled under MSW (there is no need to uglify Unix-only code using
timeval, as in wxSelectDispatcher, for example) to use it instead of
timeval.
This commit is contained in:
Vadim Zeitlin
2018-01-13 13:43:28 +01:00
parent 1261139bcb
commit ebb06fbeaf
3 changed files with 16 additions and 7 deletions

View File

@@ -62,6 +62,15 @@
#include <sys/time.h> // for timeval
#endif
// 64 bit Cygwin can't use the standard struct timeval because it has long
// fields, which are supposed to be 32 bits in Win64 API, but long is 64 bits
// in 64 bit Cygwin, so we need to use its special __ms_timeval instead.
#if defined(__CYGWIN__) && defined(__LP64__)
typedef __ms_timeval wxTimeVal_t;
#else
typedef timeval wxTimeVal_t;
#endif
// these definitions are for MSW when we don't use configure, otherwise these
// symbols are defined by configure
#ifndef WX_SOCKLEN_T
@@ -254,7 +263,7 @@ public:
// flags defines what kind of conditions we're interested in, the return
// value is composed of a (possibly empty) subset of the bits set in flags
wxSocketEventFlags Select(wxSocketEventFlags flags,
const timeval *timeout = NULL);
wxTimeVal_t *timeout = NULL);
// convenient wrapper calling Select() with our default timeout
wxSocketEventFlags SelectWithTimeout(wxSocketEventFlags flags)
@@ -299,7 +308,7 @@ public:
bool m_broadcast;
bool m_dobind;
struct timeval m_timeout;
wxTimeVal_t m_timeout;
protected:
wxSocketImpl(wxSocketBase& wxsocket);