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

From: Muli Ben-Yehuda
Date: Mon Sep 29 2003 - 04:08:08 EST


In continuation to the thread at
http://marc.theaimsgroup.com/?l=linux-kernel&m=3D106270456516176&w=2 wrt
translating PROT_(censored) bits to VM_(censored) bits, here's a small
comment only patch to document the optimizing macro Jamie's patch
used. Against 2.6.0-t6, but should apply to anything
recent. Compiles.

Cheers,
Muli

--- linux-2.5/include/linux/mman.h Sun Sep 7 10:05:18 2003
+++ optimizing-macro-2.6.0-t6/include/linux/mman.h Mon Sep 29 11:53:12 2003
@@ -28,7 +28,10 @@
vm_acct_memory(-pages);
}

-/* 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)))

--
Muli Ben-Yehuda
http://www.mulix.org

Attachment: signature.asc
Description: Digital signature