qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [4191] Remove osdep.c/qemu-img code duplication


From: Aurelien Jarno
Subject: [Qemu-devel] [4191] Remove osdep.c/qemu-img code duplication
Date: Fri, 11 Apr 2008 21:35:42 +0000

Revision: 4191
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4191
Author:   aurel32
Date:     2008-04-11 21:35:42 +0000 (Fri, 11 Apr 2008)

Log Message:
-----------
Remove osdep.c/qemu-img code duplication

(Kevin Wolf)

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

Modified: trunk/Makefile.target
===================================================================
--- trunk/Makefile.target       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/Makefile.target       2008-04-11 21:35:42 UTC (rev 4191)
@@ -430,6 +430,7 @@
 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.

Modified: trunk/cutils.c
===================================================================
--- trunk/cutils.c      2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/cutils.c      2008-04-11 21:35:42 UTC (rev 4191)
@@ -95,3 +95,38 @@
     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;
+}

Modified: trunk/exec.c
===================================================================
--- trunk/exec.c        2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/exec.c        2008-04-11 21:35:42 UTC (rev 4191)
@@ -35,6 +35,7 @@
 
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 #if defined(CONFIG_USER_ONLY)
 #include <qemu.h>
 #endif

Modified: trunk/kqemu.c
===================================================================
--- trunk/kqemu.c       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/kqemu.c       2008-04-11 21:35:42 UTC (rev 4191)
@@ -40,6 +40,7 @@
 
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 #ifdef USE_KQEMU
 

Modified: trunk/linux-user/main.c
===================================================================
--- trunk/linux-user/main.c     2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/linux-user/main.c     2008-04-11 21:35:42 UTC (rev 4191)
@@ -25,6 +25,7 @@
 #include <unistd.h>
 
 #include "qemu.h"
+#include "qemu-common.h"
 
 #define DEBUG_LOGFILE "/tmp/qemu.log"
 

Modified: trunk/osdep.c
===================================================================
--- trunk/osdep.c       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/osdep.c       2008-04-11 21:35:42 UTC (rev 4191)
@@ -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 @@
 
 #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];

Modified: trunk/osdep.h
===================================================================
--- trunk/osdep.h       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/osdep.h       2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/qemu-common.h
===================================================================
--- trunk/qemu-common.h 2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/qemu-common.h 2008-04-11 21:35:42 UTC (rev 4191)
@@ -86,6 +86,14 @@
 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, ...)

Modified: trunk/qemu-img.c
===================================================================
--- trunk/qemu-img.c    2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/qemu-img.c    2008-04-11 21:35:42 UTC (rev 4191)
@@ -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;

Modified: trunk/target-alpha/translate.c
===================================================================
--- trunk/target-alpha/translate.c      2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-alpha/translate.c      2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/target-arm/helper.c
===================================================================
--- trunk/target-arm/helper.c   2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-arm/helper.c   2008-04-11 21:35:42 UTC (rev 4191)
@@ -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 };

Modified: trunk/target-cris/translate.c
===================================================================
--- trunk/target-cris/translate.c       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-cris/translate.c       2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/target-i386/helper2.c
===================================================================
--- trunk/target-i386/helper2.c 2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-i386/helper2.c 2008-04-11 21:35:42 UTC (rev 4191)
@@ -28,6 +28,7 @@
 #include "cpu.h"
 #include "exec-all.h"
 #include "svm.h"
+#include "qemu-common.h"
 
 //#define DEBUG_MMU
 

Modified: trunk/target-m68k/helper.c
===================================================================
--- trunk/target-m68k/helper.c  2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-m68k/helper.c  2008-04-11 21:35:42 UTC (rev 4191)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 enum m68k_cpuid {
     M68K_CPUID_M5206,

Modified: trunk/target-mips/translate.c
===================================================================
--- trunk/target-mips/translate.c       2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-mips/translate.c       2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/target-ppc/helper.c
===================================================================
--- trunk/target-ppc/helper.c   2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-ppc/helper.c   2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/target-ppc/translate.c
===================================================================
--- trunk/target-ppc/translate.c        2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-ppc/translate.c        2008-04-11 21:35:42 UTC (rev 4191)
@@ -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

Modified: trunk/target-sh4/translate.c
===================================================================
--- trunk/target-sh4/translate.c        2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-sh4/translate.c        2008-04-11 21:35:42 UTC (rev 4191)
@@ -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;

Modified: trunk/target-sparc/helper.c
===================================================================
--- trunk/target-sparc/helper.c 2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/target-sparc/helper.c 2008-04-11 21:35:42 UTC (rev 4191)
@@ -27,6 +27,7 @@
 
 #include "cpu.h"
 #include "exec-all.h"
+#include "qemu-common.h"
 
 //#define DEBUG_MMU
 

Modified: trunk/tcg/tcg.c
===================================================================
--- trunk/tcg/tcg.c     2008-04-11 04:55:31 UTC (rev 4190)
+++ trunk/tcg/tcg.c     2008-04-11 21:35:42 UTC (rev 4191)
@@ -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 @@
 
 #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)
 {






reply via email to

[Prev in Thread] Current Thread [Next in Thread]