PC parallel port support (Mark Jonckheere)
[qemu] / osdep.c
diff --git a/osdep.c b/osdep.c
index d4d3364..087a5c2 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 */
@@ -143,6 +144,22 @@ void *shmat(int shmid, const void *shmaddr, int shmflg)
 }
 
 /****************************************************************/
+/* sigaction bypassing the threads */
+
+static int kernel_sigaction(int signum, const struct qemu_sigaction *act, 
+                            struct qemu_sigaction *oldact, 
+                            int sigsetsize)
+{
+    QEMU_SYSCALL4(rt_sigaction, signum, act, oldact, sigsetsize);
+}
+
+int qemu_sigaction(int signum, const struct qemu_sigaction *act, 
+                   struct qemu_sigaction *oldact)
+{
+    return kernel_sigaction(signum, act, oldact, 8);
+}
+
+/****************************************************************/
 /* memory allocation */
 
 //#define DEBUG_MALLOC
@@ -234,6 +251,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 +300,26 @@ 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;
+}
+
+char *qemu_strdup(const char *str)
+{
+    char *ptr;
+    ptr = qemu_malloc(strlen(str) + 1);
+    if (!ptr)
+        return NULL;
+    strcpy(ptr, str);
+    return ptr;
+}
+
 /****************************************************************/
 /* printf support */