Correct errno return for getsockopt(), by Thayne Harbaugh.
[qemu/qemu_0_9_1_stable.git] / qemu-common.h
blobe8ea68735b4ded13c35f02307f0d80845700d431
1 /* Common header file that is included by all of qemu. */
2 #ifndef QEMU_COMMON_H
3 #define QEMU_COMMON_H
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>
19 #ifndef O_LARGEFILE
20 #define O_LARGEFILE 0
21 #endif
22 #ifndef O_BINARY
23 #define O_BINARY 0
24 #endif
26 #ifndef ENOMEDIUM
27 #define ENOMEDIUM ENODEV
28 #endif
30 #ifdef _WIN32
31 #define WIN32_LEAN_AND_MEAN
32 #include <windows.h>
33 #define fsync _commit
34 #define lseek _lseeki64
35 #define ENOTSUP 4096
36 extern int qemu_ftruncate64(int, int64_t);
37 #define ftruncate qemu_ftruncate64
40 static inline char *realpath(const char *path, char *resolved_path)
42 _fullpath(resolved_path, path, _MAX_PATH);
43 return resolved_path;
46 #define PRId64 "I64d"
47 #define PRIx64 "I64x"
48 #define PRIu64 "I64u"
49 #define PRIo64 "I64o"
50 #endif
52 /* FIXME: Remove NEED_CPU_H. */
53 #ifndef NEED_CPU_H
55 #include "config-host.h"
56 #include <setjmp.h>
57 #include "osdep.h"
58 #include "bswap.h"
60 #else
62 #include "cpu.h"
64 #endif /* !defined(NEED_CPU_H) */
66 /* bottom halves */
67 typedef struct QEMUBH QEMUBH;
69 typedef void QEMUBHFunc(void *opaque);
71 QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
72 void qemu_bh_schedule(QEMUBH *bh);
73 void qemu_bh_cancel(QEMUBH *bh);
74 void qemu_bh_delete(QEMUBH *bh);
75 int qemu_bh_poll(void);
77 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
79 /* cutils.c */
80 void pstrcpy(char *buf, int buf_size, const char *str);
81 char *pstrcat(char *buf, int buf_size, const char *s);
82 int strstart(const char *str, const char *val, const char **ptr);
83 int stristart(const char *str, const char *val, const char **ptr);
84 time_t mktimegm(struct tm *tm);
86 /* Error handling. */
88 void hw_error(const char *fmt, ...)
89 __attribute__ ((__format__ (__printf__, 1, 2)))
90 __attribute__ ((__noreturn__));
92 /* IO callbacks. */
93 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
94 typedef int IOCanRWHandler(void *opaque);
95 typedef void IOHandler(void *opaque);
97 struct ParallelIOArg {
98 void *buffer;
99 int count;
102 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
104 /* A load of opaque types so that device init declarations don't have to
105 pull in all the real definitions. */
106 typedef struct NICInfo NICInfo;
107 typedef struct AudioState AudioState;
108 typedef struct BlockDriverState BlockDriverState;
109 typedef struct DisplayState DisplayState;
110 typedef struct TextConsole TextConsole;
111 typedef struct CharDriverState CharDriverState;
112 typedef struct VLANState VLANState;
113 typedef struct QEMUFile QEMUFile;
114 typedef struct i2c_bus i2c_bus;
115 typedef struct i2c_slave i2c_slave;
116 typedef struct SMBusDevice SMBusDevice;
117 typedef struct QEMUTimer QEMUTimer;
118 typedef struct PCIBus PCIBus;
119 typedef struct PCIDevice PCIDevice;
120 typedef struct SerialState SerialState;
121 typedef struct IRQState *qemu_irq;
122 struct pcmcia_card_s;
124 #endif