#include <stdio.h>
#include <stdarg.h>
#include <string.h>
-#include <sys/mman.h>
-#include <sys/ipc.h>
#include <errno.h>
#include <unistd.h>
#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 */
return ptr;
}
+/****************************************************************/
+/* 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 */
{
MemoryBlock *mb;
+ if (!ptr)
+ return;
mb = (MemoryBlock *)((uint8_t *)ptr - BLOCK_HEADER_SIZE);
mb->next = first_free_block;
first_free_block = mb;
#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 */