Revision ca10f867

b/Makefile.target
430 430
endif
431 431

  
432 432
OBJS+= libqemu.a
433
OBJS+= ../libqemu_common.a
433 434

  
434 435
# Note: this is a workaround. The real fix is to avoid compiling
435 436
# cpu_signal_handler() in cpu-exec.c.
b/cutils.c
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
}
b/exec.c
35 35

  
36 36
#include "cpu.h"
37 37
#include "exec-all.h"
38
#include "qemu-common.h"
38 39
#if defined(CONFIG_USER_ONLY)
39 40
#include <qemu.h>
40 41
#endif
b/kqemu.c
40 40

  
41 41
#include "cpu.h"
42 42
#include "exec-all.h"
43
#include "qemu-common.h"
43 44

  
44 45
#ifdef USE_KQEMU
45 46

  
b/linux-user/main.c
25 25
#include <unistd.h>
26 26

  
27 27
#include "qemu.h"
28
#include "qemu-common.h"
28 29

  
29 30
#define DEBUG_LOGFILE "/tmp/qemu.log"
30 31

  
b/osdep.c
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 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];
b/osdep.h
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
b/qemu-common.h
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, ...)
b/qemu-img.c
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;
b/target-alpha/translate.c
26 26
#include "exec-all.h"
27 27
#include "disas.h"
28 28
#include "tcg-op.h"
29
#include "qemu-common.h"
29 30

  
30 31
#define DO_SINGLE_STEP
31 32
#define GENERATE_NOP
b/target-arm/helper.c
6 6
#include "exec-all.h"
7 7
#include "gdbstub.h"
8 8
#include "helpers.h"
9
#include "qemu-common.h"
9 10

  
10 11
static uint32_t cortexa8_cp15_c0_c1[8] =
11 12
{ 0x1031, 0x11, 0x400, 0, 0x31100003, 0x20000000, 0x01202000, 0x11 };
b/target-cris/translate.c
32 32
#include "tcg-op.h"
33 33
#include "helper.h"
34 34
#include "crisv32-decode.h"
35
#include "qemu-common.h"
35 36

  
36 37
#define CRIS_STATS 0
37 38
#if CRIS_STATS
b/target-i386/helper2.c
28 28
#include "cpu.h"
29 29
#include "exec-all.h"
30 30
#include "svm.h"
31
#include "qemu-common.h"
31 32

  
32 33
//#define DEBUG_MMU
33 34

  
b/target-m68k/helper.c
25 25
#include "config.h"
26 26
#include "cpu.h"
27 27
#include "exec-all.h"
28
#include "qemu-common.h"
28 29

  
29 30
enum m68k_cpuid {
30 31
    M68K_CPUID_M5206,
b/target-mips/translate.c
30 30
#include "exec-all.h"
31 31
#include "disas.h"
32 32
#include "tcg-op.h"
33
#include "qemu-common.h"
33 34

  
34 35
//#define MIPS_DEBUG_DISAS
35 36
//#define MIPS_DEBUG_SIGN_EXTENSIONS
b/target-ppc/helper.c
28 28
#include "cpu.h"
29 29
#include "exec-all.h"
30 30
#include "helper_regs.h"
31
#include "qemu-common.h"
31 32

  
32 33
//#define DEBUG_MMU
33 34
//#define DEBUG_BATS
b/target-ppc/translate.c
27 27
#include "exec-all.h"
28 28
#include "disas.h"
29 29
#include "tcg-op.h"
30
#include "qemu-common.h"
30 31

  
31 32
/* Include definitions for instructions classes and implementations flags */
32 33
//#define DO_SINGLE_STEP
b/target-sh4/translate.c
32 32
#include "exec-all.h"
33 33
#include "disas.h"
34 34
#include "tcg-op.h"
35
#include "qemu-common.h"
35 36

  
36 37
typedef struct DisasContext {
37 38
    struct TranslationBlock *tb;
b/target-sparc/helper.c
27 27

  
28 28
#include "cpu.h"
29 29
#include "exec-all.h"
30
#include "qemu-common.h"
30 31

  
31 32
//#define DEBUG_MMU
32 33

  
b/tcg/tcg.c
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 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
{

Also available in: Unified diff