[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/8] qemu-common: add QEMU_ALIGN_DOWN() and QEMU_
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v2 1/8] qemu-common: add QEMU_ALIGN_DOWN() and QEMU_ALIGN_UP() macros |
Date: |
Thu, 17 Nov 2011 13:40:25 +0000 |
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 <address@hidden>
---
qemu-common.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
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
--
1.7.7.1
- [Qemu-devel] [PATCH v2 0/8] block: generic copy-on-read, Stefan Hajnoczi, 2011/11/17
- [Qemu-devel] [PATCH v2 8/8] block: add -drive copy-on-read=on|off, Stefan Hajnoczi, 2011/11/17
- [Qemu-devel] [PATCH v2 3/8] block: add request tracking, Stefan Hajnoczi, 2011/11/17
- [Qemu-devel] [PATCH v2 2/8] coroutine: add qemu_co_queue_restart_all(), Stefan Hajnoczi, 2011/11/17
- [Qemu-devel] [PATCH v2 4/8] block: add bdrv_set_copy_on_read(), Stefan Hajnoczi, 2011/11/17
- [Qemu-devel] [PATCH v2 5/8] block: wait for overlapping requests, Stefan Hajnoczi, 2011/11/17