]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Remove osdep.c/qemu-img code duplication
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Fri, 11 Apr 2008 21:35:42 +0000 (21:35 +0000)
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Fri, 11 Apr 2008 21:35:42 +0000 (21:35 +0000)
(Kevin Wolf)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4191 c046a42c-6fe2-441c-8c8c-71466251a162

20 files changed:
Makefile.target
cutils.c
exec.c
kqemu.c
linux-user/main.c
osdep.c
osdep.h
qemu-common.h
qemu-img.c
target-alpha/translate.c
target-arm/helper.c
target-cris/translate.c
target-i386/helper2.c
target-m68k/helper.c
target-mips/translate.c
target-ppc/helper.c
target-ppc/translate.c
target-sh4/translate.c
target-sparc/helper.c
tcg/tcg.c

index d92c109705a0473aadda55d889bf2803e9f84f86..7bedbf763cf7bf9650fbcd64c036443ae3689415 100644 (file)
@@ -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.
index 9ef2fa627cfba9d78c12ed406f491b2e09ef6334..738d5265d7be722c8926114c1582a12d314808c1 100644 (file)
--- 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 8015202a68dc870164b06b746259dd5c7da25d12..877de89f1d692668169968b368310ed1e8c7d0e1 100644 (file)
--- 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 148a52f1cc69f5d8c1950ba2ff78f40b92ce91ce..88592eee7a9c78a15f93cc969428f9ada4e9c805 100644 (file)
--- a/kqemu.c
+++ b/kqemu.c
@@ -40,6 +40,7 @@
 
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 #ifdef USE_KQEMU
 
index 8cfd2f77aca19e669cb7cf44ec2777fb027b8f68..2125aa5e63f5f2b3d3be43b130e025c1448aecd3 100644 (file)
@@ -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 f824bc1ea25e24e70f774450bb06774245961093..64bc16e05ccbf64b75e69a7ccfe7721d41dd2b7b 100644 (file)
--- a/osdep.c
+++ b/osdep.c
 #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 eb3198c78fc21e9c996e22f696bbb1d897577678..62de457048dedf01c582b2ab26d5c9611c01f786 100644 (file)
--- a/osdep.h
+++ b/osdep.h
 
 #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
index 746dcc5d63204ce5ca9748e905ffcb9b52d2f5f7..a246144672054e7662116a2de421a90806389ea1 100644 (file)
@@ -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, ...)
index 4fc365db4c486b68b09f7e6abab77692aa77cdaa..309a746da7838cd84f6e1dc153efb8d2371de887 100644 (file)
 #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;
index 1c8587db99c68081ff25bb0df27d793a8488f755..e0b76867007d76bd12facca04b77aae7f2836b8f 100644 (file)
@@ -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
index d6a5f33ff530984c3cdf440ec0fd667871a83500..4ff30c1a8e6cfa8dc686088405dbcc94f236fb01 100644 (file)
@@ -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 };
index 5769175ab0cf286d046391e00d6db7df9a64309a..ff5711c8346d86e0598662d10bb0eb1878a1de58 100644 (file)
@@ -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
index effd728e1134a7f1958a1c11730fb17bf7aac357..3b9cd947df59163150261169d04dd08b14df1863 100644 (file)
@@ -28,6 +28,7 @@
 #include "cpu.h"
 #include "exec-all.h"
 #include "svm.h"
+#include "qemu-common.h"
 
 //#define DEBUG_MMU
 
index c63964891d4af5831d84fd684c7cfce1641198d2..848c5891051a9b8a52fd1d0de9b8ea7d970be1e4 100644 (file)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 enum m68k_cpuid {
     M68K_CPUID_M5206,
index 65f0ba9041deb83b2c4c79b34e16fb49c7e82816..eeb08f60859b2c720c7d430b7eb866c64e8388ee 100644 (file)
@@ -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
index a808454a201e2bd664cb8470348044a5641fe835..2a52dc69a2032f369ed373eaf93eefbbe51bb6ec 100644 (file)
@@ -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
index c9530eb17e1af620c7b2b0b4bb7faf9fa6b9370e..7c47dee6e78119c7a6a79246eafc0d863521ac6a 100644 (file)
@@ -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
index b7c5f8d0a4c0eaa0290dc7c2fe4585543bd2479b..f9cabcf83f786496c1711ee846182fc668e3c263 100644 (file)
@@ -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;
index a788ef633e8c6d458def5cd20eb8af05c5af5bab..dd7a51f9c2be2e384662156d44e472a38aa1eeda 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 //#define DEBUG_MMU
 
index 379b8f230c324df8fc678923b22af9832fb243d2..26e0ff80a715da015cffcf4c61b5d7a0d99902a4 100644 (file)
--- 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)
 {