diff mbox series

util: fix to check if target OS is linux in util/mmap-alloc.c

Message ID 20200306120735.24457-1-jingqi.liu@intel.com
State New
Headers show
Series util: fix to check if target OS is linux in util/mmap-alloc.c | expand

Commit Message

Liu, Jingqi March 6, 2020, 12:07 p.m. UTC
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 <jingqi.liu@intel.com>
---
 util/mmap-alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Peter Maydell March 6, 2020, 12:14 p.m. UTC | #1
On Fri, 6 Mar 2020 at 12:12, Jingqi Liu <jingqi.liu@intel.com> 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 <jingqi.liu@intel.com>
> ---
>  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.

thanks
-- PMM
Liu, Jingqi March 6, 2020, 1:30 p.m. UTC | #2
On 3/6/2020 8:14 PM, Peter Maydell wrote:
> On Fri, 6 Mar 2020 at 12:12, Jingqi Liu <jingqi.liu@intel.com> 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 <jingqi.liu@intel.com>
>> ---
>>   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
no-reply@patchew.org March 6, 2020, 1:39 p.m. UTC | #3
Patchew URL: https://patchew.org/QEMU/20200306120735.24457-1-jingqi.liu@intel.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

File: "/tmp/qemu-nsis\qemu-doc.html" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
   /oname=outfile one_file_only)
Error in script "/tmp/qemu-test/src/qemu.nsi" on line 180 -- aborting creation process
make: *** [Makefile:1162: qemu-setup-4.2.50.exe] Error 1
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 664, in <module>
    sys.exit(main())
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=129637ca425f4fae823349cd2ea3d4b0', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-lcaifi77/src/docker-src.2020-03-06-08.36.29.5278:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=129637ca425f4fae823349cd2ea3d4b0
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-lcaifi77/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    3m26.534s
user    0m7.926s


The full log is available at
http://patchew.org/logs/20200306120735.24457-1-jingqi.liu@intel.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
diff mbox series

Patch

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
 
 #include "qemu/osdep.h"
 #include "qemu/mmap-alloc.h"