Longstanding __USE_W32_SOCKETS hiccup.

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Aug 6 14:24:00 GMT 2009


On Aug  6 16:15, Corinna Vinschen wrote:
> struct timeval in winsock2.h only differs by using `long' instead of
> time_t and susecond_t as types of tv_sec and tv_usec.  The size of the
> structs is the same, the underlying types are equivalent.
> 
> So, wouldn't it be less hassle in the long run to define struct timeval
> in winsock2.h equivalent to sys/time.h if building for Cygwin?
> 
> Something along these lines:
> 
>   sys/types.h:
> 
>     #ifndef __time_t_defined		// This #ifdef already exists
>     typedef _TIME_T_ time_t;
>     #define __time_t_defined
>     #endif
> 
>     [...]
> 
>     #ifndef __suseconds_t_defined	// This #ifdef is missing yet
>     typedef long suseconds_t;
>     #define __suseconds_t_defined
>     #endif
> 
>   sys/time.h:
> 
>     #ifndef __timeval_defined		// This one, too
>     struct timeval {
>       time_t      tv_sec;
>       suseconds_t tv_usec;
>     };
>     #define __timeval_defined
>     #endif
> 
>   w32api/include/winsock2.h:
> 
>     #ifdef __CYGWIN__
>     #ifndef __time_t_defined
>     typedef _TIME_T_ time_t;
>     #define __time_t_defined
>     #endif
>     #ifndef __suseconds_t_defined
>     typedef long suseconds_t;
>     #define __suseconds_t_defined
>     #endif
>     #ifndef __timeval_defined
>     struct timeval {
>       time_t      tv_sec;
>       suseconds_t tv_usec;
>     };
>     #define __timeval_defined
>     #endif
>     #else /* !__CYGWIN__ */
>     struct timeval {
>       long    tv_sec;
>       long    tv_usec;
>     };
>     #endif

Same for winsock.h, btw.  This should also drop the need for the

  #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))

The patch should probably also go through the mingw folks, if it's
feasible at all.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat



More information about the Cygwin-developers mailing list