PIC spurious irq support (aka Solaris install bug)
[qemu] / osdep.c
diff --git a/osdep.c b/osdep.c
index d4d3364..83f5a77 100644 (file)
--- a/osdep.c
+++ b/osdep.c
@@ -25,8 +25,6 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
-#include <sys/mman.h>
-#include <sys/ipc.h>
 #include <errno.h>
 #include <unistd.h>
 
@@ -34,6 +32,9 @@
 
 #if defined(__i386__) && !defined(CONFIG_SOFTMMU) && !defined(CONFIG_USER_ONLY)
 
+#include <sys/mman.h>
+#include <sys/ipc.h>
+
 /* When not using soft mmu, libc independant functions are needed for
    the CPU core because it needs to use alternates stacks and
    libc/thread incompatibles settings */
@@ -234,6 +235,8 @@ void qemu_free(void *ptr)
 {
     MemoryBlock *mb;
 
+    if (!ptr)
+        return;
     mb = (MemoryBlock *)((uint8_t *)ptr - BLOCK_HEADER_SIZE);
     mb->next = first_free_block;
     first_free_block = mb;
@@ -281,6 +284,16 @@ void *qemu_malloc(size_t size)
 
 #endif
 
+void *qemu_mallocz(size_t size)
+{
+    void *ptr;
+    ptr = qemu_malloc(size);
+    if (!ptr)
+        return NULL;
+    memset(ptr, 0, size);
+    return ptr;
+}
+
 /****************************************************************/
 /* printf support */