Patchwork [04/22] qemu_memalign: Allow small alignments

login
register
mail settings
Submitter Kevin Wolf
Date Dec. 11, 2013, 9:08 p.m.
Message ID <1386796109-15264-5-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/300418/
State New
Headers show

Comments

Kevin Wolf - Dec. 11, 2013, 9:08 p.m.
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>
---
 util/oslib-posix.c | 5 +++++
 1 file changed, 5 insertions(+)
Wayne Xia - Dec. 12, 2013, 3:09 a.m.
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

Patch

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index e00a44c..54f8932 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -85,6 +85,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);