1 | #ifndef QEMU_OSDEP_H
|
---|
2 | #define QEMU_OSDEP_H
|
---|
3 |
|
---|
4 | #if defined(VBOX)
|
---|
5 |
|
---|
6 | #include <iprt/alloc.h>
|
---|
7 | #include <iprt/string.h>
|
---|
8 |
|
---|
9 | #define qemu_vsnprintf(pszBuf, cchBuf, pszFormat, args) \
|
---|
10 | RTStrPrintfV((pszBuf), (cchBuf), (pszFormat), (args))
|
---|
11 | #define qemu_vprintf(pszFormat, args) \
|
---|
12 | RTLogPrintfV((pszFormat), (args))
|
---|
13 | #define qemu_printf RTLogPrintf
|
---|
14 | #define qemu_malloc(cb) RTMemAlloc(cb)
|
---|
15 | #define qemu_mallocz(cb) RTMemAllocZ(cb)
|
---|
16 | #define qemu_free(pv) RTMemFree(pv)
|
---|
17 | #define qemu_strdup(psz) RTStrDup(psz)
|
---|
18 |
|
---|
19 |
|
---|
20 | #else /* !VBOX */
|
---|
21 |
|
---|
22 | #include <stdarg.h>
|
---|
23 |
|
---|
24 | int qemu_vsnprintf(char *buf, int buflen, const char *fmt, va_list args);
|
---|
25 | void qemu_vprintf(const char *fmt, va_list ap);
|
---|
26 | void qemu_printf(const char *fmt, ...);
|
---|
27 |
|
---|
28 | void *qemu_malloc(size_t size);
|
---|
29 | void *qemu_mallocz(size_t size);
|
---|
30 | void qemu_free(void *ptr);
|
---|
31 | char *qemu_strdup(const char *str);
|
---|
32 |
|
---|
33 | void *get_mmap_addr(unsigned long size);
|
---|
34 |
|
---|
35 | /* specific kludges for OS compatibility (should be moved elsewhere) */
|
---|
36 | #if defined(__i386__) && !defined(CONFIG_SOFTMMU) && !defined(CONFIG_USER_ONLY)
|
---|
37 |
|
---|
38 | /* disabled pthread version of longjmp which prevent us from using an
|
---|
39 | alternative signal stack */
|
---|
40 | extern void __longjmp(jmp_buf env, int val);
|
---|
41 | #define longjmp __longjmp
|
---|
42 |
|
---|
43 | #include <signal.h>
|
---|
44 |
|
---|
45 | /* NOTE: it works only because the glibc sigset_t is >= kernel sigset_t */
|
---|
46 | struct qemu_sigaction {
|
---|
47 | union {
|
---|
48 | void (*_sa_handler)(int);
|
---|
49 | void (*_sa_sigaction)(int, struct siginfo *, void *);
|
---|
50 | } _u;
|
---|
51 | unsigned long sa_flags;
|
---|
52 | void (*sa_restorer)(void);
|
---|
53 | sigset_t sa_mask; /* mask last for extensibility */
|
---|
54 | };
|
---|
55 |
|
---|
56 | int qemu_sigaction(int signum, const struct qemu_sigaction *act,
|
---|
57 | struct qemu_sigaction *oldact);
|
---|
58 |
|
---|
59 | #undef sigaction
|
---|
60 | #undef sa_handler
|
---|
61 | #undef sa_sigaction
|
---|
62 | #define sigaction qemu_sigaction
|
---|
63 | #define sa_handler _u._sa_handler
|
---|
64 | #define sa_sigaction _u._sa_sigaction
|
---|
65 |
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #endif /* !VBOX */
|
---|
69 |
|
---|
70 | #endif
|
---|