Menu

#1752 timeradd/timersub macros for sys/time.h

WSL
pending
Feature
later
Feature_in_WSL_4.1
True
2014-10-09
2012-07-21
No

I would like to suggest to add macros timeradd() and timersub() in sys/time.h
These macros may be useful for compiling some stuff, for example they are a requirement for compiling natively xine-lib for Windows.
Information about how these macros must work has been taken from the sources of cygwin.

Sincerely,

Carlo Bramini.

Discussion

  • Carlo Bramini

    Carlo Bramini - 2012-07-21
     
  • Carlo Bramini

    Carlo Bramini - 2012-07-21
     
  • Earnie Boyd

    Earnie Boyd - 2012-07-21

    We will need a reference from MSDN for the macros you want. The patch itself may not be able to be used since you state "taken from the sources of cygwin" which has a GPL license and we cannot use it.

     
  • Earnie Boyd

    Earnie Boyd - 2012-07-21
    • milestone: --> 898614
    • status: open --> pending
     
  • Carlo Bramini

    Carlo Bramini - 2012-07-21

    From what I could see, a sys/time.h file does not exist in MSDN, I could find time.h and sys/timeb.h, but not that one and it also seems to me that the gettimeofday() function does not exist either in MSDN, which it is provided by this file (I had just found an implementation of it in the social.msdn, to be used as replacement if you are porting code).
    So, I was thinking that this file was providing some compatibility at level of headers, normally not available in the PSDK.

    The piece of code that I studied is not GPL.
    On top of /usr/include/sys/time.h, there is written:

    /* time.h -- An implementation of the standard Unix <sys/time.h> file.
    Written by Geoffrey Noer <noer@cygnus.com>
    Public domain; no rights reserved. */

    as you can see in the sources of newlib, which it is used by cygwin as C library and it is also used by msys if I have understood correctly.
    So, in my opinion there are not license conflicts.

    I also wanted to say that this is pretty much my first patch, please excuse me if I'm doing errors...

     
  • Carlo Bramini

    Carlo Bramini - 2012-07-21
    • status: pending --> open
     
  • Earnie Boyd

    Earnie Boyd - 2012-07-24
    • milestone: 898614 -->
     
  • Earnie Boyd

    Earnie Boyd - 2012-07-24

    Then you should have said it was from newlib project which I know that most of it is PD. Keith, what do you think about adding non Microsoft timeradd and timersub to mingwex?

    As implemented in the patchset I will not accept it. IMO, these deserve to be added as functions with declarations so that others do not have a hit in unneeded code when including the header.

     
    • Keith Marshall

      Keith Marshall - 2013-02-20

      I'm somewhat dubious; not only do Microsoft not provide them, but neither are they required, nor even recognised by POSIX. That said, they do seem to be common in BSD derivatives, and Linux glibc does provide them.

      On the concept of providing them as functions in libmingwex.a, I am opposed. If they are to be added, they should remain as macros, since this adds no code overhead whatsoever, until they are actually expanded (by reference in client code).

      Additionally, if we are to provide them, why just these two? Any implementation should provide the full complement of timeradd(3), timersub(3), timerclear(3), timerisset(3), and timercmp(3), as enumerated in http://www.kernel.org/doc/man-pages/online/pages/man3/timeradd.3.html, and all should be guarded by _BSD_SOURCE

       
  • Earnie Boyd

    Earnie Boyd - 2013-02-12

    Ticket moved from /p/mingw/patches/522/

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-12
    • labels: MinGW runtime --> posix enhancement
    • status: open --> pending
    • assigned_to: Earnie Boyd
    • milestone: --> WSL
    • type: --> Feature
    • resolution: --> later
    • category: --> Unknown
    • patch_attached: --> False
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-12
    • patch_attached: False --> True
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-20
    • category: Unknown --> Feature_in_WSL_4.1
     
  • Arrigo Marchiori

    Hello,

    I bumped into this bug today and I am willing to help, if I can.
    Does the attached "wrap-up in _BSD_SOURCE" fix the patch for you?

    To answer Keith's concern about the other macros: they are not included in Carlo's patch because they were already inside the file time.h on 2012-08-11, as committed by Earnie (at least this is what I understand from the git browser). That file did not contain any _BSD_SOURCE wrappers, but the existing macros are inside another ``wrapper'', i.e. _TIMEVAL_DEFINED.

    Moreover, the definition of struct timeval and of the existing macros is repeated among different files: winsock.h, winsock2.h and sys/time.h. This is probably the reason for the _TIMEVAL_DEFINED macro.

    I hope this helps. Thank you for your work on MinGW.