Commit ca10f86763f58b7b3667e2ca7d26db3dc810eb20
1 parent
ea86e4e6
Remove osdep.c/qemu-img code duplication
(Kevin Wolf) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4191 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
20 changed files
with
58 additions
and
108 deletions
Makefile.target
cutils.c
... | ... | @@ -95,3 +95,38 @@ time_t mktimegm(struct tm *tm) |
95 | 95 | t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec; |
96 | 96 | return t; |
97 | 97 | } |
98 | + | |
99 | +void *get_mmap_addr(unsigned long size) | |
100 | +{ | |
101 | + return NULL; | |
102 | +} | |
103 | + | |
104 | +void qemu_free(void *ptr) | |
105 | +{ | |
106 | + free(ptr); | |
107 | +} | |
108 | + | |
109 | +void *qemu_malloc(size_t size) | |
110 | +{ | |
111 | + return malloc(size); | |
112 | +} | |
113 | + | |
114 | +void *qemu_mallocz(size_t size) | |
115 | +{ | |
116 | + void *ptr; | |
117 | + ptr = qemu_malloc(size); | |
118 | + if (!ptr) | |
119 | + return NULL; | |
120 | + memset(ptr, 0, size); | |
121 | + return ptr; | |
122 | +} | |
123 | + | |
124 | +char *qemu_strdup(const char *str) | |
125 | +{ | |
126 | + char *ptr; | |
127 | + ptr = qemu_malloc(strlen(str) + 1); | |
128 | + if (!ptr) | |
129 | + return NULL; | |
130 | + strcpy(ptr, str); | |
131 | + return ptr; | |
132 | +} | ... | ... |
exec.c
kqemu.c
linux-user/main.c
osdep.c
... | ... | @@ -45,21 +45,6 @@ |
45 | 45 | #include <malloc.h> |
46 | 46 | #endif |
47 | 47 | |
48 | -void *get_mmap_addr(unsigned long size) | |
49 | -{ | |
50 | - return NULL; | |
51 | -} | |
52 | - | |
53 | -void qemu_free(void *ptr) | |
54 | -{ | |
55 | - free(ptr); | |
56 | -} | |
57 | - | |
58 | -void *qemu_malloc(size_t size) | |
59 | -{ | |
60 | - return malloc(size); | |
61 | -} | |
62 | - | |
63 | 48 | #if defined(_WIN32) |
64 | 49 | void *qemu_memalign(size_t alignment, size_t size) |
65 | 50 | { |
... | ... | @@ -217,26 +202,6 @@ void qemu_vfree(void *ptr) |
217 | 202 | |
218 | 203 | #endif |
219 | 204 | |
220 | -void *qemu_mallocz(size_t size) | |
221 | -{ | |
222 | - void *ptr; | |
223 | - ptr = qemu_malloc(size); | |
224 | - if (!ptr) | |
225 | - return NULL; | |
226 | - memset(ptr, 0, size); | |
227 | - return ptr; | |
228 | -} | |
229 | - | |
230 | -char *qemu_strdup(const char *str) | |
231 | -{ | |
232 | - char *ptr; | |
233 | - ptr = qemu_malloc(strlen(str) + 1); | |
234 | - if (!ptr) | |
235 | - return NULL; | |
236 | - strcpy(ptr, str); | |
237 | - return ptr; | |
238 | -} | |
239 | - | |
240 | 205 | int qemu_create_pidfile(const char *filename) |
241 | 206 | { |
242 | 207 | char buffer[128]; | ... | ... |
osdep.h
... | ... | @@ -47,17 +47,10 @@ |
47 | 47 | |
48 | 48 | #define qemu_printf printf |
49 | 49 | |
50 | -void *qemu_malloc(size_t size); | |
51 | -void *qemu_mallocz(size_t size); | |
52 | -void qemu_free(void *ptr); | |
53 | -char *qemu_strdup(const char *str); | |
54 | - | |
55 | 50 | void *qemu_memalign(size_t alignment, size_t size); |
56 | 51 | void *qemu_vmalloc(size_t size); |
57 | 52 | void qemu_vfree(void *ptr); |
58 | 53 | |
59 | -void *get_mmap_addr(unsigned long size); | |
60 | - | |
61 | 54 | int qemu_create_pidfile(const char *filename); |
62 | 55 | |
63 | 56 | #ifdef _WIN32 | ... | ... |
qemu-common.h
... | ... | @@ -86,6 +86,14 @@ int strstart(const char *str, const char *val, const char **ptr); |
86 | 86 | int stristart(const char *str, const char *val, const char **ptr); |
87 | 87 | time_t mktimegm(struct tm *tm); |
88 | 88 | |
89 | +void *qemu_malloc(size_t size); | |
90 | +void *qemu_mallocz(size_t size); | |
91 | +void qemu_free(void *ptr); | |
92 | +char *qemu_strdup(const char *str); | |
93 | + | |
94 | +void *get_mmap_addr(unsigned long size); | |
95 | + | |
96 | + | |
89 | 97 | /* Error handling. */ |
90 | 98 | |
91 | 99 | void hw_error(const char *fmt, ...) | ... | ... |
qemu-img.c
... | ... | @@ -30,41 +30,6 @@ |
30 | 30 | #include <windows.h> |
31 | 31 | #endif |
32 | 32 | |
33 | -void *get_mmap_addr(unsigned long size) | |
34 | -{ | |
35 | - return NULL; | |
36 | -} | |
37 | - | |
38 | -void qemu_free(void *ptr) | |
39 | -{ | |
40 | - free(ptr); | |
41 | -} | |
42 | - | |
43 | -void *qemu_malloc(size_t size) | |
44 | -{ | |
45 | - return malloc(size); | |
46 | -} | |
47 | - | |
48 | -void *qemu_mallocz(size_t size) | |
49 | -{ | |
50 | - void *ptr; | |
51 | - ptr = qemu_malloc(size); | |
52 | - if (!ptr) | |
53 | - return NULL; | |
54 | - memset(ptr, 0, size); | |
55 | - return ptr; | |
56 | -} | |
57 | - | |
58 | -char *qemu_strdup(const char *str) | |
59 | -{ | |
60 | - char *ptr; | |
61 | - ptr = qemu_malloc(strlen(str) + 1); | |
62 | - if (!ptr) | |
63 | - return NULL; | |
64 | - strcpy(ptr, str); | |
65 | - return ptr; | |
66 | -} | |
67 | - | |
68 | 33 | static void __attribute__((noreturn)) error(const char *fmt, ...) |
69 | 34 | { |
70 | 35 | va_list ap; | ... | ... |
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
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | #endif |
40 | 40 | |
41 | 41 | #include "config.h" |
42 | -#include "osdep.h" | |
42 | +#include "qemu-common.h" | |
43 | 43 | |
44 | 44 | /* Note: the long term plan is to reduce the dependancies on the QEMU |
45 | 45 | CPU definitions. Currently they are used for qemu_ld/st |
... | ... | @@ -147,36 +147,6 @@ int gen_new_label(void) |
147 | 147 | |
148 | 148 | #include "tcg-target.c" |
149 | 149 | |
150 | -/* XXX: factorize */ | |
151 | -static void pstrcpy(char *buf, int buf_size, const char *str) | |
152 | -{ | |
153 | - int c; | |
154 | - char *q = buf; | |
155 | - | |
156 | - if (buf_size <= 0) | |
157 | - return; | |
158 | - | |
159 | - for(;;) { | |
160 | - c = *str++; | |
161 | - if (c == 0 || q >= buf + buf_size - 1) | |
162 | - break; | |
163 | - *q++ = c; | |
164 | - } | |
165 | - *q = '\0'; | |
166 | -} | |
167 | - | |
168 | -#if TCG_TARGET_REG_BITS == 32 | |
169 | -/* strcat and truncate. */ | |
170 | -static char *pstrcat(char *buf, int buf_size, const char *s) | |
171 | -{ | |
172 | - int len; | |
173 | - len = strlen(buf); | |
174 | - if (len < buf_size) | |
175 | - pstrcpy(buf + len, buf_size - len, s); | |
176 | - return buf; | |
177 | -} | |
178 | -#endif | |
179 | - | |
180 | 150 | /* pool based memory allocation */ |
181 | 151 | void *tcg_malloc_internal(TCGContext *s, int size) |
182 | 152 | { | ... | ... |