qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec: use macro for alignment
@ 2015-07-23 10:20 Chen Hanxiao
  2015-07-23 10:43 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Hanxiao @ 2015-07-23 10:20 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
 exec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index 7d60e15..f84b485 100644
--- a/exec.c
+++ b/exec.c
@@ -1153,6 +1153,8 @@ static long gethugepagesize(const char *path, Error **errp)
     return fs.f_bsize;
 }
 
+#define ALIGN(x, y)  (((x)+(y)-1) & ~((y)-1))
+
 static void *file_ram_alloc(RAMBlock *block,
                             ram_addr_t memory,
                             const char *path,
@@ -1207,7 +1209,7 @@ static void *file_ram_alloc(RAMBlock *block,
     unlink(filename);
     g_free(filename);
 
-    memory = (memory+hpagesize-1) & ~(hpagesize-1);
+    memory = ALIGN(memory, hpagesize);
 
     /*
      * ftruncate is not supported by hugetlbfs in older
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-23 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23 10:20 [Qemu-devel] [PATCH] exec: use macro for alignment Chen Hanxiao
2015-07-23 10:43 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).