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