Re: [PATCH] document optimizing macro for translating PROT_ to VM_ bits

From: Jamie Lokier
Date: Mon Sep 29 2003 - 10:36:53 EST


Muli Ben-Yehuda wrote:
> -/* Optimisation macro. */
> +/* Optimisation macro, used to be defined as: */
> +/* ((bit1 == bit2) ? (x & bit1) : (x & bit1) ? bit2 : 0) */
> +/* but this version is faster */
> +/* "check if bit1 is on in 'x'. If it is, return bit2" */
> #define _calc_vm_trans(x,bit1,bit2) \
> ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
> : ((x) & (bit1)) / ((bit1) / (bit2)))

I agree with the intent of that comment, but the code in it is
unnecessarily complex. See if you like this, and if you do feel free
to submit it as a patch:

/* Optimisation macro. It is equivalent to:
(x & bit1) ? bit2 : 0
but this version is faster. ("bit1" and "bit2" must be single bits). */

cheers,
-- Jamie
-
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/