1
2
3
4
5
6
7
8
9
10
11
12#ifndef QEMU_COMMON_H
13#define QEMU_COMMON_H
14
15#include "qemu/fprintf-fn.h"
16
17#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)
18#define WORDS_ALIGNED
19#endif
20
21#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
22
23#include "qemu/option.h"
24#include "qemu/host-utils.h"
25
26void cpu_ticks_init(void);
27
28
29void configure_icount(QemuOpts *opts, Error **errp);
30extern int use_icount;
31extern int icount_align_option;
32
33extern int64_t max_delay;
34extern int64_t max_advance;
35void dump_drift_info(FILE *f, fprintf_function cpu_fprintf);
36
37#include "qemu/bswap.h"
38
39
40#ifdef NEED_CPU_H
41#include "cpu.h"
42#endif
43
44
45#if defined(CONFIG_COCOA)
46int qemu_main(int argc, char **argv, char **envp);
47#endif
48
49void qemu_get_timedate(struct tm *tm, int offset);
50int qemu_timedate_diff(struct tm *tm);
51
52#define qemu_isalnum(c) isalnum((unsigned char)(c))
53#define qemu_isalpha(c) isalpha((unsigned char)(c))
54#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
55#define qemu_isdigit(c) isdigit((unsigned char)(c))
56#define qemu_isgraph(c) isgraph((unsigned char)(c))
57#define qemu_islower(c) islower((unsigned char)(c))
58#define qemu_isprint(c) isprint((unsigned char)(c))
59#define qemu_ispunct(c) ispunct((unsigned char)(c))
60#define qemu_isspace(c) isspace((unsigned char)(c))
61#define qemu_isupper(c) isupper((unsigned char)(c))
62#define qemu_isxdigit(c) isxdigit((unsigned char)(c))
63#define qemu_tolower(c) tolower((unsigned char)(c))
64#define qemu_toupper(c) toupper((unsigned char)(c))
65#define qemu_isascii(c) isascii((unsigned char)(c))
66#define qemu_toascii(c) toascii((unsigned char)(c))
67
68void *qemu_oom_check(void *ptr);
69
70ssize_t qemu_write_full(int fd, const void *buf, size_t count)
71 QEMU_WARN_UNUSED_RESULT;
72
73#ifndef _WIN32
74int qemu_pipe(int pipefd[2]);
75
76int qemu_openpty_raw(int *aslave, char *pty_name);
77#endif
78
79#ifdef _WIN32
80
81#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
82 getsockopt(sockfd, level, optname, (void *)optval, optlen)
83#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
84 setsockopt(sockfd, level, optname, (const void *)optval, optlen)
85#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
86#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
87 sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
88#else
89#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
90 getsockopt(sockfd, level, optname, optval, optlen)
91#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
92 setsockopt(sockfd, level, optname, optval, optlen)
93#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
94#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
95 sendto(sockfd, buf, len, flags, destaddr, addrlen)
96#endif
97
98void tcg_exec_init(unsigned long tb_size);
99bool tcg_enabled(void);
100
101void cpu_exec_init_all(void);
102
103
104void qemu_cpu_kick_self(void);
105
106
107struct qemu_work_item {
108 struct qemu_work_item *next;
109 void (*func)(void *data);
110 void *data;
111 int done;
112 bool free;
113};
114
115
116
117
118
119
120
121
122
123ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
124 size_t offset, size_t bytes, bool do_send);
125#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
126 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
127#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
128 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
129
130
131
132
133ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
134#define qemu_co_recv(sockfd, buf, bytes) \
135 qemu_co_send_recv(sockfd, buf, bytes, false)
136#define qemu_co_send(sockfd, buf, bytes) \
137 qemu_co_send_recv(sockfd, buf, bytes, true)
138
139void qemu_progress_init(int enabled, float min_skip);
140void qemu_progress_end(void);
141void qemu_progress_print(float delta, int max);
142const char *qemu_get_vm_name(void);
143
144#define QEMU_FILE_TYPE_BIOS 0
145#define QEMU_FILE_TYPE_KEYMAP 1
146char *qemu_find_file(int type, const char *name);
147
148
149void os_setup_early_signal_handling(void);
150char *os_find_datadir(void);
151void os_parse_cmd_args(int index, const char *optarg);
152
153#include "qemu/module.h"
154
155
156
157
158
159void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
160
161
162
163
164int parse_debug_env(const char *name, int max, int initial);
165
166const char *qemu_ether_ntoa(const MACAddr *mac);
167void page_size_init(void);
168
169
170
171bool dump_in_progress(void);
172
173#endif
174