diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-11-29 21:29:17 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-01-24 17:40:01 +0100 |
commit | e5354657a626b325c31888f33de88ac6d39e2fcb (patch) | |
tree | 23fdaf1aa96d4ec78c9f72a9560c6c3f637da0f0 /util/oslib-posix.c | |
parent | 355ef4ac95a7a47d5c7201ccd910056a100d2fdf (diff) |
qemu_memalign: Allow small alignments
The functions used by qemu_memalign() require an alignment that is at
least sizeof(void*). Adjust it if it is too small.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: BenoƮt Canet <benoit@irqsave.net>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r-- | util/oslib-posix.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c index f5c401646f..d5dca4729a 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -88,6 +88,11 @@ void *qemu_oom_check(void *ptr) void *qemu_memalign(size_t alignment, size_t size) { void *ptr; + + if (alignment < sizeof(void*)) { + alignment = sizeof(void*); + } + #if defined(_POSIX_C_SOURCE) && !defined(__sun__) int ret; ret = posix_memalign(&ptr, alignment, size); |