[LTP] [RFC] [PATCH] lib/tst_test: Use CLOCK_MONOTONIC for -I option.

Xiao Yang yangx.jy@cn.fujitsu.com
Thu Jan 25 07:59:00 CET 2018


On 2018/01/25 13:50, Li Wang wrote:
>
>
> On Mon, Jan 22, 2018 at 10:19 PM, Cyril Hrubis <chrubis@suse.cz 
> <mailto:chrubis@suse.cz>> wrote:
>
>     ​...
>
>     -       return tv.tv_sec * 1000 + tv.tv_usec / 1000;
>     +       return tst_timespec_to_ms(ts);
>
>
>
> ​Both patches(include the old-lib one) looks good.
>
> I just have a small question about function tst_timespec_to_ms(), why 
> the t.tv_nsec plus 500000 when convert to msec?
Hi Li,

It seems to round up/down the decimal produced by converting nesc to msec.
If the decimal is greater than 0.5,  round up it. If not, round down it.

Thanks,
Xiao Yang

>
> static inline long long tst_timespec_to_ms(struct timespec t)
> {
>     return t.tv_sec * 1000 + (t.tv_nsec + 500000) / 1000000;
> }
>>
>
> -- 
> Li Wang
> liwang@redhat.com <mailto:liwang@redhat.com>
>
>
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180125/f9723f6c/attachment.html>


More information about the ltp mailing list