[vlc-devel] [vlc-commits] vlc_tick: use a macro for vlc_tick_from_timespec()

Steve Lhomme robux4 at ycbcr.xyz
Thu Jul 5 08:38:11 CEST 2018


How so ? Because of the call to vlc_tick_from_sec() ? There it can be 
replaced by a multiplication by CLOCK_FREQ since we know the type of the 
tv_sec value.


On 2018-07-04 18:52, Rémi Denis-Courmont wrote:
> Le keskiviikkona 4. heinäkuuta 2018, 19.24.57 EEST Steve Lhomme a écrit :
>> vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul  4 18:24:16
>> 2018 +0200| [6735a69b79e13180a8c0f4a06ffc6ec246e14b01] | committer: Steve
>> Lhomme
>>
>> vlc_tick: use a macro for vlc_tick_from_timespec()
>>
>> So we don't have to include extra headers for struct timespec (time.h).
>>
>>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6735a69b79e13180a8c
>>> 0f4a06ffc6ec246e14b01
>> ---
>>
>>   include/vlc_tick.h | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/vlc_tick.h b/include/vlc_tick.h
>> index c923e78976..a8db0f19a3 100644
>> --- a/include/vlc_tick.h
>> +++ b/include/vlc_tick.h
>> @@ -158,10 +158,8 @@ typedef int64_t msftime_t;
>>   #define vlc_tick_from_timeval(tv) \
>>       (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_US( (tv)->tv_usec ))
>>
>> -static inline vlc_tick_t vlc_tick_from_timespec(const struct timespec *tv)
>> -{
>> -    return vlc_tick_from_sec( tv->tv_sec ) + VLC_TICK_FROM_NS( tv->tv_nsec
>> ); -}
>> +#define vlc_tick_from_timespec(tv) \
>> +    (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec ))
> What I did not consider in the previous comment, is that this turns out
> expansion-unsafe :(
>
> -- 
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list