lkml.org 
[lkml]   [2004]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: MSEC_TO_JIFFIES is messed up...
From
Date
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]
\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.086 / U:1.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site