--- linux-2.5/include/linux/mman.h	Sun Sep  7 10:05:18 2003
+++ calc-vm-bit-optimizing-macro-2.6.0-t6//include/linux/mman.h	Tue Sep 30 10:02:01 2003
@@ -28,10 +28,28 @@
 	vm_acct_memory(-pages);
 }
 
-/* Optimisation macro. */
-#define _calc_vm_trans(x,bit1,bit2) \
-  ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
-   : ((x) & (bit1)) / ((bit1) / (bit2)))
+/* 
+ * assert that only a single bit is on in 'bit' 
+ */ 
+static inline void assert_single_bit(unsigned long bit)
+{
+	BUG_ON(bit & (bit - 1)); 
+}
+/* 
+ * Optimisation function.  It is equivalent to: 
+ *      (x & bit1) ? bit2 : 0
+ * but this version is faster.  
+ * ("bit1" and "bit2" must be single bits). 
+ */
+static inline unsigned long 
+_calc_vm_trans(unsigned long x, unsigned long bit1, unsigned long bit2) 
+{
+	assert_single_bit(bit1); 
+	assert_single_bit(bit2); 
+
+	return ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1))
+		: ((x) & (bit1)) / ((bit1) / (bit2))); 
+}
 
 /*
  * Combine the mmap "prot" argument into "vm_flags" used internally.
