root / osdep.h @ 00dbbb03
History | View | Annotate | Download (1.6 kB)
1 |
#ifndef QEMU_OSDEP_H
|
---|---|
2 |
#define QEMU_OSDEP_H
|
3 |
|
4 |
#include <stdarg.h> |
5 |
#ifdef __OpenBSD__
|
6 |
#include <sys/types.h> |
7 |
#include <sys/signal.h> |
8 |
#endif
|
9 |
|
10 |
#ifndef glue
|
11 |
#define xglue(x, y) x ## y |
12 |
#define glue(x, y) xglue(x, y)
|
13 |
#define stringify(s) tostring(s)
|
14 |
#define tostring(s) #s |
15 |
#endif
|
16 |
|
17 |
#ifndef likely
|
18 |
#if __GNUC__ < 3 |
19 |
#define __builtin_expect(x, n) (x)
|
20 |
#endif
|
21 |
|
22 |
#define likely(x) __builtin_expect(!!(x), 1) |
23 |
#define unlikely(x) __builtin_expect(!!(x), 0) |
24 |
#endif
|
25 |
|
26 |
#define container_of(ptr, type, member) ({ \
|
27 |
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
28 |
(type *)( (char *)__mptr - offsetof(type,member) );})
|
29 |
|
30 |
#ifndef MIN
|
31 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
32 |
#endif
|
33 |
#ifndef MAX
|
34 |
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
35 |
#endif
|
36 |
|
37 |
#ifndef ARRAY_SIZE
|
38 |
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
39 |
#endif
|
40 |
|
41 |
#ifndef always_inline
|
42 |
#if (__GNUC__ < 3) || defined(__APPLE__) |
43 |
#define always_inline inline |
44 |
#else
|
45 |
#define always_inline __attribute__ (( always_inline )) __inline__
|
46 |
#define inline always_inline |
47 |
#endif
|
48 |
#else
|
49 |
#define inline always_inline |
50 |
#endif
|
51 |
|
52 |
#ifdef __i386__
|
53 |
#define REGPARM __attribute((regparm(3))) |
54 |
#else
|
55 |
#define REGPARM
|
56 |
#endif
|
57 |
|
58 |
#define qemu_printf printf
|
59 |
|
60 |
void *qemu_memalign(size_t alignment, size_t size);
|
61 |
void *qemu_vmalloc(size_t size);
|
62 |
void qemu_vfree(void *ptr); |
63 |
|
64 |
int qemu_create_pidfile(const char *filename); |
65 |
|
66 |
#ifdef _WIN32
|
67 |
int ffs(int i); |
68 |
|
69 |
typedef struct { |
70 |
long tv_sec;
|
71 |
long tv_usec;
|
72 |
} qemu_timeval; |
73 |
int qemu_gettimeofday(qemu_timeval *tp);
|
74 |
#else
|
75 |
typedef struct timeval qemu_timeval; |
76 |
#define qemu_gettimeofday(tp) gettimeofday(tp, NULL); |
77 |
#endif /* !_WIN32 */ |
78 |
|
79 |
#endif
|