Merge tag 'v4.1.0-rc4'
[qemu/ar7.git] / include / qemu-common.h
blob1cf44aca2029ec07f7c54513d4f24402d6e2f081
1 /*
2 * This file is supposed to be included only by .c files. No header file should
3 * depend on qemu-common.h, as this would easily lead to circular header
4 * dependencies.
6 * If a header file uses a definition from qemu-common.h, that definition
7 * must be moved to a separate header file, and the header that uses it
8 * must include that header.
9 */
10 #ifndef QEMU_COMMON_H
11 #define QEMU_COMMON_H
13 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
15 /* Copyright string for -version arguments, About dialogs, etc */
16 #define QEMU_COPYRIGHT "Copyright (c) 2003-2019 " \
17 "Fabrice Bellard and the QEMU Project developers"
19 /* Bug reporting information for --help arguments, About dialogs, etc */
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>."
24 /* Trace unassigned memory or i/o accesses. */
25 extern bool trace_unassigned;
27 /* main function, renamed */
28 #if defined(CONFIG_COCOA)
29 int qemu_main(int argc, char **argv, char **envp);
30 #endif
32 void qemu_get_timedate(struct tm *tm, int offset);
33 int qemu_timedate_diff(struct tm *tm);
35 void *qemu_oom_check(void *ptr);
37 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
38 QEMU_WARN_UNUSED_RESULT;
40 #ifndef _WIN32
41 int qemu_pipe(int pipefd[2]);
42 /* like openpty() but also makes it raw; return master fd */
43 int qemu_openpty_raw(int *aslave, char *pty_name);
44 #endif
46 #ifdef _WIN32
47 /* MinGW needs type casts for the 'buf' and 'optval' arguments. */
48 #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
49 getsockopt(sockfd, level, optname, (void *)optval, optlen)
50 #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
51 setsockopt(sockfd, level, optname, (const void *)optval, optlen)
52 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
53 #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
54 sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
55 #else
56 #define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
57 getsockopt(sockfd, level, optname, optval, optlen)
58 #define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
59 setsockopt(sockfd, level, optname, optval, optlen)
60 #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
61 #define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
62 sendto(sockfd, buf, len, flags, destaddr, addrlen)
63 #endif
65 void cpu_exec_init_all(void);
66 void cpu_exec_step_atomic(CPUState *cpu);
68 /**
69 * set_preferred_target_page_bits:
70 * @bits: number of bits needed to represent an address within the page
72 * Set the preferred target page size (the actual target page
73 * size may be smaller than any given CPU's preference).
74 * Returns true on success, false on failure (which can only happen
75 * if this is called after the system has already finalized its
76 * choice of page size and the requested page size is smaller than that).
78 bool set_preferred_target_page_bits(int bits);
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
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)
94 /**
95 * The same as above, but with just a single buffer
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)
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);
108 #define QEMU_FILE_TYPE_BIOS 0
109 #define QEMU_FILE_TYPE_KEYMAP 1
110 char *qemu_find_file(int type, const char *name);
112 /* OS specific functions */
113 void os_setup_early_signal_handling(void);
114 char *os_find_datadir(void);
115 int os_parse_cmd_args(int index, const char *optarg);
118 * Hexdump a buffer to a file. An optional string prefix is added to every line
121 void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
124 * helper to parse debug environment variables
126 int parse_debug_env(const char *name, int max, int initial);
128 const char *qemu_ether_ntoa(const MACAddr *mac);
129 char *size_to_str(uint64_t val);
130 void page_size_init(void);
132 /* returns non-zero if dump is in progress, otherwise zero is
133 * returned. */
134 bool dump_in_progress(void);
136 #endif