Messages in this thread | | | Subject | Re: MSEC_TO_JIFFIES is messed up... | From | Valdis.Kletnieks@vt ... | Date | Wed, 12 May 2004 17:03:10 -0400 |
| |
On Wed, 12 May 2004 22:50:28 +0200, Ingo Molnar said:
> Content-Disposition: attachment; filename="hz-cleanup-2.6.6-A2" > > --- linux/include/linux/time.h.orig > +++ linux/include/linux/time.h > @@ -177,6 +177,24 @@ struct timezone { > (SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1) > > #endif > + > +/* > + * Convert jiffies to milliseconds and back. > + * > + * Avoid unnecessary multiplications/divisions in the > + * two most common HZ cases: > + */ > +#if HZ == 1000 > +# define JIFFIES_TO_MSECS(x) (x) > +# define MSECS_TO_JIFFIES(x) (x) > +#elif HZ == 100 > +# define JIFFIES_TO_MSECS(x) ((x) * 10) > +# define MSECS_TO_JIFFIES(x) ((x) / 10) > +#else > +# define JIFFIES_TO_MSECS(x) ((x) * 1000 / HZ) > +# define MSECS_TO_JIFFIES(x) ((x) * HZ / 1000) > +#endif > +
Looks good to me.. :) [unhandled content-type:application/pgp-signature] | |