]> Git Repo - qemu.git/blame - qemu-common.h
Luminary board input support.
[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
87ecb68b
PB
65#ifndef glue
66#define xglue(x, y) x ## y
67#define glue(x, y) xglue(x, y)
68#define stringify(s) tostring(s)
69#define tostring(s) #s
70#endif
71
72#ifndef likely
73#if __GNUC__ < 3
74#define __builtin_expect(x, n) (x)
75#endif
76
77#define likely(x) __builtin_expect(!!(x), 1)
78#define unlikely(x) __builtin_expect(!!(x), 0)
79#endif
80
81#ifndef MIN
82#define MIN(a, b) (((a) < (b)) ? (a) : (b))
83#endif
84#ifndef MAX
85#define MAX(a, b) (((a) > (b)) ? (a) : (b))
86#endif
87
88#ifndef always_inline
89#if (__GNUC__ < 3) || defined(__APPLE__)
90#define always_inline inline
91#else
92#define always_inline __attribute__ (( always_inline )) inline
93#endif
94#endif
95
faf07963
PB
96/* bottom halves */
97typedef struct QEMUBH QEMUBH;
98
99typedef void QEMUBHFunc(void *opaque);
100
101QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
102void qemu_bh_schedule(QEMUBH *bh);
103void qemu_bh_cancel(QEMUBH *bh);
104void qemu_bh_delete(QEMUBH *bh);
105int qemu_bh_poll(void);
106
87ecb68b
PB
107uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
108
faf07963
PB
109/* cutils.c */
110void pstrcpy(char *buf, int buf_size, const char *str);
111char *pstrcat(char *buf, int buf_size, const char *s);
112int strstart(const char *str, const char *val, const char **ptr);
113int stristart(const char *str, const char *val, const char **ptr);
114time_t mktimegm(struct tm *tm);
115
87ecb68b
PB
116/* Error handling. */
117
118void hw_error(const char *fmt, ...)
119 __attribute__ ((__format__ (__printf__, 1, 2)))
120 __attribute__ ((__noreturn__));
121
122/* IO callbacks. */
123typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
124typedef int IOCanRWHandler(void *opaque);
125typedef void IOHandler(void *opaque);
126
127struct ParallelIOArg {
128 void *buffer;
129 int count;
130};
131
132typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
133
134/* A load of opaque types so that device init declarations don't have to
135 pull in all the real definitions. */
136typedef struct NICInfo NICInfo;
137typedef struct AudioState AudioState;
138typedef struct BlockDriverState BlockDriverState;
139typedef struct DisplayState DisplayState;
140typedef struct TextConsole TextConsole;
141typedef struct CharDriverState CharDriverState;
142typedef struct VLANState VLANState;
143typedef struct QEMUFile QEMUFile;
144typedef struct i2c_bus i2c_bus;
145typedef struct i2c_slave i2c_slave;
146typedef struct SMBusDevice SMBusDevice;
147typedef struct QEMUTimer QEMUTimer;
148typedef struct PCIBus PCIBus;
149typedef struct PCIDevice PCIDevice;
150typedef struct SerialState SerialState;
151typedef struct IRQState *qemu_irq;
152struct pcmcia_card_s;
153
faf07963 154#endif
This page took 0.034659 seconds and 4 git commands to generate.