aboutsummaryrefslogtreecommitdiff
path: root/util/oslib-win32.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-10-21 19:38:03 +0200
committerRichard Henderson <richard.henderson@linaro.org>2021-01-07 05:09:06 -1000
commited6f53f9ca9eda16f5edb157fbfe6be09cefc537 (patch)
tree9b63d0adb8af662ca7c4780d0f4cb1609a622211 /util/oslib-win32.c
parentdfbd0b873a85021c083d9b4b84630c3732645963 (diff)
downloadqemu-ed6f53f9ca9eda16f5edb157fbfe6be09cefc537.zip
qemu-ed6f53f9ca9eda16f5edb157fbfe6be09cefc537.tar.gz
qemu-ed6f53f9ca9eda16f5edb157fbfe6be09cefc537.tar.bz2
util/oslib: Assert qemu_try_memalign() alignment is a power of 2
qemu_try_memalign() expects a power of 2 alignment: - posix_memalign(3): The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). - _aligned_malloc() The alignment value, which must be an integer power of 2. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201021173803.2619054-3-philmd@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'util/oslib-win32.c')
-rw-r--r--util/oslib-win32.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 8adc651..e6f83e1 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -58,6 +58,7 @@ void *qemu_try_memalign(size_t alignment, size_t size)
void *ptr;
g_assert(size != 0);
+ g_assert(is_power_of_2(alignment));
ptr = _aligned_malloc(alignment, size);
trace_qemu_memalign(alignment, size, ptr);
return ptr;