Re: [RFC][PATCH 1/4] add jiffies_to_nsecs() helper and fix up size of usecs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2005-07-14 at 13:28 -0700, Nishanth Aravamudan wrote:
> +static inline u64 jiffies_to_nsecs(const unsigned long j)
> +{
> +#if HZ <= NSEC_PER_SEC && !(NSEC_PER_SEC % HZ)
> +	return (NSEC_PER_SEC / HZ) * (u64)j;
> +#elif HZ > NSEC_PER_SEC && !(HZ % NSEC_PER_SEC)
> +	return ((u64)j + (HZ / NSEC_PER_SEC) - 1)/(HZ / NSEC_PER_SEC);
> +#else
> +	return ((u64)j * NSEC_PER_SEC) / HZ;
> +#endif
> +}

That might look a little better something like:

static inline u64 jiffies_to_nsecs(const unsigned long __j)
{
	u64 j = __j;

	if (HZ <= NSEC_PER_SEC && !(NSEC_PER_SEC % HZ))
		return (NSEC_PER_SEC / HZ) * j;
	else if (HZ > NSEC_PER_SEC && !(HZ % NSEC_PER_SEC))
		return (j + (HZ / NSEC_PER_SEC) - 1)/(HZ / NSEC_PER_SEC);
	else
		return (j * NSEC_PER_SEC) / HZ;
}

Compilers are smart :)

-- Dave

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux