Lines Matching refs:align

228  * Macros for various sorts of alignment and rounding.  The "align" must
233 * return x rounded down to an align boundary
234 * eg, P2ALIGN(1200, 1024) == 1024 (1*align)
235 * eg, P2ALIGN(1024, 1024) == 1024 (1*align)
236 * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align)
237 * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align)
239 #define P2ALIGN(x, align) ((x) & -(align))
242 * return x % (mod) align
243 * eg, P2PHASE(0x1234, 0x100) == 0x34 (x-0x12*align)
244 * eg, P2PHASE(0x5600, 0x100) == 0x00 (x-0x56*align)
246 #define P2PHASE(x, align) ((x) & ((align) - 1))
251 * eg, P2NPHASE(0x1234, 0x100) == 0xcc (0x13*align-x)
252 * eg, P2NPHASE(0x5600, 0x100) == 0x00 (0x56*align-x)
254 #define P2NPHASE(x, align) (-(x) & ((align) - 1))
257 * return x rounded up to an align boundary
258 * eg, P2ROUNDUP(0x1234, 0x100) == 0x1300 (0x13*align)
259 * eg, P2ROUNDUP(0x5600, 0x100) == 0x5600 (0x56*align)
261 #define P2ROUNDUP(x, align) (-(-(x) & -(align)))
265 * eg, P2END(0x1234, 0x100) == 0x12ff (0x13*align - 1)
266 * eg, P2END(0x5600, 0x100) == 0x56ff (0x57*align - 1)
268 #define P2END(x, align) (-(~(x) & -(align)))
271 * return x rounded up to the next phase (offset) within align.
272 * phase should be < align.
273 * eg, P2PHASEUP(0x1234, 0x100, 0x10) == 0x1310 (0x13*align + phase)
274 * eg, P2PHASEUP(0x5600, 0x100, 0x10) == 0x5610 (0x56*align + phase)
276 #define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align)))
279 * return TRUE if adding len to off would cause it to cross an align
284 #define P2BOUNDARY(off, len, align) \
285 (((off) ^ ((off) + (len) - 1)) > (align) - 1)
305 #define P2ALIGN_TYPED(x, align, type) \
306 ((type)(x) & -(type)(align))
307 #define P2PHASE_TYPED(x, align, type) \
308 ((type)(x) & ((type)(align) - 1))
309 #define P2NPHASE_TYPED(x, align, type) \
310 (-(type)(x) & ((type)(align) - 1))
311 #define P2ROUNDUP_TYPED(x, align, type) \
312 (-(-(type)(x) & -(type)(align)))
313 #define P2END_TYPED(x, align, type) \
314 (-(~(type)(x) & -(type)(align)))
315 #define P2PHASEUP_TYPED(x, align, phase, type) \
316 ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
317 #define P2CROSS_TYPED(x, y, align, type) \
318 (((type)(x) ^ (type)(y)) > (type)(align) - 1)