8 #include <sys/signal.h>
16 #define xglue(x, y) x ## y
17 #define glue(x, y) xglue(x, y)
18 #define stringify(s) tostring(s)
19 #define tostring(s) #s
24 #define __builtin_expect(x, n) (x)
27 #define likely(x) __builtin_expect(!!(x), 1)
28 #define unlikely(x) __builtin_expect(!!(x), 0)
31 #ifdef CONFIG_NEED_OFFSETOF
32 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
35 #define container_of(ptr, type, member) ({ \
36 const typeof(((type *) 0)->member) *__mptr = (ptr); \
37 (type *) ((char *) __mptr - offsetof(type, member));})
40 #define typeof_field(type, field) typeof(((type *)0)->field)
41 #define type_check(t1,t2) ((t1*)0 - (t2*)0)
44 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
47 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
51 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
55 #if !((__GNUC__ < 3) || defined(__APPLE__))
57 #define inline __attribute__ (( always_inline )) __inline__
61 #define inline always_inline
65 #define REGPARM __attribute((regparm(3)))
70 #define qemu_printf printf
72 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
73 # define QEMU_GNUC_PREREQ(maj, min) \
74 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
76 # define QEMU_GNUC_PREREQ(maj, min) 0
79 void *qemu_memalign(size_t alignment
, size_t size
);
80 void *qemu_vmalloc(size_t size
);
81 void qemu_vfree(void *ptr
);
83 int qemu_create_pidfile(const char *filename
);
92 int qemu_gettimeofday(qemu_timeval
*tp
);
94 typedef struct timeval qemu_timeval
;
95 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);