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