kvm: bios: fix SMBIOS end address range reporting
[qemu-kvm/fedora.git] / osdep.h
blob9e8547cea41667e59069334902fe5e1522ba1afc
1 #ifndef QEMU_OSDEP_H
2 #define QEMU_OSDEP_H
4 #include <stdarg.h>
5 #ifdef __OpenBSD__
6 #include <sys/types.h>
7 #include <sys/signal.h>
8 #endif
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
17 #ifndef likely
18 #if __GNUC__ < 3
19 #define __builtin_expect(x, n) (x)
20 #endif
22 #define likely(x) __builtin_expect(!!(x), 1)
23 #define unlikely(x) __builtin_expect(!!(x), 0)
24 #endif
26 #ifndef offsetof
27 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
28 #endif
29 #ifndef container_of
30 #define container_of(ptr, type, member) ({ \
31 const typeof(((type *) 0)->member) *__mptr = (ptr); \
32 (type *) ((char *) __mptr - offsetof(type, member));})
33 #endif
35 #ifndef MIN
36 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
37 #endif
38 #ifndef MAX
39 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
40 #endif
42 #ifndef ARRAY_SIZE
43 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44 #endif
46 #ifndef always_inline
47 #if (__GNUC__ < 3) || defined(__APPLE__)
48 #define always_inline inline
49 #else
50 #define always_inline __attribute__ (( always_inline )) __inline__
51 #define inline always_inline
52 #endif
53 #else
54 #define inline always_inline
55 #endif
57 #ifdef __i386__
58 #define REGPARM __attribute((regparm(3)))
59 #else
60 #define REGPARM
61 #endif
63 #define qemu_printf printf
65 void *qemu_memalign(size_t alignment, size_t size);
66 void *qemu_vmalloc(size_t size);
67 void qemu_vfree(void *ptr);
69 int qemu_create_pidfile(const char *filename);
71 #ifdef _WIN32
72 int ffs(int i);
74 typedef struct {
75 long tv_sec;
76 long tv_usec;
77 } qemu_timeval;
78 int qemu_gettimeofday(qemu_timeval *tp);
79 #else
80 typedef struct timeval qemu_timeval;
81 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
82 #endif /* !_WIN32 */
84 #endif