This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Longstanding __USE_W32_SOCKETS hiccup.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]