aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.target1
-rw-r--r--cutils.c35
-rw-r--r--exec.c1
-rw-r--r--kqemu.c1
-rw-r--r--linux-user/main.c1
-rw-r--r--osdep.c35
-rw-r--r--osdep.h7
-rw-r--r--qemu-common.h8
-rw-r--r--qemu-img.c35
-rw-r--r--target-alpha/translate.c1
-rw-r--r--target-arm/helper.c1
-rw-r--r--target-cris/translate.c1
-rw-r--r--target-i386/helper2.c1
-rw-r--r--target-m68k/helper.c1
-rw-r--r--target-mips/translate.c1
-rw-r--r--target-ppc/helper.c1
-rw-r--r--target-ppc/translate.c1
-rw-r--r--target-sh4/translate.c1
-rw-r--r--target-sparc/helper.c1
-rw-r--r--tcg/tcg.c32
20 files changed, 58 insertions, 108 deletions
diff --git a/Makefile.target b/Makefile.target
index d92c109705..7bedbf763c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -430,6 +430,7 @@ OBJS+=gdbstub.o
endif
OBJS+= libqemu.a
+OBJS+= ../libqemu_common.a
# Note: this is a workaround. The real fix is to avoid compiling
# cpu_signal_handler() in cpu-exec.c.
diff --git a/cutils.c b/cutils.c
index 9ef2fa627c..738d5265d7 100644
--- a/cutils.c
+++ b/cutils.c
@@ -95,3 +95,38 @@ time_t mktimegm(struct tm *tm)
t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
return t;
}
+
+void *get_mmap_addr(unsigned long size)
+{
+ return NULL;
+}
+
+void qemu_free(void *ptr)
+{
+ free(ptr);
+}
+
+void *qemu_malloc(size_t size)
+{
+ return malloc(size);
+}
+
+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;
+}
diff --git a/exec.c b/exec.c
index 8015202a68..877de89f1d 100644
--- a/exec.c
+++ b/exec.c
@@ -35,6 +35,7 @@
#include "cpu.h"
#include "exec-all.h"
+#include "qemu-common.h"
#if defined(CONFIG_USER_ONLY)
#include <qemu.h>
#endif
diff --git a/kqemu.c b/kqemu.c
index 148a52f1cc..88592eee7a 100644
--- a/kqemu.c
+++ b/kqemu.c
@@ -40,6 +40,7 @@
#include "cpu.h"
#include "exec-all.h"
+#include "qemu-common.h"
#ifdef USE_KQEMU
diff --git a/linux-user/main.c b/linux-user/main.c
index 8cfd2f77ac..2125aa5e63 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include "qemu.h"
+#include "qemu-common.h"
#define DEBUG_LOGFILE "/tmp/qemu.log"
diff --git a/osdep.c b/osdep.c
index f824bc1ea2..64bc16e05c 100644
--- a/osdep.c
+++ b/osdep.c
@@ -45,21 +45,6 @@
#include <malloc.h>
#endif
-void *get_mmap_addr(unsigned long size)
-{
- return NULL;
-}
-
-void qemu_free(void *ptr)
-{
- free(ptr);
-}
-
-void *qemu_malloc(size_t size)
-{
- return malloc(size);
-}
-
#if defined(_WIN32)
void *qemu_memalign(size_t alignment, size_t size)
{
@@ -217,26 +202,6 @@ void qemu_vfree(void *ptr)
#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;
-}
-
int qemu_create_pidfile(const char *filename)
{
char buffer[128];
diff --git a/osdep.h b/osdep.h
index eb3198c78f..62de457048 100644
--- a/osdep.h
+++ b/osdep.h
@@ -47,17 +47,10 @@
#define qemu_printf printf
-void *qemu_malloc(size_t size);
-void *qemu_mallocz(size_t size);
-void qemu_free(void *ptr);
-char *qemu_strdup(const char *str);
-
void *qemu_memalign(size_t alignment, size_t size);
void *qemu_vmalloc(size_t size);
void qemu_vfree(void *ptr);
-void *get_mmap_addr(unsigned long size);
-
int qemu_create_pidfile(const char *filename);
#ifdef _WIN32
diff --git a/qemu-common.h b/qemu-common.h
index 746dcc5d63..a246144672 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -86,6 +86,14 @@ int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm);
+void *qemu_malloc(size_t size);
+void *qemu_mallocz(size_t size);
+void qemu_free(void *ptr);
+char *qemu_strdup(const char *str);
+
+void *get_mmap_addr(unsigned long size);
+
+
/* Error handling. */
void hw_error(const char *fmt, ...)
diff --git a/qemu-img.c b/qemu-img.c
index 4fc365db4c..309a746da7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -30,41 +30,6 @@
#include <windows.h>
#endif
-void *get_mmap_addr(unsigned long size)
-{
- return NULL;
-}
-
-void qemu_free(void *ptr)
-{
- free(ptr);
-}
-
-void *qemu_malloc(size_t size)
-{
- return malloc(size);
-}
-
-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;
-}
-
static void __attribute__((noreturn)) error(const char *fmt, ...)
{
va_list ap;
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 1c8587db99..e0b7686700 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -26,6 +26,7 @@
#include "exec-all.h"
#include "disas.h"
#include "tcg-op.h"
+#include "qemu-common.h"
#define DO_SINGLE_STEP
#define GENERATE_NOP
diff --git a/target-arm/helper.c b/target-arm/helper.c
index d6a5f33ff5..4ff30c1a8e 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -6,6 +6,7 @@
#include "exec-all.h"
#include "gdbstub.h"
#include "helpers.h"
+#include "qemu-common.h"
static uint32_t cortexa8_cp15_c0_c1[8] =
{ 0x1031, 0x11, 0x400, 0, 0x31100003, 0x20000000, 0x01202000, 0x11 };
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 5769175ab0..ff5711c834 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -32,6 +32,7 @@
#include "tcg-op.h"
#include "helper.h"
#include "crisv32-decode.h"
+#include "qemu-common.h"
#define CRIS_STATS 0
#if CRIS_STATS
diff --git a/target-i386/helper2.c b/target-i386/helper2.c
index effd728e11..3b9cd947df 100644
--- a/target-i386/helper2.c
+++ b/target-i386/helper2.c
@@ -28,6 +28,7 @@
#include "cpu.h"
#include "exec-all.h"
#include "svm.h"
+#include "qemu-common.h"
//#define DEBUG_MMU
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index c63964891d..848c589105 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -25,6 +25,7 @@
#include "config.h"
#include "cpu.h"
#include "exec-all.h"
+#include "qemu-common.h"
enum m68k_cpuid {
M68K_CPUID_M5206,
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 65f0ba9041..eeb08f6085 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -30,6 +30,7 @@
#include "exec-all.h"
#include "disas.h"
#include "tcg-op.h"
+#include "qemu-common.h"
//#define MIPS_DEBUG_DISAS
//#define MIPS_DEBUG_SIGN_EXTENSIONS
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index a808454a20..2a52dc69a2 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -28,6 +28,7 @@
#include "cpu.h"
#include "exec-all.h"
#include "helper_regs.h"
+#include "qemu-common.h"
//#define DEBUG_MMU
//#define DEBUG_BATS
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index c9530eb17e..7c47dee6e7 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -27,6 +27,7 @@
#include "exec-all.h"
#include "disas.h"
#include "tcg-op.h"
+#include "qemu-common.h"
/* Include definitions for instructions classes and implementations flags */
//#define DO_SINGLE_STEP
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index b7c5f8d0a4..f9cabcf83f 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -32,6 +32,7 @@
#include "exec-all.h"
#include "disas.h"
#include "tcg-op.h"
+#include "qemu-common.h"
typedef struct DisasContext {
struct TranslationBlock *tb;
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index a788ef633e..dd7a51f9c2 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -27,6 +27,7 @@
#include "cpu.h"
#include "exec-all.h"
+#include "qemu-common.h"
//#define DEBUG_MMU
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 379b8f230c..26e0ff80a7 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -39,7 +39,7 @@
#endif
#include "config.h"
-#include "osdep.h"
+#include "qemu-common.h"
/* Note: the long term plan is to reduce the dependancies on the QEMU
CPU definitions. Currently they are used for qemu_ld/st
@@ -147,36 +147,6 @@ int gen_new_label(void)
#include "tcg-target.c"
-/* XXX: factorize */
-static void pstrcpy(char *buf, int buf_size, const char *str)
-{
- int c;
- char *q = buf;
-
- if (buf_size <= 0)
- return;
-
- for(;;) {
- c = *str++;
- if (c == 0 || q >= buf + buf_size - 1)
- break;
- *q++ = c;
- }
- *q = '\0';
-}
-
-#if TCG_TARGET_REG_BITS == 32
-/* strcat and truncate. */
-static char *pstrcat(char *buf, int buf_size, const char *s)
-{
- int len;
- len = strlen(buf);
- if (len < buf_size)
- pstrcpy(buf + len, buf_size - len, s);
- return buf;
-}
-#endif
-
/* pool based memory allocation */
void *tcg_malloc_internal(TCGContext *s, int size)
{