root / osdep.h @ d656469f
History | View | Annotate | Download (1.4 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 | df2542c7 | j_mayer | #ifndef always_inline
|
30 | df2542c7 | j_mayer | #if (__GNUC__ < 3) || defined(__APPLE__) |
31 | df2542c7 | j_mayer | #define always_inline inline |
32 | df2542c7 | j_mayer | #else
|
33 | df2542c7 | j_mayer | #define always_inline __attribute__ (( always_inline )) __inline__
|
34 | df2542c7 | j_mayer | #endif
|
35 | df2542c7 | j_mayer | #endif
|
36 | df2542c7 | j_mayer | #define inline always_inline |
37 | df2542c7 | j_mayer | |
38 | df2542c7 | j_mayer | #ifdef __i386__
|
39 | d656469f | bellard | #define REGPARM __attribute((regparm(3))) |
40 | df2542c7 | j_mayer | #else
|
41 | d656469f | bellard | #define REGPARM
|
42 | df2542c7 | j_mayer | #endif
|
43 | df2542c7 | j_mayer | |
44 | d62ca2bb | bellard | #define qemu_printf printf
|
45 | ea88812f | bellard | |
46 | ea88812f | bellard | void *qemu_malloc(size_t size);
|
47 | 0fb48229 | bellard | void *qemu_mallocz(size_t size);
|
48 | ea88812f | bellard | void qemu_free(void *ptr); |
49 | 2571929a | bellard | char *qemu_strdup(const char *str); |
50 | 49b470eb | bellard | |
51 | 33f00271 | balrog | void *qemu_memalign(size_t alignment, size_t size);
|
52 | 49b470eb | bellard | void *qemu_vmalloc(size_t size);
|
53 | 49b470eb | bellard | void qemu_vfree(void *ptr); |
54 | ea88812f | bellard | |
55 | ea88812f | bellard | void *get_mmap_addr(unsigned long size); |
56 | ea88812f | bellard | |
57 | aa26bb2d | ths | int qemu_create_pidfile(const char *filename); |
58 | aa26bb2d | ths | |
59 | 29b3a662 | pbrook | #ifdef _WIN32
|
60 | c6d29ad6 | balrog | int ffs(int i); |
61 | c6d29ad6 | balrog | |
62 | 29b3a662 | pbrook | typedef struct { |
63 | 29b3a662 | pbrook | long tv_sec;
|
64 | 29b3a662 | pbrook | long tv_usec;
|
65 | 29b3a662 | pbrook | } qemu_timeval; |
66 | 29b3a662 | pbrook | int qemu_gettimeofday(qemu_timeval *tp);
|
67 | 29b3a662 | pbrook | #else
|
68 | 29b3a662 | pbrook | typedef struct timeval qemu_timeval; |
69 | 29b3a662 | pbrook | #define qemu_gettimeofday(tp) gettimeofday(tp, NULL); |
70 | 29b3a662 | pbrook | #endif /* !_WIN32 */ |
71 | 29b3a662 | pbrook | |
72 | ea88812f | bellard | #endif |