1
2
3
4
5
6
7
8
9
10#ifndef QEMU_COMMON_H
11#define QEMU_COMMON_H
12
13#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
14
15
16#define QEMU_COPYRIGHT "Copyright (c) 2003-2021 " \
17 "Fabrice Bellard and the QEMU Project developers"
18
19
20#define QEMU_HELP_BOTTOM \
21 "See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \
22 "More information on the QEMU project at <https://qemu.org>."
23
24
25#if defined(CONFIG_COCOA)
26int qemu_main(int argc, char **argv, char **envp);
27#endif
28
29void qemu_get_timedate(struct tm *tm, int offset);
30int qemu_timedate_diff(struct tm *tm);
31
32void *qemu_oom_check(void *ptr);
33
34ssize_t qemu_write_full(int fd, const void *buf, size_t count)
35 QEMU_WARN_UNUSED_RESULT;
36
37#ifndef _WIN32
38int qemu_pipe(int pipefd[2]);
39
40int qemu_openpty_raw(int *aslave, char *pty_name);
41#endif
42
43#ifdef _WIN32
44
45#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
46 getsockopt(sockfd, level, optname, (void *)optval, optlen)
47#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
48 setsockopt(sockfd, level, optname, (const void *)optval, optlen)
49#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
50#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
51 sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
52#else
53#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
54 getsockopt(sockfd, level, optname, optval, optlen)
55#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
56 setsockopt(sockfd, level, optname, optval, optlen)
57#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
58#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
59 sendto(sockfd, buf, len, flags, destaddr, addrlen)
60#endif
61
62void cpu_exec_init_all(void);
63void cpu_exec_step_atomic(CPUState *cpu);
64
65
66
67
68
69
70
71
72
73
74
75bool set_preferred_target_page_bits(int bits);
76
77
78
79
80
81void finalize_target_page_bits(void);
82
83
84
85
86
87
88
89
90ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
91 size_t offset, size_t bytes, bool do_send);
92#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
93 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
94#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
95 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
96
97
98
99
100ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
101#define qemu_co_recv(sockfd, buf, bytes) \
102 qemu_co_send_recv(sockfd, buf, bytes, false)
103#define qemu_co_send(sockfd, buf, bytes) \
104 qemu_co_send_recv(sockfd, buf, bytes, true)
105
106void qemu_progress_init(int enabled, float min_skip);
107void qemu_progress_end(void);
108void qemu_progress_print(float delta, int max);
109const char *qemu_get_vm_name(void);
110
111
112void os_setup_early_signal_handling(void);
113int os_parse_cmd_args(int index, const char *optarg);
114
115
116
117
118#define QEMU_HEXDUMP_LINE_BYTES 16
119#define QEMU_HEXDUMP_LINE_LEN 75
120void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr,
121 unsigned int len, bool ascii);
122
123
124
125
126
127void qemu_hexdump(FILE *fp, const char *prefix,
128 const void *bufptr, size_t size);
129
130
131
132
133int parse_debug_env(const char *name, int max, int initial);
134
135const char *qemu_ether_ntoa(const MACAddr *mac);
136void page_size_init(void);
137
138
139
140bool dump_in_progress(void);
141
142#endif
143