00001 /* 00002 * mod(a,b) 00003 * non_negative a,b; b is a power of 2 00004 * Computes a mod b 00005 */ 00006 #define mod(a,b) ((a) & ((b) - 1)) 00007 00008 /* 00009 * rounddown(a,b) 00010 * non-negative a, b; 00011 * Compute a rounded down to the nearest multiple of b where b is a 00012 * power of two. 00013 */ 00014 # define rounddown(a,b) ( (a) & ~((b) - 1) ) 00015 00016 /* 00017 * roundup(n,mult) 00018 * non-negative a, b; 00019 * Round n up to the nearest multiple of mult. 00020 * mult must be a power of two. 00021 */ 00022 # define roundup(n,mult) rounddown( (n) + (mult) - 1, (mult) )