Subversion Repositories HelenOS

Rev

Rev 3386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3386 Rev 4153
Line 33... Line 33...
33
 */
33
 */
34
 
34
 
35
#ifndef LIBC_ALIGN_H_
35
#ifndef LIBC_ALIGN_H_
36
#define LIBC_ALIGN_H_
36
#define LIBC_ALIGN_H_
37
 
37
 
38
/** Align to the nearest lower address.
38
/** Align to the nearest lower address which is a power of two.
39
 *
39
 *
40
 * @param s Address or size to be aligned.
40
 * @param s     Address or size to be aligned.
41
 * @param a Size of alignment, must be power of 2.
41
 * @param a     Size of alignment, must be power of 2.
42
 */
42
 */
43
#define ALIGN_DOWN(s, a)    ((s) & ~((a) - 1))
43
#define ALIGN_DOWN(s, a)    ((s) & ~((a) - 1))
44
 
44
 
45
 
45
 
46
/** Align to the nearest higher address.
46
/** Align to the nearest higher address which is a power of two.
47
 *
47
 *
48
 * @param s Address or size to be aligned.
48
 * @param s     Address or size to be aligned.
49
 * @param a Size of alignment, must be power of 2.
49
 * @param a     Size of alignment, must be power of 2.
50
 */
50
 */
51
#define ALIGN_UP(s, a)      ((long)((s) + ((a) - 1)) & ~((long) (a) - 1))
51
#define ALIGN_UP(s, a)      ((long)((s) + ((a) - 1)) & ~((long) (a) - 1))
52
 
52
 
-
 
53
/** Round up to the nearest higher boundary.
-
 
54
 *
-
 
55
 * @param n     Number to be aligned.
-
 
56
 * @param b     Boundary, arbitrary unsigned number.
-
 
57
 */
-
 
58
#define ROUND_UP(n, b)      (((n) / (b) + ((n) % (b) != 0)) * (b))
-
 
59
 
53
#endif
60
#endif
54
 
61
 
55
/** @}
62
/** @}
56
 */
63
 */