exec: use macro for alignment
PATCH 1/1 exec: use macro for alignment
Signed-off-by Chen Hanxiao <[email protected]>
--- exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
exec.c +3 -1
@@ -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
Signature · 1 line
2.1.0
exec.c static void *file_ram_alloc(RAMBlock *block, · line 1213
Quoted 13 lines · Chen Hanxiao
exec.c +3
-1+#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);
Hi,
the patch is a good idea, but please use ROUND_UP instead of defining your own ALIGN macro.
Thanks!
Paolo