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