[vlc-devel] [PATCH 05/15] vlc_common: add helper function to convert microseconds to/from mtime_t

Rémi Denis-Courmont remi at remlab.net
Mon Jun 18 11:52:02 CEST 2018


There were also no needs for static mutex, list head, you-name-it initialization... Until there were.

There are no technical reasons why we cannot make it a both constant-preserving and expansion-safe macro... Therefore we should make it constant-preserving and expansion-safe.

Le 18 juin 2018 09:48:23 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>On 2018-06-16 10:56 AM, Rémi Denis-Courmont wrote:
>> Le perjantaina 15. kesäkuuta 2018, 18.09.16 EEST Steve Lhomme a écrit
>:
>>> ---
>>>   include/vlc_common.h | 8 ++++++++
>>>   1 file changed, 8 insertions(+)
>>>
>>> diff --git a/include/vlc_common.h b/include/vlc_common.h
>>> index 3191d3ce4c8..8b4baffcf27 100644
>>> --- a/include/vlc_common.h
>>> +++ b/include/vlc_common.h
>>> @@ -316,6 +316,14 @@ static inline int64_t milli_from_vtick(mtime_t
>mt)
>>>       return mt / (CLOCK_FREQ / 1000);
>>>   }
>>>
>>> +static inline int64_t micro_from_vtick(mtime_t mt)
>>> +{
>>> +    return mt * INT64_C(1000000) / CLOCK_FREQ;
>>> +}
>>> +static inline mtime_t vtick_from_micro(int64_t micro)
>>> +{
>>> +    return micro * CLOCK_FREQ / INT64_C(1000000);
>>> +}
>>>   static inline mtime_t vtick_from_nano(int64_t nano)
>>>   {
>>>       return nano / (INT64_C(1000000000) / CLOCK_FREQ);
>> Use macros to preserve constants.
>
>There are no cases where the conversion happens on a constant. See
>other 
>thread about macros vs functions for these conversions.
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180618/34e14fa7/attachment.html>


More information about the vlc-devel mailing list