Add pci_find_bus
[qemu-kvm/fedora.git] / osdep.h
blob0666e78b3ffff6a674dc88e584c860d62be52eac
1 #ifndef QEMU_OSDEP_H
2 #define QEMU_OSDEP_H
4 #include <stdarg.h>
6 #ifndef glue
7 #define xglue(x, y) x ## y
8 #define glue(x, y) xglue(x, y)
9 #define stringify(s) tostring(s)
10 #define tostring(s) #s
11 #endif
13 #ifndef likely
14 #if __GNUC__ < 3
15 #define __builtin_expect(x, n) (x)
16 #endif
18 #define likely(x) __builtin_expect(!!(x), 1)
19 #define unlikely(x) __builtin_expect(!!(x), 0)
20 #endif
22 #ifndef MIN
23 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
24 #endif
25 #ifndef MAX
26 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
27 #endif
29 #ifndef always_inline
30 #if (__GNUC__ < 3) || defined(__APPLE__)
31 #define always_inline inline
32 #else
33 #define always_inline __attribute__ (( always_inline )) __inline__
34 #endif
35 #endif
36 #define inline always_inline
38 #ifdef __i386__
39 #define REGPARM __attribute((regparm(3)))
40 #else
41 #define REGPARM
42 #endif
44 #define qemu_printf printf
46 void *qemu_malloc(size_t size);
47 void *qemu_mallocz(size_t size);
48 void qemu_free(void *ptr);
49 char *qemu_strdup(const char *str);
51 void *qemu_memalign(size_t alignment, size_t size);
52 void *qemu_vmalloc(size_t size);
53 void qemu_vfree(void *ptr);
55 void *get_mmap_addr(unsigned long size);
57 int qemu_create_pidfile(const char *filename);
59 #ifdef _WIN32
60 int ffs(int i);
62 typedef struct {
63 long tv_sec;
64 long tv_usec;
65 } qemu_timeval;
66 int qemu_gettimeofday(qemu_timeval *tp);
67 #else
68 typedef struct timeval qemu_timeval;
69 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
70 #endif /* !_WIN32 */
72 #endif