diff --git a/include/wx/private/socket.h b/include/wx/private/socket.h index 906c20c659..56a3cef528 100644 --- a/include/wx/private/socket.h +++ b/include/wx/private/socket.h @@ -62,6 +62,15 @@ #include // 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); diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 5fb8c291ae..207b3c9751 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -135,7 +135,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent); namespace { -void SetTimeValFromMS(timeval& tv, unsigned long ms) +void SetTimeValFromMS(wxTimeVal_t& tv, unsigned long ms) { tv.tv_sec = (ms / 1000); tv.tv_usec = (ms % 1000) * 1000; @@ -1304,12 +1304,12 @@ wxSocketBase& wxSocketBase::Discard() and it will return a mask indicating which operations can be performed. */ wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags, - const timeval *timeout) + wxTimeVal_t *timeout) { if ( m_fd == INVALID_SOCKET ) return (wxSOCKET_LOST_FLAG & flags); - struct timeval tv; + wxTimeVal_t tv; if ( timeout ) tv = *timeout; else @@ -1502,7 +1502,7 @@ wxSocketBase::DoWait(long timeout, wxSocketEventFlags flags) else // no event loop or waiting in another thread { // as explained below, we should always check for wxSOCKET_LOST_FLAG - timeval tv; + wxTimeVal_t tv; SetTimeValFromMS(tv, timeLeft); events = m_impl->Select(flags | wxSOCKET_LOST_FLAG, &tv); } diff --git a/src/msw/sockmsw.cpp b/src/msw/sockmsw.cpp index 791f18a49b..2a66c8eda4 100644 --- a/src/msw/sockmsw.cpp +++ b/src/msw/sockmsw.cpp @@ -217,7 +217,7 @@ LRESULT CALLBACK wxSocket_Internal_WinProc(HWND hWnd, // only then). Ignore such dummy notifications. { fd_set fds; - timeval tv = { 0, 0 }; + wxTimeVal_t tv = { 0, 0 }; wxFD_ZERO(&fds); wxFD_SET(socket->m_fd, &fds);