Skip to contentSkip to conversation

exec: Fix broken build for MinGW (regression)

PATCH Applied Stefan Weil 3 participants 3 messages Sep 18, 2013 – Sep 20, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exec: Fix broken build for MinGW (regression)

Commit 3435f39513a104294b5e3bbf3612047028d25cfc reduced the ifdeffery with this result for MinGW:

exec.c: In function ‘qemu_ram_free’:
exec.c:1239:17: warning:
implicit declaration of function ‘munmap’ [-Wimplicit-function-declaration]
exec.c:1239:17: warning:
nested extern declaration of ‘munmap’ [-Wnested-externs]
exec.c:1239: undefined reference to `munmap'

Add some ifdeffery again to fix this.

---
 exec.c |    2 ++
 1 file changed, 2 insertions(+)
exec.c +2 -0
index 2646912..efeca14 100644
@@ -1229,9 +1229,11 @@ void qemu_ram_free(ram_addr_t addr)
                 ;
             } else if (xen_enabled()) {
                 xen_invalidate_map_cache_entry(block->host);
+#ifndef _WIN32
             } else if (block->fd >= 0) {
                 munmap(block->host, block->length);
                 close(block->fd);
+#endif
             } else {
                 qemu_anon_ram_free(block->host, block->length);
             }
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Stefan Weil

Commit 3435f39513a104294b5e3bbf3612047028d25cfc reduced the ifdeffery with this result for MinGW:

exec.c: In function ‘qemu_ram_free’:
exec.c:1239:17: warning:
implicit declaration of function ‘munmap’ [-Wimplicit-function-declaration]
exec.c:1239:17: warning:
nested extern declaration of ‘munmap’ [-Wnested-externs]
exec.c:1239: undefined reference to `munmap'

Add some ifdeffery again to fix this.

---
 exec.c |    2 ++
 1 file changed, 2 insertions(+)
exec.c +0 -0
index 2646912..efeca14 100644
@@ -1229,9 +1229,11 @@ void qemu_ram_free(ram_addr_t addr)
                 ;

exec.c void qemu_ram_free(ram_addr_t addr) · line 1239

Quoted 10 lines
exec.c +2 -0
             } else if (xen_enabled()) {
                 xen_invalidate_map_cache_entry(block->host);
+#ifndef _WIN32
             } else if (block->fd >= 0) {
                 munmap(block->host, block->length);
                 close(block->fd);
+#endif
             } else {
                 qemu_anon_ram_free(block->host, block->length);
             }

The initial mmap() is under #ifdef __linux__, in file_ram_alloc(). However, the code manipulating it in qemu_ram_remap() is under #ifndef _WIN32, and your patch matches that. Makes sense.

Thanks for cleaning up after me ;)

#2 lore raw
In reply to Stefan Weil
Quoted 11 lines · Stefan Weil

Commit 3435f39513a104294b5e3bbf3612047028d25cfc reduced the ifdeffery with this result for MinGW:

exec.c: In function ‘qemu_ram_free’:
exec.c:1239:17: warning:
implicit declaration of function ‘munmap’ [-Wimplicit-function-declaration]
exec.c:1239:17: warning:
nested extern declaration of ‘munmap’ [-Wnested-externs]
exec.c:1239: undefined reference to `munmap'

Add some ifdeffery again to fix this.

Thanks, applied to the trivial patches queue.

/mjt