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