7 #include <sys/signal.h>
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
19 #define __builtin_expect(x, n) (x)
22 #define likely(x) __builtin_expect(!!(x), 1)
23 #define unlikely(x) __builtin_expect(!!(x), 0)
27 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
30 #define container_of(ptr, type, member) ({ \
31 const typeof(((type *) 0)->member) *__mptr = (ptr); \
32 (type *) ((char *) __mptr - offsetof(type, member));})
36 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
39 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
43 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
47 #if (__GNUC__ < 3) || defined(__APPLE__)
48 #define always_inline inline
50 #define always_inline __attribute__ (( always_inline )) __inline__
52 #define inline always_inline
56 #define inline always_inline
60 #define REGPARM __attribute((regparm(3)))
65 #define qemu_printf printf
67 #if defined (__GNUC__) && defined (__GNUC_MINOR_)
68 # define QEMU_GNUC_PREREQ(maj, min) \
69 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
71 # define QEMU_GNUC_PREREQ(maj, min) 0
74 void *qemu_memalign(size_t alignment
, size_t size
);
75 void *qemu_vmalloc(size_t size
);
76 void qemu_vfree(void *ptr
);
78 int qemu_create_pidfile(const char *filename
);
87 int qemu_gettimeofday(qemu_timeval
*tp
);
89 typedef struct timeval qemu_timeval
;
90 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);