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

Rémi Denis-Courmont remi at remlab.net
Wed Jul 4 18:52:47 CEST 2018


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/





More information about the vlc-devel mailing list