Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2012 08:18:41 -0800
From:      Luigi Rizzo <rizzo@iet.unipi.it>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        Davide Italiano <davide@freebsd.org>, Ian Lepore <freebsd@damnhippie.dyndns.org>, Alexander Motin <mav@freebsd.org>, freebsd-current <freebsd-current@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: API explosion (Re: [RFC/RFT] calloutng)
Message-ID:  <CA%2BhQ2%2Bgn64-b4Y4cvk_cTry55XZyc-vGesnLSkS2YcfmCTVd6Q@mail.gmail.com>
In-Reply-To: <17057.1355931448@critter.freebsd.dk>
References:  <50CF88B9.6040004@FreeBSD.org> <20121218173643.GA94266@onelab2.iet.unipi.it> <50D0B00D.8090002@FreeBSD.org> <50D0E42B.6030605@FreeBSD.org> <20121218225823.GA96962@onelab2.iet.unipi.it> <1355873265.1198.183.camel@revolution.hippie.lan> <14604.1355910848@critter.freebsd.dk> <CACYV=-Eg542iHm9KfujPvCzZrA4TqepEBVA8RzT1YOHnCgfJnA@mail.gmail.com> <15882.1355914308@critter.freebsd.dk> <20121219150809.GA98673@onelab2.iet.unipi.it> <17057.1355931448@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 19, 2012 at 7:37 AM, Poul-Henning Kamp <phk@phk.freebsd.dk>wrote:

> --------
> In message <20121219150809.GA98673@onelab2.iet.unipi.it>, Luigi Rizzo
> writes:
>
> >>         typedef dur_t   int64_t;        /* signed for bug catching */
> >>         #define DURSEC  ((dur_t)1 << 32)
> >>         #define DURMIN  (DURSEC * 60)
> >>         #define DURMSEC (DURSEC / 1000)
> >>         #define DURUSEC (DURSEC / 10000000)
> >>         #define DURNSEC (DURSEC / 10000000000)
>
> >only thing, we must be careful with the parentheses
>
> Actually, it's more impportant to be careful with zeros, if you
> adjust the above to the correct number of zeros, DURNSEC is 4,
> which is within seven percent of the correct value.
>

counting digits is impossible for people over 45.
But i have a solution for that

#define DURNSEC (DURSEC / 1003006009)

which is within 0.5% of the desired value.

(and of course (1000*1000*1000) might do the job too)

cheers
luigi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BhQ2%2Bgn64-b4Y4cvk_cTry55XZyc-vGesnLSkS2YcfmCTVd6Q>