Lines Matching defs:align

231  * Macros for various sorts of alignment and rounding.  The "align" must
236 * return x rounded down to an align boundary
237 * eg, P2ALIGN(1200, 1024) == 1024 (1*align)
238 * eg, P2ALIGN(1024, 1024) == 1024 (1*align)
239 * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align)
240 * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align)
242 #define P2ALIGN(x, align) ((x) & -(align))
245 * return x % (mod) align
246 * eg, P2PHASE(0x1234, 0x100) == 0x34 (x-0x12*align)
247 * eg, P2PHASE(0x5600, 0x100) == 0x00 (x-0x56*align)
249 #define P2PHASE(x, align) ((x) & ((align) - 1))
254 * eg, P2NPHASE(0x1234, 0x100) == 0xcc (0x13*align-x)
255 * eg, P2NPHASE(0x5600, 0x100) == 0x00 (0x56*align-x)
257 #define P2NPHASE(x, align) (-(x) & ((align) - 1))
260 * return x rounded up to an align boundary
261 * eg, P2ROUNDUP(0x1234, 0x100) == 0x1300 (0x13*align)
262 * eg, P2ROUNDUP(0x5600, 0x100) == 0x5600 (0x56*align)
264 #define P2ROUNDUP(x, align) (-(-(x) & -(align)))
268 * eg, P2END(0x1234, 0x100) == 0x12ff (0x13*align - 1)
269 * eg, P2END(0x5600, 0x100) == 0x56ff (0x57*align - 1)
271 #define P2END(x, align) (-(~(x) & -(align)))
274 * return x rounded up to the next phase (offset) within align.
275 * phase should be < align.
276 * eg, P2PHASEUP(0x1234, 0x100, 0x10) == 0x1310 (0x13*align + phase)
277 * eg, P2PHASEUP(0x5600, 0x100, 0x10) == 0x5610 (0x56*align + phase)
279 #define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align)))
282 * return TRUE if adding len to off would cause it to cross an align
287 #define P2BOUNDARY(off, len, align) \
288 (((off) ^ ((off) + (len) - 1)) > (align) - 1)
308 #define P2ALIGN_TYPED(x, align, type) \
309 ((type)(x) & -(type)(align))
310 #define P2PHASE_TYPED(x, align, type) \
311 ((type)(x) & ((type)(align) - 1))
312 #define P2NPHASE_TYPED(x, align, type) \
313 (-(type)(x) & ((type)(align) - 1))
314 #define P2ROUNDUP_TYPED(x, align, type) \
315 (-(-(type)(x) & -(type)(align)))
316 #define P2END_TYPED(x, align, type) \
317 (-(~(type)(x) & -(type)(align)))
318 #define P2PHASEUP_TYPED(x, align, phase, type) \
319 ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
320 #define P2CROSS_TYPED(x, y, align, type) \
321 (((type)(x) ^ (type)(y)) > (type)(align) - 1)