Changeset f62355a in mainline


Ignore:
Timestamp:
2005-12-07T23:38:53Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9d5e23c
Parents:
b87f418
Message:

Improved ALIGN_UP.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/include/align.h

    rb87f418 rf62355a  
    3030#define __ALIGN_H__
    3131
     32/** Align to the nearest lower address.
     33 *
     34 * @param s Address or size to be aligned.
     35 * @param a Size of alignment, must be power of 2.
     36 */
     37#define ALIGN_DOWN(s, a)        ((s) & ~((a) - 1))
     38
     39
    3240/** Align to the nearest higher address.
    3341 *
    3442 * @param s Address or size to be aligned.
    35  * @param a Size of alignment.
     43 * @param a Size of alignment, must be power of 2.
    3644 */
    37 #define ALIGN_UP(s, a)          ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s))
    38 
    39 /** Align to the nearest lower address.
    40  *
    41  * @param s Address or size to be aligned.
    42  * @param a Size of alignment.
    43  */
    44 #define ALIGN_DOWN(s, a)        ((s) & ~((a)-1))
     45#define ALIGN_UP(s, a)          ((s + ((a) - 1)) & ~((a) - 1))
    4546
    4647#endif
Note: See TracChangeset for help on using the changeset viewer.