Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Oct 2014 00:15:57 +0200
From:      Jeremie Le Hen <jlh@FreeBSD.org>
To:        freebsd-hackers@FreeBSD.org
Subject:   struct bintime
Message-ID:  <CAGSa5y2voSswSV4XFVR8%2BOqdftsfPWNSHYiptp-BMJ_hSp5u2A@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi,

I need to get microseconds from a struct bintime.  I found
bintime2timeval() in sys/time.h which more or less does this, but I
don't understand how the computation works.

Can someone explain it to me please?

static __inline void
bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
{

        _tv->tv_sec = _bt->sec;
        _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
}

Thanks!
-- 
Jeremie Le Hen
jlh@FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGSa5y2voSswSV4XFVR8%2BOqdftsfPWNSHYiptp-BMJ_hSp5u2A>