root / osdep.h @ 4b816985
History | View | Annotate | Download (2 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 | f7b4a940 | aliguori | #ifndef _WIN32
|
11 | f7b4a940 | aliguori | #include <sys/time.h> |
12 | f7b4a940 | aliguori | #endif
|
13 | f7b4a940 | aliguori | |
14 | df2542c7 | j_mayer | #ifndef glue
|
15 | df2542c7 | j_mayer | #define xglue(x, y) x ## y |
16 | df2542c7 | j_mayer | #define glue(x, y) xglue(x, y)
|
17 | df2542c7 | j_mayer | #define stringify(s) tostring(s)
|
18 | df2542c7 | j_mayer | #define tostring(s) #s |
19 | df2542c7 | j_mayer | #endif
|
20 | df2542c7 | j_mayer | |
21 | df2542c7 | j_mayer | #ifndef likely
|
22 | df2542c7 | j_mayer | #if __GNUC__ < 3 |
23 | df2542c7 | j_mayer | #define __builtin_expect(x, n) (x)
|
24 | df2542c7 | j_mayer | #endif
|
25 | df2542c7 | j_mayer | |
26 | df2542c7 | j_mayer | #define likely(x) __builtin_expect(!!(x), 1) |
27 | df2542c7 | j_mayer | #define unlikely(x) __builtin_expect(!!(x), 0) |
28 | df2542c7 | j_mayer | #endif
|
29 | df2542c7 | j_mayer | |
30 | ac509d88 | balrog | #ifndef offsetof
|
31 | ac509d88 | balrog | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) |
32 | ac509d88 | balrog | #endif
|
33 | ac509d88 | balrog | #ifndef container_of
|
34 | 62a6e3e1 | aliguori | #define container_of(ptr, type, member) ({ \
|
35 | ac509d88 | balrog | const typeof(((type *) 0)->member) *__mptr = (ptr); \ |
36 | ac509d88 | balrog | (type *) ((char *) __mptr - offsetof(type, member));})
|
37 | ac509d88 | balrog | #endif
|
38 | 62a6e3e1 | aliguori | |
39 | df2542c7 | j_mayer | #ifndef MIN
|
40 | df2542c7 | j_mayer | #define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
41 | df2542c7 | j_mayer | #endif
|
42 | df2542c7 | j_mayer | #ifndef MAX
|
43 | df2542c7 | j_mayer | #define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
44 | df2542c7 | j_mayer | #endif
|
45 | df2542c7 | j_mayer | |
46 | 0954d0d9 | blueswir1 | #ifndef ARRAY_SIZE
|
47 | 0954d0d9 | blueswir1 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
48 | 0954d0d9 | blueswir1 | #endif
|
49 | 0954d0d9 | blueswir1 | |
50 | df2542c7 | j_mayer | #ifndef always_inline
|
51 | df2542c7 | j_mayer | #if (__GNUC__ < 3) || defined(__APPLE__) |
52 | df2542c7 | j_mayer | #define always_inline inline |
53 | df2542c7 | j_mayer | #else
|
54 | df2542c7 | j_mayer | #define always_inline __attribute__ (( always_inline )) __inline__
|
55 | 3dec6ecd | pbrook | #ifdef __OPTIMIZE__
|
56 | cebdff77 | ths | #define inline always_inline |
57 | df2542c7 | j_mayer | #endif
|
58 | 3dec6ecd | pbrook | #endif
|
59 | cebdff77 | ths | #else
|
60 | df2542c7 | j_mayer | #define inline always_inline |
61 | cebdff77 | ths | #endif
|
62 | df2542c7 | j_mayer | |
63 | df2542c7 | j_mayer | #ifdef __i386__
|
64 | d656469f | bellard | #define REGPARM __attribute((regparm(3))) |
65 | df2542c7 | j_mayer | #else
|
66 | d656469f | bellard | #define REGPARM
|
67 | df2542c7 | j_mayer | #endif
|
68 | df2542c7 | j_mayer | |
69 | d62ca2bb | bellard | #define qemu_printf printf
|
70 | ea88812f | bellard | |
71 | 80fe30ed | balrog | #if defined (__GNUC__) && defined (__GNUC_MINOR__)
|
72 | bad5b1ec | aurel32 | # define QEMU_GNUC_PREREQ(maj, min) \
|
73 | bad5b1ec | aurel32 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) |
74 | bad5b1ec | aurel32 | #else
|
75 | bad5b1ec | aurel32 | # define QEMU_GNUC_PREREQ(maj, min) 0 |
76 | bad5b1ec | aurel32 | #endif
|
77 | bad5b1ec | aurel32 | |
78 | 33f00271 | balrog | void *qemu_memalign(size_t alignment, size_t size);
|
79 | 49b470eb | bellard | void *qemu_vmalloc(size_t size);
|
80 | 49b470eb | bellard | void qemu_vfree(void *ptr); |
81 | ea88812f | bellard | |
82 | aa26bb2d | ths | int qemu_create_pidfile(const char *filename); |
83 | aa26bb2d | ths | |
84 | 29b3a662 | pbrook | #ifdef _WIN32
|
85 | c6d29ad6 | balrog | int ffs(int i); |
86 | c6d29ad6 | balrog | |
87 | 29b3a662 | pbrook | typedef struct { |
88 | 29b3a662 | pbrook | long tv_sec;
|
89 | 29b3a662 | pbrook | long tv_usec;
|
90 | 29b3a662 | pbrook | } qemu_timeval; |
91 | 29b3a662 | pbrook | int qemu_gettimeofday(qemu_timeval *tp);
|
92 | 29b3a662 | pbrook | #else
|
93 | 29b3a662 | pbrook | typedef struct timeval qemu_timeval; |
94 | 29b3a662 | pbrook | #define qemu_gettimeofday(tp) gettimeofday(tp, NULL); |
95 | 29b3a662 | pbrook | #endif /* !_WIN32 */ |
96 | 29b3a662 | pbrook | |
97 | ea88812f | bellard | #endif |