VirtualBox

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

Last change on this file since 36138 was 36125, checked in by vboxsync, 14 years ago

recompiler: Removing traces of attempts at making the recompiler compile with the microsoft compiler. (untested)

  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
1#ifndef QEMU_OSDEP_H
2#define QEMU_OSDEP_H
3
4#ifdef VBOX
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#ifndef VBOX
84#if __GNUC__ < 3
85#define __builtin_expect(x, n) (x)
86#endif
87
88#define likely(x) __builtin_expect(!!(x), 1)
89#define unlikely(x) __builtin_expect(!!(x), 0)
90#else /* VBOX */
91#define likely(cond) RT_LIKELY(cond)
92#define unlikely(cond) RT_UNLIKELY(cond)
93#endif
94#endif /* !likely */
95
96#ifndef offsetof
97#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
98#endif
99#ifndef container_of
100#define container_of(ptr, type, member) ({ \
101 const typeof(((type *) 0)->member) *__mptr = (ptr); \
102 (type *) ((char *) __mptr - offsetof(type, member));})
103#endif
104
105#ifndef MIN
106#define MIN(a, b) (((a) < (b)) ? (a) : (b))
107#endif
108#ifndef MAX
109#define MAX(a, b) (((a) > (b)) ? (a) : (b))
110#endif
111
112#ifndef ARRAY_SIZE
113#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
114#endif
115
116#ifndef always_inline
117#if (__GNUC__ < 3) || defined(__APPLE__)
118#define always_inline inline
119#else
120#define always_inline __attribute__ (( always_inline )) __inline__
121#define inline always_inline
122#endif
123#else
124#define inline always_inline
125#endif
126
127#ifdef __i386__
128#define REGPARM __attribute((regparm(3)))
129#else
130#define REGPARM
131#endif
132
133#if defined (__GNUC__) && defined (__GNUC_MINOR_)
134# define QEMU_GNUC_PREREQ(maj, min) \
135 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
136#else
137# define QEMU_GNUC_PREREQ(maj, min) 0
138#endif
139
140#ifndef VBOX
141void *qemu_memalign(size_t alignment, size_t size);
142void *qemu_vmalloc(size_t size);
143void qemu_vfree(void *ptr);
144
145int qemu_create_pidfile(const char *filename);
146
147#ifdef _WIN32
148int ffs(int i);
149
150typedef struct {
151 long tv_sec;
152 long tv_usec;
153} qemu_timeval;
154int qemu_gettimeofday(qemu_timeval *tp);
155#else
156typedef struct timeval qemu_timeval;
157#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
158#endif /* !_WIN32 */
159#endif /* !VBOX */
160
161#ifdef VBOX
162/** @todo why don't we go with dyngen-exec.h here? */
163#define FORCE_RET() ;
164#endif /* VBOX */
165
166#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