[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/25] osdep: Document differences in rounding macros
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 17/25] osdep: Document differences in rounding macros |
Date: |
Tue, 2 Aug 2016 21:39:27 +0200 |
From: Eric Blake <address@hidden>
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 <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
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 d7c111d..9e9fa61 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.7.4
- [Qemu-devel] [PULL 10/25] qdist: fix memory leak during binning, (continued)
- [Qemu-devel] [PULL 10/25] qdist: fix memory leak during binning, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 07/25] util: Drop inet_listen(), Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 11/25] qdist: use g_realloc_n instead of g_realloc, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 12/25] qdist: return "(empty)" instead of NULL when printing an empty dist, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 13/25] mptsas: really fix migration compatibility, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 14/25] i2c: fix migration regression introduced by broadcast support, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 15/25] nbd: Fix bad flag detection on server, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 19/25] fw_cfg: Make base type "fw_cfg" abstract, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 18/25] block: Cater to iscsi with non-power-of-2 discard, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 17/25] osdep: Document differences in rounding macros,
Paolo Bonzini <=
- [Qemu-devel] [PULL 16/25] nbd: Limit nbdflags to 16 bits, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 20/25] apic: fix broken migration for kvm-apic, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 21/25] x86: ioapic: ignore level irq during processing, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 22/25] x86: ioapic: add support for explicit EOI, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 25/25] util: Fix assertion in iov_copy() upon zero 'bytes' and non-zero 'offset', Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 24/25] qdev: Fix use after free in qdev_init_nofail error path, Paolo Bonzini, 2016/08/02
- [Qemu-devel] [PULL 23/25] Reorganize help output of '-display' option, Paolo Bonzini, 2016/08/02
- Re: [Qemu-devel] [PULL 00/25] Misc QEMU fixes for 2016-08-02, Peter Maydell, 2016/08/03