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