On 3/6/2020 8:14 PM, Peter Maydell wrote:
On Fri, 6 Mar 2020 at 12:12, Jingqi Liu <[email protected]> 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 <[email protected]>
---
  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