Rev 564 | Rev 571 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 564 | Rev 565 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | */ |
27 | */ |
28 | 28 | ||
29 | #ifndef __ALIGN_H__ |
29 | #ifndef __ALIGN_H__ |
30 | #define __ALIGN_H__ |
30 | #define __ALIGN_H__ |
31 | 31 | ||
32 | /** Align to the nearest higher address. |
32 | /** Align to the nearest lower address. |
33 | * |
33 | * |
34 | * @param s Address or size to be aligned. |
34 | * @param s Address or size to be aligned. |
35 | * @param a Size of alignment. |
35 | * @param a Size of alignment, must be power of 2. |
36 | */ |
36 | */ |
37 | #define ALIGN_UP(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s)) |
37 | #define ALIGN_DOWN(s, a) ((s) & ~((a) - 1)) |
38 | 38 | ||
- | 39 | ||
39 | /** Align to the nearest lower address. |
40 | /** Align to the nearest higher address. |
40 | * |
41 | * |
41 | * @param s Address or size to be aligned. |
42 | * @param s Address or size to be aligned. |
42 | * @param a Size of alignment. |
43 | * @param a Size of alignment, must be power of 2. |
43 | */ |
44 | */ |
44 | #define ALIGN_DOWN(s, a) ((s) & ~((a)-1)) |
45 | #define ALIGN_UP(s, a) ((s + ((a) - 1)) & ~((a) - 1)) |
45 | 46 | ||
46 | #endif |
47 | #endif |