qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] util: fix to check if target OS is linux in util/mmap-alloc.


From: Liu, Jingqi
Subject: Re: [PATCH] util: fix to check if target OS is linux in util/mmap-alloc.c
Date: Fri, 6 Mar 2020 21:30:03 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 3/6/2020 8:14 PM, Peter Maydell wrote:
On Fri, 6 Mar 2020 at 12:12, Jingqi Liu <address@hidden> wrote:
The CONFIG_LINUX symbol is always undefined before including "qemu/osdep.h".
Use __linux__ to check if target OS is linux instead of CONFIG_LINUX.

Signed-off-by: Jingqi Liu <address@hidden>
---
  util/mmap-alloc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 27dcccd8ec..8340540292 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -10,12 +10,12 @@
   * later.  See the COPYING file in the top-level directory.
   */

-#ifdef CONFIG_LINUX
+#ifdef __linux__
  #include <linux/mman.h>
-#else  /* !CONFIG_LINUX */
+#else
  #define MAP_SYNC              0x0
  #define MAP_SHARED_VALIDATE   0x0
-#endif /* CONFIG_LINUX */
+#endif
This is not the right way to fix this. osdep.h must go
first, no exceptions.

osdep.h pulls in sys/mman.h, which defines the MAP_* constants

except for MAP_SYNC and MAP_SHARED_VALIDATE.

I'm curious that this system header doesn't define them.

How about just adding the following code in util/mmap-alloc.c ?

#ifndef MAP_SYNC
#define MAP_SYNC 0x80000
#endif
#ifndef MAP_SYNC
#define MAP_SYNC 0x80000
#endif

#ifndef MAP_SHARED_VALIDATE
#define MAP_SHARED_VALIDATE 0x03
#endif

Thanks,

Jingqi


thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]