[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 02/11] include/qemu/osdep.h: Add macros for point
From: |
Sergey Fedorov |
Subject: |
[Qemu-devel] [PATCH v2 02/11] include/qemu/osdep.h: Add macros for pointer alignment |
Date: |
Fri, 22 Apr 2016 19:08:44 +0300 |
From: Sergey Fedorov <address@hidden>
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 <address@hidden>
Signed-off-by: Sergey Fedorov <address@hidden>
---
include/qemu/osdep.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e3bc50b61359..1e3221cbec65 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -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
--
2.8.1
- [Qemu-devel] [PATCH v2 00/11] tcg: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 02/11] include/qemu/osdep.h: Add macros for pointer alignment,
Sergey Fedorov <=
- [Qemu-devel] [PATCH v2 01/11] include/qemu/osdep.h: Add a macro to check for alignment, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 03/11] tci: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 04/11] tcg/ppc: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 05/11] tcg/i386: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 08/11] tcg/aarch64: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 11/11] tcg: Note requirement on atomic direct jump patching, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 06/11] tcg/s390: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22
- [Qemu-devel] [PATCH v2 10/11] tcg/mips: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/22