7 #include <sys/signal.h>
15 #define xglue(x, y) x ## y
16 #define glue(x, y) xglue(x, y)
17 #define stringify(s) tostring(s)
18 #define tostring(s) #s
23 #define __builtin_expect(x, n) (x)
26 #define likely(x) __builtin_expect(!!(x), 1)
27 #define unlikely(x) __builtin_expect(!!(x), 0)
31 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
34 #define container_of(ptr, type, member) ({ \
35 const typeof(((type *) 0)->member) *__mptr = (ptr); \
36 (type *) ((char *) __mptr - offsetof(type, member));})
40 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
43 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
47 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
51 #if (__GNUC__ < 3) || defined(__APPLE__)
52 #define always_inline inline
54 #define always_inline __attribute__ (( always_inline )) __inline__
56 #define inline always_inline
60 #define inline always_inline
64 #define REGPARM __attribute((regparm(3)))
69 #define qemu_printf printf
71 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
72 # define QEMU_GNUC_PREREQ(maj, min) \
73 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
75 # define QEMU_GNUC_PREREQ(maj, min) 0
78 void *qemu_memalign(size_t alignment
, size_t size
);
79 void *qemu_vmalloc(size_t size
);
80 void qemu_vfree(void *ptr
);
82 int qemu_create_pidfile(const char *filename
);
91 int qemu_gettimeofday(qemu_timeval
*tp
);
93 typedef struct timeval qemu_timeval
;
94 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);