Changeset 71f1cc1 in mainline


Ignore:
Timestamp:
2008-10-25T14:58:54Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8d32152
Parents:
c947dda
Message:

Add the ROUND_UP() macro.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/align.h

    rc947dda r71f1cc1  
    3636#define LIBC_ALIGN_H_
    3737
    38 /** Align to the nearest lower address.
     38/** Align to the nearest lower address which is a power of two.
    3939 *
    40  * @param s Address or size to be aligned.
    41  * @param a Size of alignment, must be power of 2.
     40 * @param s             Address or size to be aligned.
     41 * @param a             Size of alignment, must be power of 2.
    4242 */
    4343#define ALIGN_DOWN(s, a)        ((s) & ~((a) - 1))
    4444
    4545
    46 /** Align to the nearest higher address.
     46/** Align to the nearest higher address which is a power of two.
    4747 *
    48  * @param s Address or size to be aligned.
    49  * @param a Size of alignment, must be power of 2.
     48 * @param s             Address or size to be aligned.
     49 * @param a             Size of alignment, must be power of 2.
    5050 */
    5151#define ALIGN_UP(s, a)          ((long)((s) + ((a) - 1)) & ~((long) (a) - 1))
     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))
    5259
    5360#endif
Note: See TracChangeset for help on using the changeset viewer.