]> Git Repo - qemu.git/blob - include/qemu-common.h
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
[qemu.git] / include / qemu-common.h
1
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  */
12 #ifndef QEMU_COMMON_H
13 #define QEMU_COMMON_H
14
15 #include "qemu/fprintf-fn.h"
16
17 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
18
19 #include "qemu/option.h"
20
21 /* main function, renamed */
22 #if defined(CONFIG_COCOA)
23 int qemu_main(int argc, char **argv, char **envp);
24 #endif
25
26 void qemu_get_timedate(struct tm *tm, int offset);
27 int qemu_timedate_diff(struct tm *tm);
28
29 #define qemu_isalnum(c)         isalnum((unsigned char)(c))
30 #define qemu_isalpha(c)         isalpha((unsigned char)(c))
31 #define qemu_iscntrl(c)         iscntrl((unsigned char)(c))
32 #define qemu_isdigit(c)         isdigit((unsigned char)(c))
33 #define qemu_isgraph(c)         isgraph((unsigned char)(c))
34 #define qemu_islower(c)         islower((unsigned char)(c))
35 #define qemu_isprint(c)         isprint((unsigned char)(c))
36 #define qemu_ispunct(c)         ispunct((unsigned char)(c))
37 #define qemu_isspace(c)         isspace((unsigned char)(c))
38 #define qemu_isupper(c)         isupper((unsigned char)(c))
39 #define qemu_isxdigit(c)        isxdigit((unsigned char)(c))
40 #define qemu_tolower(c)         tolower((unsigned char)(c))
41 #define qemu_toupper(c)         toupper((unsigned char)(c))
42 #define qemu_isascii(c)         isascii((unsigned char)(c))
43 #define qemu_toascii(c)         toascii((unsigned char)(c))
44
45 void *qemu_oom_check(void *ptr);
46
47 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
48     QEMU_WARN_UNUSED_RESULT;
49
50 #ifndef _WIN32
51 int qemu_pipe(int pipefd[2]);
52 /* like openpty() but also makes it raw; return master fd */
53 int qemu_openpty_raw(int *aslave, char *pty_name);
54 #endif
55
56 #ifdef _WIN32
57 /* MinGW needs type casts for the 'buf' and 'optval' arguments. */
58 #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
59     getsockopt(sockfd, level, optname, (void *)optval, optlen)
60 #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
61     setsockopt(sockfd, level, optname, (const void *)optval, optlen)
62 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
63 #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
64     sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
65 #else
66 #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
67     getsockopt(sockfd, level, optname, optval, optlen)
68 #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
69     setsockopt(sockfd, level, optname, optval, optlen)
70 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
71 #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
72     sendto(sockfd, buf, len, flags, destaddr, addrlen)
73 #endif
74
75 void tcg_exec_init(unsigned long tb_size);
76 bool tcg_enabled(void);
77
78 void cpu_exec_init_all(void);
79
80 /**
81  * Sends a (part of) iovec down a socket, yielding when the socket is full, or
82  * Receives data into a (part of) iovec from a socket,
83  * yielding when there is no data in the socket.
84  * The same interface as qemu_sendv_recvv(), with added yielding.
85  * XXX should mark these as coroutine_fn
86  */
87 ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
88                             size_t offset, size_t bytes, bool do_send);
89 #define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
90   qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
91 #define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
92   qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
93
94 /**
95  * The same as above, but with just a single buffer
96  */
97 ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
98 #define qemu_co_recv(sockfd, buf, bytes) \
99   qemu_co_send_recv(sockfd, buf, bytes, false)
100 #define qemu_co_send(sockfd, buf, bytes) \
101   qemu_co_send_recv(sockfd, buf, bytes, true)
102
103 void qemu_progress_init(int enabled, float min_skip);
104 void qemu_progress_end(void);
105 void qemu_progress_print(float delta, int max);
106 const char *qemu_get_vm_name(void);
107
108 #define QEMU_FILE_TYPE_BIOS   0
109 #define QEMU_FILE_TYPE_KEYMAP 1
110 char *qemu_find_file(int type, const char *name);
111
112 /* OS specific functions */
113 void os_setup_early_signal_handling(void);
114 char *os_find_datadir(void);
115 void os_parse_cmd_args(int index, const char *optarg);
116
117 #include "qemu/module.h"
118
119 /*
120  * Hexdump a buffer to a file. An optional string prefix is added to every line
121  */
122
123 void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
124
125 /*
126  * helper to parse debug environment variables
127  */
128 int parse_debug_env(const char *name, int max, int initial);
129
130 const char *qemu_ether_ntoa(const MACAddr *mac);
131 void page_size_init(void);
132
133 /* returns non-zero if dump is in progress, otherwise zero is
134  * returned. */
135 bool dump_in_progress(void);
136
137 #endif
This page took 0.032849 seconds and 4 git commands to generate.