Re: [RFC PATCH] consolidate within() implementations

From: Mikael Pettersson
Date: Tue Jun 03 2008 - 05:10:31 EST


Peter Oberparleiter writes:
> +static inline int addr_within_len(const void *addr, const void *start,
> + size_t len)
> +{
> + return ((unsigned long) addr >= (unsigned long) start) &&
> + ((unsigned long) addr < ((unsigned long) start + len));
> +}

On most machines you'd get better code with

return (unsigned long)((char*)addr - (char*)start) < (unsigned long)len;

Maybe a candidate for a follow-up optimisation patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/