VirtualBox

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

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

MSVC related changes

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