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 13:59, Dave Korn wrote:
>   The attached patch is my suggestion to fix this problem.  There is one little
> bit of fallout; since struct itimerval requires struct timeval, if we're using
> the winsock version of timeval (as indicated by __USE_W32_SOCKETS), and we
> haven't already included winsock2.h, we can't define struct itimerval.  I don't
> see how there could be any code relying on those definitions which wouldn't
> already fail to compile because of the redefinition of struct timeval, but I
> thought I should point it out.
> 
>   Any comments?  It looks like this struct just got omitted during the initial
> implementation of __USE_W32_SOCKETS.  Having this work right is needed to fix
> libada in upstream GCC, where it's not always an option to "just #include
> winsock first"(*).  If I don't hear any issues raised, I'll send this to newlib
> in fairly short order.

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

?


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]