From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, pl@kamp.de, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 3/4] osdep: Document differences in rounding macros
Date: Thu, 21 Jul 2016 13:34:47 -0600 [thread overview]
Message-ID: <1469129688-22848-4-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1469129688-22848-1-git-send-email-eblake@redhat.com>
Make it obvious which macros are safe in which situations.
Useful since QEMU_ALIGN_UP and ROUND_UP both purport to do
the same thing, but differ on whether the alignment must be
a power of 2.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
include/qemu/osdep.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index fbb8759..9991fb0 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -158,7 +158,8 @@ extern int daemon(int, int);
/* Round number down to multiple */
#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m))
-/* Round number up to multiple */
+/* Round number up to multiple. Safe when m is not a power of 2 (see
+ * ROUND_UP for a faster version when a power of 2 is guaranteed) */
#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m))
/* Check if n is a multiple of m */
@@ -175,6 +176,9 @@ extern int daemon(int, int);
/* Check if pointer p is n-bytes aligned */
#define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n))
+/* Round number up to multiple. Requires that d be a power of 2 (see
+ * QEMU_ALIGN_UP for a safer but slower version on arbitrary
+ * numbers) */
#ifndef ROUND_UP
#define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
#endif
--
2.5.5
next prev parent reply other threads:[~2016-07-21 19:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 19:34 [Qemu-devel] [PATCH for-2.7 0/4] NBD and block alignment fixes Eric Blake
2016-07-21 19:34 ` [Qemu-devel] [PATCH 1/4] nbd: Fix bad flag detection on server Eric Blake
2016-07-21 19:34 ` [Qemu-devel] [PATCH 2/4] nbd: Limit nbdflags to 16 bits Eric Blake
2016-08-01 9:17 ` Paolo Bonzini
2016-08-01 11:43 ` Eric Blake
2016-08-01 11:50 ` Paolo Bonzini
2016-07-21 19:34 ` Eric Blake [this message]
2016-08-01 9:19 ` [Qemu-devel] [PATCH 3/4] osdep: Document differences in rounding macros Paolo Bonzini
2016-07-21 19:34 ` [Qemu-devel] [PATCH 4/4] block: Cater to iscsi with non-power-of-2 discard Eric Blake
2016-07-26 13:28 ` Stefan Hajnoczi
2016-07-27 7:25 ` Fam Zheng
2016-07-28 2:39 ` Eric Blake
2016-08-01 9:22 ` Paolo Bonzini
2016-10-25 12:03 ` Peter Lieven
2016-10-25 12:09 ` Paolo Bonzini
2016-10-25 12:12 ` Peter Lieven
2016-10-25 12:19 ` Paolo Bonzini
2016-10-25 12:42 ` Peter Lieven
2016-10-25 13:59 ` Eric Blake
2016-10-25 14:20 ` Peter Lieven
2016-10-25 14:35 ` Eric Blake
2016-10-25 14:36 ` Paolo Bonzini
2016-10-25 16:12 ` Eric Blake
2016-11-08 11:03 ` Peter Lieven
2016-11-08 16:43 ` Eric Blake
2016-11-11 4:02 ` Eric Blake
2016-07-27 7:26 ` [Qemu-devel] [PATCH for-2.7 0/4] NBD and block alignment fixes Fam Zheng
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=1469129688-22848-4-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--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).