]>
Commit | Line | Data |
---|---|---|
9fb26641 | 1 | |
04509ad9 EH |
2 | /* Common header file that is included by all of QEMU. |
3 | * | |
4 | * This file is supposed to be included only by .c files. No header file should | |
5 | * depend on qemu-common.h, as this would easily lead to circular header | |
6 | * dependencies. | |
7 | * | |
8 | * If a header file uses a definition from qemu-common.h, that definition | |
9 | * must be moved to a separate header file, and the header that uses it | |
10 | * must include that header. | |
11 | */ | |
faf07963 PB |
12 | #ifndef QEMU_COMMON_H |
13 | #define QEMU_COMMON_H | |
14 | ||
082b5557 | 15 | #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) |
24ebf5f3 | 16 | |
d915b7bb | 17 | /* Copyright string for -version arguments, About dialogs, etc */ |
1dcb3c3b | 18 | #define QEMU_COPYRIGHT "Copyright (c) 2003-2019 " \ |
d915b7bb PM |
19 | "Fabrice Bellard and the QEMU Project developers" |
20 | ||
f5048cb7 EB |
21 | /* Bug reporting information for --help arguments, About dialogs, etc */ |
22 | #define QEMU_HELP_BOTTOM \ | |
70b7fba9 SH |
23 | "See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \ |
24 | "More information on the QEMU project at <https://qemu.org>." | |
f5048cb7 | 25 | |
3bbbee18 AF |
26 | /* main function, renamed */ |
27 | #if defined(CONFIG_COCOA) | |
28 | int qemu_main(int argc, char **argv, char **envp); | |
29 | #endif | |
30 | ||
f6503059 AZ |
31 | void qemu_get_timedate(struct tm *tm, int offset); |
32 | int qemu_timedate_diff(struct tm *tm); | |
33 | ||
cd390083 BS |
34 | #define qemu_isalnum(c) isalnum((unsigned char)(c)) |
35 | #define qemu_isalpha(c) isalpha((unsigned char)(c)) | |
36 | #define qemu_iscntrl(c) iscntrl((unsigned char)(c)) | |
37 | #define qemu_isdigit(c) isdigit((unsigned char)(c)) | |
38 | #define qemu_isgraph(c) isgraph((unsigned char)(c)) | |
39 | #define qemu_islower(c) islower((unsigned char)(c)) | |
40 | #define qemu_isprint(c) isprint((unsigned char)(c)) | |
41 | #define qemu_ispunct(c) ispunct((unsigned char)(c)) | |
42 | #define qemu_isspace(c) isspace((unsigned char)(c)) | |
43 | #define qemu_isupper(c) isupper((unsigned char)(c)) | |
44 | #define qemu_isxdigit(c) isxdigit((unsigned char)(c)) | |
45 | #define qemu_tolower(c) tolower((unsigned char)(c)) | |
46 | #define qemu_toupper(c) toupper((unsigned char)(c)) | |
47 | #define qemu_isascii(c) isascii((unsigned char)(c)) | |
48 | #define qemu_toascii(c) toascii((unsigned char)(c)) | |
49 | ||
b152aa84 | 50 | void *qemu_oom_check(void *ptr); |
ca10f867 | 51 | |
7c7c0629 JQ |
52 | ssize_t qemu_write_full(int fd, const void *buf, size_t count) |
53 | QEMU_WARN_UNUSED_RESULT; | |
40ff6d7e KW |
54 | |
55 | #ifndef _WIN32 | |
56 | int qemu_pipe(int pipefd[2]); | |
4efeabbb MT |
57 | /* like openpty() but also makes it raw; return master fd */ |
58 | int qemu_openpty_raw(int *aslave, char *pty_name); | |
40ff6d7e KW |
59 | #endif |
60 | ||
00aa0040 | 61 | #ifdef _WIN32 |
58455eb9 SW |
62 | /* MinGW needs type casts for the 'buf' and 'optval' arguments. */ |
63 | #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \ | |
64 | getsockopt(sockfd, level, optname, (void *)optval, optlen) | |
65 | #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \ | |
66 | setsockopt(sockfd, level, optname, (const void *)optval, optlen) | |
00aa0040 | 67 | #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags) |
73062dfe SW |
68 | #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ |
69 | sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen) | |
00aa0040 | 70 | #else |
58455eb9 SW |
71 | #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \ |
72 | getsockopt(sockfd, level, optname, optval, optlen) | |
73 | #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \ | |
74 | setsockopt(sockfd, level, optname, optval, optlen) | |
00aa0040 | 75 | #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags) |
73062dfe SW |
76 | #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \ |
77 | sendto(sockfd, buf, len, flags, destaddr, addrlen) | |
00aa0040 BS |
78 | #endif |
79 | ||
8e2b7299 | 80 | extern bool tcg_allowed; |
d5ab9713 | 81 | void tcg_exec_init(unsigned long tb_size); |
8e2b7299 YZ |
82 | #ifdef CONFIG_TCG |
83 | #define tcg_enabled() (tcg_allowed) | |
84 | #else | |
85 | #define tcg_enabled() 0 | |
86 | #endif | |
d5ab9713 JK |
87 | |
88 | void cpu_exec_init_all(void); | |
fdbc2b57 | 89 | void cpu_exec_step_atomic(CPUState *cpu); |
d2053c3c | 90 | |
20bccb82 PM |
91 | /** |
92 | * set_preferred_target_page_bits: | |
93 | * @bits: number of bits needed to represent an address within the page | |
94 | * | |
95 | * Set the preferred target page size (the actual target page | |
96 | * size may be smaller than any given CPU's preference). | |
97 | * Returns true on success, false on failure (which can only happen | |
98 | * if this is called after the system has already finalized its | |
99 | * choice of page size and the requested page size is smaller than that). | |
100 | */ | |
101 | bool set_preferred_target_page_bits(int bits); | |
102 | ||
8c5135f9 | 103 | /** |
2fc8ae1d MT |
104 | * Sends a (part of) iovec down a socket, yielding when the socket is full, or |
105 | * Receives data into a (part of) iovec from a socket, | |
106 | * yielding when there is no data in the socket. | |
107 | * The same interface as qemu_sendv_recvv(), with added yielding. | |
108 | * XXX should mark these as coroutine_fn | |
8c5135f9 | 109 | */ |
2fc8ae1d MT |
110 | ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, |
111 | size_t offset, size_t bytes, bool do_send); | |
112 | #define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \ | |
113 | qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false) | |
114 | #define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \ | |
115 | qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true) | |
8c5135f9 PB |
116 | |
117 | /** | |
2fc8ae1d | 118 | * The same as above, but with just a single buffer |
8c5135f9 | 119 | */ |
2fc8ae1d MT |
120 | ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send); |
121 | #define qemu_co_recv(sockfd, buf, bytes) \ | |
122 | qemu_co_send_recv(sockfd, buf, bytes, false) | |
123 | #define qemu_co_send(sockfd, buf, bytes) \ | |
124 | qemu_co_send_recv(sockfd, buf, bytes, true) | |
8c5135f9 | 125 | |
6b837bc4 JS |
126 | void qemu_progress_init(int enabled, float min_skip); |
127 | void qemu_progress_end(void); | |
3bfe4dbf | 128 | void qemu_progress_print(float delta, int max); |
31459f46 | 129 | const char *qemu_get_vm_name(void); |
6b837bc4 | 130 | |
082b5557 BS |
131 | #define QEMU_FILE_TYPE_BIOS 0 |
132 | #define QEMU_FILE_TYPE_KEYMAP 1 | |
133 | char *qemu_find_file(int type, const char *name); | |
134 | ||
135 | /* OS specific functions */ | |
136 | void os_setup_early_signal_handling(void); | |
10f5bff6 | 137 | char *os_find_datadir(void); |
1217d6ca | 138 | int os_parse_cmd_args(int index, const char *optarg); |
082b5557 | 139 | |
1de7afc9 | 140 | #include "qemu/module.h" |
0bfe3ca5 | 141 | |
6ff66f50 PC |
142 | /* |
143 | * Hexdump a buffer to a file. An optional string prefix is added to every line | |
144 | */ | |
145 | ||
3568ac2a | 146 | void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); |
6ff66f50 | 147 | |
b16352ac AL |
148 | /* |
149 | * helper to parse debug environment variables | |
150 | */ | |
151 | int parse_debug_env(const char *name, int max, int initial); | |
152 | ||
4297c8ee | 153 | const char *qemu_ether_ntoa(const MACAddr *mac); |
22951aaa | 154 | char *size_to_str(uint64_t val); |
87f50caa | 155 | void page_size_init(void); |
4297c8ee | 156 | |
65d64f36 PX |
157 | /* returns non-zero if dump is in progress, otherwise zero is |
158 | * returned. */ | |
159 | bool dump_in_progress(void); | |
160 | ||
faf07963 | 161 | #endif |