From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v4 1/8] qemu-common: add QEMU_ALIGN_DOWN() and QEMU_ALIGN_UP() macros
Date: Wed, 23 Nov 2011 11:47:51 +0000 [thread overview]
Message-ID: <1322048878-26348-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1322048878-26348-1-git-send-email-stefanha@linux.vnet.ibm.com>
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(-)
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
next prev parent reply other threads:[~2011-11-23 12:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-23 11:47 [Qemu-devel] [PATCH v4 0/8] block: generic copy-on-read Stefan Hajnoczi
2011-11-23 11:47 ` Stefan Hajnoczi [this message]
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 2/8] coroutine: add qemu_co_queue_restart_all() Stefan Hajnoczi
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 3/8] block: add request tracking Stefan Hajnoczi
2011-12-05 12:17 ` Marcelo Tosatti
2011-12-05 12:20 ` Paolo Bonzini
2011-12-05 16:09 ` Marcelo Tosatti
2011-12-05 16:20 ` Stefan Hajnoczi
2011-12-05 16:31 ` Marcelo Tosatti
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 4/8] block: add bdrv_set_copy_on_read() Stefan Hajnoczi
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 5/8] block: wait for overlapping requests Stefan Hajnoczi
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 6/8] block: request overlap detection Stefan Hajnoczi
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 7/8] block: core copy-on-read logic Stefan Hajnoczi
2011-12-02 17:13 ` Marcelo Tosatti
2011-12-05 11:35 ` Stefan Hajnoczi
2011-11-23 11:47 ` [Qemu-devel] [PATCH v4 8/8] block: add -drive copy-on-read=on|off Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322048878-26348-2-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).