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