VirtualBox

source: vbox/trunk/src/recompiler_new/osdep.h@ 13356

Last change on this file since 13356 was 13337, checked in by vboxsync, 16 years ago

more recompiler work

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1#ifndef QEMU_OSDEP_H
2#define QEMU_OSDEP_H
3
4#ifdef VBOX
5
6#include <iprt/alloc.h>
7#include <iprt/stdarg.h>
8#include <iprt/string.h>
9
10#define qemu_snprintf(pszBuf, cbBuf, ...) RTStrPrintf((pszBuf), (cbBuf), __VA_ARGS__)
11#define qemu_vsnprintf(pszBuf, cbBuf, pszFormat, args) \
12 RTStrPrintfV((pszBuf), (cbBuf), (pszFormat), (args))
13#define qemu_vprintf(pszFormat, args) \
14 RTLogPrintfV((pszFormat), (args))
15#define qemu_printf RTLogPrintf
16#define qemu_malloc(cb) RTMemAlloc(cb)
17#define qemu_mallocz(cb) RTMemAllocZ(cb)
18#define qemu_free(pv) RTMemFree(pv)
19#define qemu_strdup(psz) RTStrDup(psz)
20
21#define qemu_vmalloc(cb) RTMemPageAlloc(cb)
22#define qemu_vfree(pv) RTMemPageFree(pv)
23
24#ifndef NULL
25# define NULL 0
26#endif
27
28#else /* !VBOX */
29
30#include <stdarg.h>
31
32#define qemu_snprintf snprintf /* bird */
33#define qemu_vsnprintf vsnprintf /* bird */
34#define qemu_vprintf vprintf /* bird */
35
36#define qemu_printf printf
37
38void *qemu_malloc(size_t size);
39void *qemu_mallocz(size_t size);
40void qemu_free(void *ptr);
41char *qemu_strdup(const char *str);
42
43void *qemu_vmalloc(size_t size);
44void qemu_vfree(void *ptr);
45
46void *get_mmap_addr(unsigned long size);
47
48#endif /* !VBOX */
49
50#ifdef __OpenBSD__
51#include <sys/types.h>
52#include <sys/signal.h>
53#endif
54
55#ifndef glue
56#define xglue(x, y) x ## y
57#define glue(x, y) xglue(x, y)
58#define stringify(s) tostring(s)
59#define tostring(s) #s
60#endif
61
62#ifndef likely
63#ifndef VBOX
64#if __GNUC__ < 3
65#define __builtin_expect(x, n) (x)
66#endif
67
68#define likely(x) __builtin_expect(!!(x), 1)
69#define unlikely(x) __builtin_expect(!!(x), 0)
70#else // VBOX
71#define likely(cond) RT_LIKELY(cond)
72#define unlikely(cond) RT_UNLIKELY(cond)
73#endif
74#endif // !likely
75
76#ifndef offsetof
77#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
78#endif
79#ifndef container_of
80#define container_of(ptr, type, member) ({ \
81 const typeof(((type *) 0)->member) *__mptr = (ptr); \
82 (type *) ((char *) __mptr - offsetof(type, member));})
83#endif
84
85#ifndef MIN
86#define MIN(a, b) (((a) < (b)) ? (a) : (b))
87#endif
88#ifndef MAX
89#define MAX(a, b) (((a) > (b)) ? (a) : (b))
90#endif
91
92#ifndef ARRAY_SIZE
93#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
94#endif
95
96#ifndef always_inline
97#if (__GNUC__ < 3) || defined(__APPLE__)
98#define always_inline inline
99#else
100#define always_inline __attribute__ (( always_inline )) __inline__
101#define inline always_inline
102#endif
103#else
104#define inline always_inline
105#endif
106
107#ifdef __i386__
108#define REGPARM __attribute((regparm(3)))
109#else
110#define REGPARM
111#endif
112
113#if defined (__GNUC__) && defined (__GNUC_MINOR_)
114# define QEMU_GNUC_PREREQ(maj, min) \
115 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
116#else
117# define QEMU_GNUC_PREREQ(maj, min) 0
118#endif
119
120void *qemu_memalign(size_t alignment, size_t size);
121void *qemu_vmalloc(size_t size);
122void qemu_vfree(void *ptr);
123
124#ifndef VBOX
125int qemu_create_pidfile(const char *filename);
126
127#ifdef _WIN32
128int ffs(int i);
129
130typedef struct {
131 long tv_sec;
132 long tv_usec;
133} qemu_timeval;
134int qemu_gettimeofday(qemu_timeval *tp);
135#else
136typedef struct timeval qemu_timeval;
137#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
138#endif /* !_WIN32 */
139#endif // !VBOX
140
141#endif
Note: See TracBrowser for help on using the repository browser.

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