Details

    • Type: Bug Bug
    • Status: Closed
    • Severity: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Target Release Version/s: None
    • Component/s: General
    • Labels:
      None
    • SVN Revision Number:
      89114
    • Mantis ID:
      11270
    • Regression:
      No

      Description

      Patch adds trivial function ast_tvdiff_us to get the difference between two timeval instances in microseconds.

                • ADDITIONAL INFORMATION ******

      We need this one for T38 fax terminal support in ReceiveFAX (issue 10815). Although the fax application is in addons, I believe it worth having this function in the core asterisk (close to its friend ast_tvdiff_ms which returns milliseconds)

      1. tvdiff_us.patch
        1.0 kB
        Dmitry Andrianov
      2. tvdiff_us-2.patch
        0.8 kB
        Dmitry Andrianov
      3. tvdiff_us-3.patch
        1 kB
        Dmitry Andrianov
      4. tvdiff_us-4.patch
        2 kB
        Dmitry Andrianov

        Activity

        Hide
        Dmitry Andrianov added a comment -

        sorry, first patch contains typo. I fixed it in second one.

        Show
        Dmitry Andrianov added a comment - sorry, first patch contains typo. I fixed it in second one.
        Hide
        Tilghman Lesher added a comment -

        Is there a reason why you chose int64_t as the return type, though your calculations are not necessarily done in that precision?

        Show
        Tilghman Lesher added a comment - Is there a reason why you chose int64_t as the return type, though your calculations are not necessarily done in that precision?
        Hide
        Dmitry Andrianov added a comment -

        My bad. This is result of extensive usage of Java where long is 64 bit...

        I chosen 64 bits intentionally because time delta expressed in microseconds can be very big value and 32 bit signed int can only represent about 30 minutes. Obviously, where we need microsecond precision, we are measuring very small intervals so even 32 bit int is ok. But I just didn't want surprise someone who could use this function for long intervals.

        I can fix the patch in both ways but I would prefer "true" 64 bits. What do you think?

        Show
        Dmitry Andrianov added a comment - My bad. This is result of extensive usage of Java where long is 64 bit... I chosen 64 bits intentionally because time delta expressed in microseconds can be very big value and 32 bit signed int can only represent about 30 minutes. Obviously, where we need microsecond precision, we are measuring very small intervals so even 32 bit int is ok. But I just didn't want surprise someone who could use this function for long intervals. I can fix the patch in both ways but I would prefer "true" 64 bits. What do you think?
        Hide
        Tilghman Lesher added a comment -

        Sure, that's fine.

        Show
        Tilghman Lesher added a comment - Sure, that's fine.
        Hide
        Dmitry Andrianov added a comment -

        Fixed. The new patch also adds ast_tvdiff_sec to get delta in seconds.

        Show
        Dmitry Andrianov added a comment - Fixed. The new patch also adds ast_tvdiff_sec to get delta in seconds.
        Hide
        Tilghman Lesher added a comment -

        One last thing. The documentation in your patch suggests that the start is the end and end is the beginning, which is really confusing. Could you correct the documentation, please?

        Show
        Tilghman Lesher added a comment - One last thing. The documentation in your patch suggests that the start is the end and end is the beginning, which is really confusing. Could you correct the documentation, please?
        Hide
        Dmitry Andrianov added a comment -

        Ohh. I've just took the documentation from already existing ast_tvdiff_ms. So it seems this function needs to be fixed too. Will upload new patch in 10 minutes...

        Show
        Dmitry Andrianov added a comment - Ohh. I've just took the documentation from already existing ast_tvdiff_ms. So it seems this function needs to be fixed too. Will upload new patch in 10 minutes...
        Hide
        Digium Subversion added a comment -

        Repository: asterisk
        Revision: 94029

        U trunk/include/asterisk/time.h

        ------------------------------------------------------------------------
        r94029 | russell | 2007-12-19 13:26:20 -0600 (Wed, 19 Dec 2007) | 7 lines

        Add a couple of new time API calls - ast_tvdiff_sec and ast_tvdiff_usec

        (closes issue ASTERISK-10787)
        Reported by: dimas
        Patches:
        tvdiff_us-4.patch uploaded by dimas (license 88)

        ------------------------------------------------------------------------

        http://svn.digium.com/view/asterisk?view=rev&revision=94029

        Show
        Digium Subversion added a comment - Repository: asterisk Revision: 94029 U trunk/include/asterisk/time.h ------------------------------------------------------------------------ r94029 | russell | 2007-12-19 13:26:20 -0600 (Wed, 19 Dec 2007) | 7 lines Add a couple of new time API calls - ast_tvdiff_sec and ast_tvdiff_usec (closes issue ASTERISK-10787 ) Reported by: dimas Patches: tvdiff_us-4.patch uploaded by dimas (license 88) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=94029

          People

          • Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development