| Submitter | Stefan Hajnoczi |
|---|---|
| Date | Nov. 17, 2011, 1:40 p.m. |
| Message ID | <1321537232-799-2-git-send-email-stefanha@linux.vnet.ibm.com> |
| Download | mbox | patch |
| Permalink | /patch/126220/ |
| State | New |
| Headers | show |
Comments
Patch
diff --git a/qemu-common.h b/qemu-common.h index 2ce47aa..44870fe 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -341,6 +341,12 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) return res.ll; } +/* Round number down to multiple */ +#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) + +/* Round number up to multiple */ +#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) + #include "module.h" #endif
Add macros for aligning a number to a multiple, for example: QEMU_ALIGN_DOWN(500, 2000) = 0 QEMU_ALIGN_UP(500, 2000) = 2000 Since ALIGN_UP() is a common macro name use the QEMU_* namespace prefix. Hopefully this will protect us from included headers that leak something with a similar name. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> --- qemu-common.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)