]> Git Repo - qemu.git/commitdiff
include/qemu/osdep.h: Add macros for pointer alignment
authorSergey Fedorov <[email protected]>
Fri, 22 Apr 2016 16:08:44 +0000 (19:08 +0300)
committerRichard Henderson <[email protected]>
Fri, 13 May 2016 00:06:40 +0000 (14:06 -1000)
These macros provide a convenient way to n-byte align pointers up and
down and check if a pointer is n-byte aligned.

Signed-off-by: Sergey Fedorov <[email protected]>
Signed-off-by: Sergey Fedorov <[email protected]>
Message-Id: <1461341333[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
include/qemu/osdep.h

index e3bc50b613597462b3b79458dc66e5e65ec50c35..1e3221cbec65dbd6c360635da4b7a3840042c5f3 100644 (file)
@@ -161,6 +161,17 @@ extern int daemon(int, int);
 /* Check if n is a multiple of m */
 #define QEMU_IS_ALIGNED(n, m) (((n) % (m)) == 0)
 
+/* n-byte align pointer down */
+#define QEMU_ALIGN_PTR_DOWN(p, n) \
+    ((typeof(p))QEMU_ALIGN_DOWN((uintptr_t)(p), (n)))
+
+/* n-byte align pointer up */
+#define QEMU_ALIGN_PTR_UP(p, n) \
+    ((typeof(p))QEMU_ALIGN_UP((uintptr_t)(p), (n)))
+
+/* Check if pointer p is n-bytes aligned */
+#define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n))
+
 #ifndef ROUND_UP
 #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
 #endif
This page took 0.028057 seconds and 4 git commands to generate.