netdev
[Top] [All Lists]

Re: MSEC_TO_JIFFIES is messed up...

To: Valdis.Kletnieks@xxxxxx
Subject: Re: MSEC_TO_JIFFIES is messed up...
From: Davide Libenzi <davidel@xxxxxxxxxxxxxxx>
Date: Wed, 12 May 2004 14:33:07 -0700 (PDT)
Cc: Ingo Molnar <mingo@xxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Netdev <netdev@xxxxxxxxxxx>
In-reply-to: <200405122103.i4CL3AUp014523@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20040512020700.6f6aa61f.akpm@xxxxxxxx> <20040512181903.GG13421@xxxxxxxxx> <40A26FFA.4030701@xxxxxxxxx> <20040512193349.GA14936@xxxxxxx> <200405121947.i4CJlJm5029666@xxxxxxxxxxxxxxxxxxxxxxx> <Pine.LNX.4.58.0405121255170.11950@xxxxxxxxxxxxxxxxxxxxxxx> <200405122007.i4CK7GPQ020444@xxxxxxxxxxxxxxxxxxxxxxx> <20040512202807.GA16849@xxxxxxx> <20040512203500.GA17999@xxxxxxx> <20040512205028.GA18806@xxxxxxx> <200405122103.i4CL3AUp014523@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
On Wed, 12 May 2004 Valdis.Kletnieks@xxxxxx wrote:

> 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.. :)

Guys, why don't you leave the compiler to do its job?



- Davide


<Prev in Thread] Current Thread [Next in Thread>