VirtualBox

source: vbox/trunk/src/recompiler/osdep.h@ 36140

最後變更 在這個檔案從36140是 36140,由 vboxsync 提交於 14 年 前

rem: Re-synced to svn://svn.savannah.nongnu.org/qemu/trunk@5495 (repo UUID c046a42c-6fe2-441c-8c8c-71466251a162).

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.9 KB
 
1#ifndef QEMU_OSDEP_H
2#define QEMU_OSDEP_H
3
4#ifdef VBOX /** @todo clean up this, it's not fully synched. */
5
6#include <iprt/alloc.h>
7#ifndef RT_OS_WINDOWS
8# include <iprt/alloca.h>
9#endif
10#include <iprt/stdarg.h>
11#include <iprt/string.h>
12
13#include "config.h"
14
15#define VBOX_ONLY(x) x
16
17#define qemu_snprintf(pszBuf, cbBuf, ...) RTStrPrintf((pszBuf), (cbBuf), __VA_ARGS__)
18#define qemu_vsnprintf(pszBuf, cbBuf, pszFormat, args) \
19 RTStrPrintfV((pszBuf), (cbBuf), (pszFormat), (args))
20#define qemu_vprintf(pszFormat, args) \
21 RTLogPrintfV((pszFormat), (args))
22#define qemu_printf RTLogPrintf
23#define qemu_malloc(cb) RTMemAlloc(cb)
24#define qemu_mallocz(cb) RTMemAllocZ(cb)
25#define qemu_realloc(ptr, cb) RTMemRealloc(ptr, cb)
26
27#define qemu_free(pv) RTMemFree(pv)
28#define qemu_strdup(psz) RTStrDup(psz)
29
30#define qemu_vmalloc(cb) RTMemPageAlloc(cb)
31#define qemu_vfree(pv) RTMemPageFree(pv, missing_size_parameter)
32
33#ifndef NULL
34# define NULL 0
35#endif
36
37#define fflush(file) RTLogFlush(NULL)
38#define printf(...) LogIt(LOG_INSTANCE, 0, LOG_GROUP_REM_PRINTF, (__VA_ARGS__))
39/* If DEBUG_TMP_LOGGING - goes to QEMU log file */
40#ifndef DEBUG_TMP_LOGGING
41# define fprintf(logfile, ...) LogIt(LOG_INSTANCE, 0, LOG_GROUP_REM_PRINTF, (__VA_ARGS__))
42#endif
43
44#define assert(cond) Assert(cond)
45
46#else /* !VBOX */
47
48#include <stdarg.h>
49
50#define VBOX_ONLY(x)
51
52#define qemu_snprintf snprintf /* bird */
53#define qemu_vsnprintf vsnprintf /* bird */
54#define qemu_vprintf vprintf /* bird */
55
56#define qemu_printf printf
57
58void *qemu_malloc(size_t size);
59void *qemu_mallocz(size_t size);
60void qemu_free(void *ptr);
61char *qemu_strdup(const char *str);
62
63void *qemu_vmalloc(size_t size);
64void qemu_vfree(void *ptr);
65
66void *get_mmap_addr(unsigned long size);
67
68#endif /* !VBOX */
69
70#ifdef __OpenBSD__
71#include <sys/types.h>
72#include <sys/signal.h>
73#endif
74
75#ifndef glue
76#define xglue(x, y) x ## y
77#define glue(x, y) xglue(x, y)
78#define stringify(s) tostring(s)
79#define tostring(s) #s
80#endif
81
82#ifndef likely
83#if __GNUC__ < 3
84#define __builtin_expect(x, n) (x)
85#endif
86
87#define likely(x) __builtin_expect(!!(x), 1)
88#define unlikely(x) __builtin_expect(!!(x), 0)
89#endif /* !likely */
90
91#ifndef offsetof
92#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
93#endif
94#ifndef container_of
95#define container_of(ptr, type, member) ({ \
96 const typeof(((type *) 0)->member) *__mptr = (ptr); \
97 (type *) ((char *) __mptr - offsetof(type, member));})
98#endif
99
100#ifndef MIN
101#define MIN(a, b) (((a) < (b)) ? (a) : (b))
102#endif
103#ifndef MAX
104#define MAX(a, b) (((a) > (b)) ? (a) : (b))
105#endif
106
107#ifndef ARRAY_SIZE
108#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
109#endif
110
111#ifndef always_inline
112#if (__GNUC__ < 3) || defined(__APPLE__)
113#define always_inline inline
114#else
115#define always_inline __attribute__ (( always_inline )) __inline__
116#define inline always_inline
117#endif
118#else
119#define inline always_inline
120#endif
121
122#ifdef __i386__
123#define REGPARM __attribute((regparm(3)))
124#else
125#define REGPARM
126#endif
127
128#ifndef VBOX
129#define qemu_printf printf
130#endif
131
132#if defined (__GNUC__) && defined (__GNUC_MINOR_)
133# define QEMU_GNUC_PREREQ(maj, min) \
134 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
135#else
136# define QEMU_GNUC_PREREQ(maj, min) 0
137#endif
138
139#ifndef VBOX
140void *qemu_memalign(size_t alignment, size_t size);
141void *qemu_vmalloc(size_t size);
142void qemu_vfree(void *ptr);
143
144int qemu_create_pidfile(const char *filename);
145
146#ifdef _WIN32
147int ffs(int i);
148
149typedef struct {
150 long tv_sec;
151 long tv_usec;
152} qemu_timeval;
153int qemu_gettimeofday(qemu_timeval *tp);
154#else
155typedef struct timeval qemu_timeval;
156#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
157#endif /* !_WIN32 */
158#endif /* !VBOX */
159
160#ifdef VBOX
161/** @todo why don't we go with dyngen-exec.h here? */
162#define FORCE_RET() ;
163#endif /* VBOX */
164
165#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette