VirtualBox

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

Last change on this file since 36412 was 36172, checked in by vboxsync, 14 years ago

build fix

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
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 VBOX
76#ifndef _WIN32
77#include <sys/time.h>
78#endif
79#endif /* !VBOX */
80
81#ifndef glue
82#define xglue(x, y) x ## y
83#define glue(x, y) xglue(x, y)
84#define stringify(s) tostring(s)
85#define tostring(s) #s
86#endif
87
88#ifndef likely
89#if __GNUC__ < 3
90#define __builtin_expect(x, n) (x)
91#endif
92
93#define likely(x) __builtin_expect(!!(x), 1)
94#define unlikely(x) __builtin_expect(!!(x), 0)
95#endif
96
97#ifndef offsetof
98#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
99#endif
100#ifndef container_of
101#define container_of(ptr, type, member) ({ \
102 const typeof(((type *) 0)->member) *__mptr = (ptr); \
103 (type *) ((char *) __mptr - offsetof(type, member));})
104#endif
105
106#ifndef MIN
107#define MIN(a, b) (((a) < (b)) ? (a) : (b))
108#endif
109#ifndef MAX
110#define MAX(a, b) (((a) > (b)) ? (a) : (b))
111#endif
112
113#ifndef ARRAY_SIZE
114#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
115#endif
116
117#ifndef always_inline
118#if (__GNUC__ < 3) || defined(__APPLE__)
119#define always_inline inline
120#else
121#define always_inline __attribute__ (( always_inline )) __inline__
122#ifdef __OPTIMIZE__
123#define inline always_inline
124#endif
125#endif
126#else
127#define inline always_inline
128#endif
129
130#ifdef __i386__
131#define REGPARM __attribute((regparm(3)))
132#else
133#define REGPARM
134#endif
135
136#ifndef VBOX
137#define qemu_printf printf
138#endif
139
140#if defined (__GNUC__) && defined (__GNUC_MINOR__)
141# define QEMU_GNUC_PREREQ(maj, min) \
142 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
143#else
144# define QEMU_GNUC_PREREQ(maj, min) 0
145#endif
146
147#ifndef VBOX
148void *qemu_memalign(size_t alignment, size_t size);
149void *qemu_vmalloc(size_t size);
150void qemu_vfree(void *ptr);
151
152int qemu_create_pidfile(const char *filename);
153
154#ifdef _WIN32
155int ffs(int i);
156
157typedef struct {
158 long tv_sec;
159 long tv_usec;
160} qemu_timeval;
161int qemu_gettimeofday(qemu_timeval *tp);
162#else
163typedef struct timeval qemu_timeval;
164#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
165#endif /* !_WIN32 */
166#else /* VBOX */
167# define qemu_memalign(alignment, size) ( (alignment) <= PAGE_SIZE ? RTMemPageAlloc((size)) : NULL )
168#endif /* VBOX */
169
170#endif
Note: See TracBrowser for help on using the repository browser.

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