mingw32/64 fixes
RFC 1/1 mingw32/64 fixes
Hi
In fedora 21 when crosscompiling for windows I get that this functions are already defined. As they are declared there, I guess than in older complilers they weren't there. Is there a portable way to get happy both old and new compilers?
Once there, the only other error that I got is this, but I think that this is a bug on the compiler
(w32 have qemu configured for cross-compiling for windows 32 bit, w64 for 64).
The problem is with the assert() on that function.
assert(region_num < PCI_NUM_REGIONS);
If I comment that assert, change it to ((unsigned)PCI_NUM_REGIONS) or (PCI_NUM_REGIONS -1) the error go away.
Notice that there are other functions on that file that use the same/similar asserts on a different function that also access io_regions give no errors/warnings.
Any idea?
()amit-pull *)$ make -j5 -C /scratch/tmp/next/w32/
make: Entering directory '/scratch/tmp/next/w32'
CC hw/pci/pci.o/mnt/kvm/qemu/next/hw/pci/pci.c: In function 'pci_register_bar':/mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds]
r = &pci_dev->io_regions[region_num];
^/mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors/mnt/kvm/qemu/next/rules.mak:57: recipe for target 'hw/pci/pci.o' failed
make: *** [hw/pci/pci.o] Error 1
make: Leaving directory '/scratch/tmp/next/w32'
(amit-pull)$ make -j5 -C /scratch/tmp/next/w64/
make: Entering directory '/scratch/tmp/next/w64'
CC hw/pci/pci.o/mnt/kvm/qemu/next/hw/pci/pci.c: In function 'pci_register_bar':/mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds]
r = &pci_dev->io_regions[region_num];
^/mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds] /mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds] /mnt/kvm/qemu/next/hw/pci/pci.c:932:29: error: array subscript is above array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors/mnt/kvm/qemu/next/rules.mak:57: recipe for target 'hw/pci/pci.o' failed
make: *** [hw/pci/pci.o] Error 1
make: Leaving directory '/scratch/tmp/next/w64'
Later, Juan.
--- include/sysemu/os-win32.h | 8 -------- 1 file changed, 8 deletions(-)
include/sysemu/os-win32.h +0 -8
@@ -75,14 +75,6 @@/* Declaration of ffs() is missing in MinGW's strings.h. */ int ffs (int i); -/* Missing POSIX functions. Don't use MinGW-w64 macros. */ -#undef gmtime_r -struct tm *gmtime_r (const time_t *timep,struct tm *result); -#undef localtime_r -struct 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 ) {}
Signature · 1 line
2.1.0
Quoted 6 lines · Juan Quintela
Hi
In fedora 21 when crosscompiling for windows I get that this functions are already defined. As they are declared there, I guess than in older complilers they weren't there. Is there a portable way to get happy both old and new compilers?
[snip]
Quoted 9 lines
include/sysemu/os-win32.h +0
-1@@ -75,14 +75,6 @@/* Declaration of ffs() is missing in MinGW's strings.h. */ int ffs (int i); -/* Missing POSIX functions. Don't use MinGW-w64 macros. */
include/sysemu/os-win32.h line 80
Quoted 10 lines
include/sysemu/os-win32.h +0
-7-#undef gmtime_r -struct tm *gmtime_r (const time_t *timep,struct tm *result); -#undef localtime_r -struct 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 ) {}
This is presumably due to the historic bad namespace pollution in Mingw64 winpthreads. They stuffed a bunch of macros in pthread.h for things like gmtime_r, localtime_r and friends. This was certainly true in the mingw64 version that shipped with Fedora 20, but in Fedora 21 that bad code in pthread.h has gone away. Presumably this change is what has caused you trouble building.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|