VirtualBox

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

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

solaris new recompiler

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