]> git.proxmox.com Git - qemu.git/blame - qemu-common.h
Avoid duplicated definitions: move common definitions from exec-all.h
[qemu.git] / qemu-common.h
CommitLineData
faf07963
PB
1/* Common header file that is included by all of qemu. */
2#ifndef QEMU_COMMON_H
3#define QEMU_COMMON_H
4
5/* we put basic includes here to avoid repeating them in device drivers */
6#include <stdlib.h>
7#include <stdio.h>
8#include <stdarg.h>
9#include <string.h>
10#include <inttypes.h>
11#include <limits.h>
12#include <time.h>
13#include <ctype.h>
14#include <errno.h>
15#include <unistd.h>
16#include <fcntl.h>
17#include <sys/stat.h>
18
19#ifndef O_LARGEFILE
20#define O_LARGEFILE 0
21#endif
22#ifndef O_BINARY
23#define O_BINARY 0
24#endif
25
26#ifndef ENOMEDIUM
27#define ENOMEDIUM ENODEV
28#endif
29
30#ifdef _WIN32
31#include <windows.h>
32#define fsync _commit
33#define lseek _lseeki64
34#define ENOTSUP 4096
35extern int qemu_ftruncate64(int, int64_t);
36#define ftruncate qemu_ftruncate64
37
38
39static inline char *realpath(const char *path, char *resolved_path)
40{
41 _fullpath(resolved_path, path, _MAX_PATH);
42 return resolved_path;
43}
44
45#define PRId64 "I64d"
46#define PRIx64 "I64x"
47#define PRIu64 "I64u"
48#define PRIo64 "I64o"
49#endif
50
51/* FIXME: Remove NEED_CPU_H. */
52#ifndef NEED_CPU_H
53
54#include "config-host.h"
55#include <setjmp.h>
56#include "osdep.h"
57#include "bswap.h"
58
59#else
60
61#include "cpu.h"
62
63#endif /* !defined(NEED_CPU_H) */
64
65/* bottom halves */
66typedef struct QEMUBH QEMUBH;
67
68typedef void QEMUBHFunc(void *opaque);
69
70QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
71void qemu_bh_schedule(QEMUBH *bh);
72void qemu_bh_cancel(QEMUBH *bh);
73void qemu_bh_delete(QEMUBH *bh);
74int qemu_bh_poll(void);
75
87ecb68b
PB
76uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
77
faf07963
PB
78/* cutils.c */
79void pstrcpy(char *buf, int buf_size, const char *str);
80char *pstrcat(char *buf, int buf_size, const char *s);
81int strstart(const char *str, const char *val, const char **ptr);
82int stristart(const char *str, const char *val, const char **ptr);
83time_t mktimegm(struct tm *tm);
84
87ecb68b
PB
85/* Error handling. */
86
87void hw_error(const char *fmt, ...)
88 __attribute__ ((__format__ (__printf__, 1, 2)))
89 __attribute__ ((__noreturn__));
90
91/* IO callbacks. */
92typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
93typedef int IOCanRWHandler(void *opaque);
94typedef void IOHandler(void *opaque);
95
96struct ParallelIOArg {
97 void *buffer;
98 int count;
99};
100
101typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
102
103/* A load of opaque types so that device init declarations don't have to
104 pull in all the real definitions. */
105typedef struct NICInfo NICInfo;
106typedef struct AudioState AudioState;
107typedef struct BlockDriverState BlockDriverState;
108typedef struct DisplayState DisplayState;
109typedef struct TextConsole TextConsole;
110typedef struct CharDriverState CharDriverState;
111typedef struct VLANState VLANState;
112typedef struct QEMUFile QEMUFile;
113typedef struct i2c_bus i2c_bus;
114typedef struct i2c_slave i2c_slave;
115typedef struct SMBusDevice SMBusDevice;
116typedef struct QEMUTimer QEMUTimer;
117typedef struct PCIBus PCIBus;
118typedef struct PCIDevice PCIDevice;
119typedef struct SerialState SerialState;
120typedef struct IRQState *qemu_irq;
121struct pcmcia_card_s;
122
faf07963 123#endif