util: Fix compilation of envlist.c for MinGW
PATCH 1/1 util: Fix compilation of envlist.c for MinGW
MinGW has no strtok_r, so we need a declaration in sysemu/os-win32.h. We must also fix the include statements in util/envlist.c to include that file.
We currently don't need an implementation of strtok_r because the code is compiled but not linked for MinGW.
--- include/sysemu/os-win32.h | 2 ++ util/envlist.c | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-)
include/sysemu/os-win32.h +2 -0
@@ -73,6 +73,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); +char *strtok_r (char *str,const char *delim,char **saveptr); +static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}static inline void os_setup_post (void ) {}
util/envlist.c +1 -6
@@ -1,9 +1,4 @@ -#include <assert.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - +#include "qemu-common.h" #include "qemu/queue.h" #include "qemu/envlist.h"
Signature · 1 line
1.7.10.4
Quoted 6 lines · Stefan Weil
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.
I think it would be better to fix the build system so that unnecessary files are not compiled.
Quoted 39 lines
Signed-off-by Stefan Weil <[email protected]>--- include/sysemu/os-win32.h | 2 ++ util/envlist.c | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-)include/sysemu/os-win32.h +2
-0@@ -73,6 +73,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); +char *strtok_r (char *str,const char *delim,char **saveptr); +static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}static inline void os_setup_post (void ) {}util/envlist.c +1
-7@@ -1,9 +1,4 @@ -#include <assert.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - +#include "qemu-common.h" #include "qemu/queue.h" #include "qemu/envlist.h" --1.7.10.4
Am 17.01.2013 21:45, schrieb Blue Swirl:
Quoted 10 lines · Stefan Weil
Quoted 6 lines
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.I think it would be better to fix the build system so that unnecessary files are not compiled.
That's what I suggested first, but keeping things simple is also a good argument. Perhaps we should accept that libqemuutil.a can contain some unnecessary files (that's the status quo!).
We also get the additional benefit of more portable code. Even if that portability is not needed for the moment, it might be useful later.
Stefan
Quoted 12 lines · Stefan Weil
Am 17.01.2013 21:45, schrieb Blue Swirl:
Quoted 10 lines · Stefan Weil
Quoted 7 lines
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.
Quoted 7 lines
Quoted 2 lines
I think it would be better to fix the build system so that unnecessary files are not compiled.
That's what I suggested first, but keeping things simple is also a good argument. Perhaps we should accept that libqemuutil.a can contain some unnecessary files (that's the status quo!).
This could be related. I get build errors on OpenBSD:
LINK i386-bsd-user/qemu-i386
../libqemuutil.a(oslib-posix.o)(.text+0x540): In function `qemu_vmalloc':
/src/qemu/util/oslib-posix.c:112: multiple definition of qemu_vmalloc' bsd-user/mmap.o(.text+0x400):/src/qemu/bsd-user/mmap.c:78: first defined here /usr/bin/ld: Warning: size of symbol qemu_vmalloc' changed from 260 in bsd-user/mmap.o to 124 in ../libqemuutil.a(oslib-posix.o)
Quoted 4 lines
We also get the additional benefit of more portable code. Even if that portability is not needed for the moment, it might be useful later.
Yes, though building as an example KVM code on Win32 may be useful one day, that day may be distant.
Quoted 3 lines
Stefan
Il 17/01/2013 22:18, Blue Swirl ha scritto:
Quoted 21 lines · Stefan Weil
Quoted 12 lines
Am 17.01.2013 21:45, schrieb Blue Swirl:
Quoted 10 lines · Stefan Weil
Quoted 7 lines
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.Quoted 7 lines
Quoted 2 lines
I think it would be better to fix the build system so that unnecessary files are not compiled.
That's what I suggested first, but keeping things simple is also a good argument. Perhaps we should accept that libqemuutil.a can contain some unnecessary files (that's the status quo!).
Quoted 7 lines
This could be related. I get build errors on OpenBSD:
LINK i386-bsd-user/qemu-i386
../libqemuutil.a(oslib-posix.o)(.text+0x540): In function `qemu_vmalloc':
/src/qemu/util/oslib-posix.c:112: multiple definition ofqemu_vmalloc' bsd-user/mmap.o(.text+0x400):/src/qemu/bsd-user/mmap.c:78: first defined here /usr/bin/ld: Warning: size of symbolqemu_vmalloc' changed from 260 inbsd-user/mmap.oto 124 in ../libqemuutil.a(oslib-posix.o)
Does this fix it?
bsd-user/mmap.c +1 -1
@@ -74,7 +74,7 @@ void mmap_unlock(void) }#endif -void *qemu_vmalloc (size_t size) +static void *qemu_vmalloc (size_t size) {void *p;mmap_lock ();
(A better change is of course to also rename qemu_vmalloc).
Quoted 7 lines
Quoted 4 lines
We also get the additional benefit of more portable code. Even if that portability is not needed for the moment, it might be useful later.
Yes, though building as an example KVM code on Win32 may be useful one day, that day may be distant.
That's not the kind of extra code that Stefan is talking about. It's extra data structures (envlist.c) that are placed in a static library but do not appear in any final build product.
Instead, "building KVM code on Win32" is in fact something we have been doing for years, see kvm-stub.c.
Paolo
Quoted 37 lines · Paolo Bonzini
Il 17/01/2013 22:18, Blue Swirl ha scritto:
Quoted 21 lines · Stefan Weil
Quoted 12 lines
Am 17.01.2013 21:45, schrieb Blue Swirl:
Quoted 10 lines · Stefan Weil
Quoted 7 lines
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.Quoted 7 lines
Quoted 2 lines
I think it would be better to fix the build system so that unnecessary files are not compiled.
That's what I suggested first, but keeping things simple is also a good argument. Perhaps we should accept that libqemuutil.a can contain some unnecessary files (that's the status quo!).
Quoted 7 lines
This could be related. I get build errors on OpenBSD:
LINK i386-bsd-user/qemu-i386
../libqemuutil.a(oslib-posix.o)(.text+0x540): In function `qemu_vmalloc':
/src/qemu/util/oslib-posix.c:112: multiple definition ofqemu_vmalloc' bsd-user/mmap.o(.text+0x400):/src/qemu/bsd-user/mmap.c:78: first defined here /usr/bin/ld: Warning: size of symbolqemu_vmalloc' changed from 260 inbsd-user/mmap.oto 124 in ../libqemuutil.a(oslib-posix.o)Does this fix it?
bsd-user/mmap.c +0
-0
bsd-user/mmap.c void mmap_unlock(void) · line 80
Quoted 8 lines
bsd-user/mmap.c +1
-1@@ -74,7 +74,7 @@ void mmap_unlock(void) }#endif -void *qemu_vmalloc (size_t size) +static void *qemu_vmalloc (size_t size) {void *p;mmap_lock ();
No, it conflicts with the function prototype.
Quoted 2 lines
(A better change is of course to also rename
qemu_vmalloc).
This works.
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
We also get the additional benefit of more portable code. Even if that portability is not needed for the moment, it might be useful later.
Yes, though building as an example KVM code on Win32 may be useful one day, that day may be distant.
Quoted 6 lines
That's not the kind of extra code that Stefan is talking about. It's extra data structures (
envlist.c) that are placed in a static library but do not appear in any final build product.Instead, "building KVM code on Win32" is in fact something we have been doing for years, see
kvm-stub.c.
I think a similar case would be to compile the non-stub versions on Win32 also but not link them in. For example, in theory envlist.c could use POSIX only features.
Quoted 2 lines
Paolo
Blue Swirl
AppliedThanks, applied.
Quoted 45 lines · Stefan Weil
MinGW has no
strtok_r, so we need a declaration insysemu/os-win32.h. We must also fix the include statements inutil/envlist.cto include that file.We currently don't need an implementation of
strtok_rbecause the code is compiled but not linked for MinGW.Signed-off-by Stefan Weil <[email protected]>--- include/sysemu/os-win32.h | 2 ++ util/envlist.c | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-)include/sysemu/os-win32.h +2
-0@@ -73,6 +73,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);#undef localtime_rstruct tm *localtime_r (const time_t *timep,struct tm *result); +char *strtok_r (char *str,const char *delim,char **saveptr); +static inline void os_setup_signal_handling (void ) {}static inline void os_daemonize (void ) {}static inline void os_setup_post (void ) {}util/envlist.c +1
-7@@ -1,9 +1,4 @@ -#include <assert.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - +#include "qemu-common.h" #include "qemu/queue.h" #include "qemu/envlist.h" --1.7.10.4