]> git.proxmox.com Git - qemu.git/blame - osdep.h
Correct the max cpuid level for each x86 cpu model (Dan Kenigsberg).
[qemu.git] / osdep.h
CommitLineData
ea88812f
FB
1#ifndef QEMU_OSDEP_H
2#define QEMU_OSDEP_H
3
4#include <stdarg.h>
5
df2542c7
JM
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
12
13#ifndef likely
14#if __GNUC__ < 3
15#define __builtin_expect(x, n) (x)
16#endif
17
18#define likely(x) __builtin_expect(!!(x), 1)
19#define unlikely(x) __builtin_expect(!!(x), 0)
20#endif
21
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
28
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
37
38#ifdef __i386__
39#define REGPARM(n) __attribute((regparm(n)))
40#else
41#define REGPARM(n)
42#endif
43
d62ca2bb 44#define qemu_printf printf
ea88812f
FB
45
46void *qemu_malloc(size_t size);
0fb48229 47void *qemu_mallocz(size_t size);
ea88812f 48void qemu_free(void *ptr);
2571929a 49char *qemu_strdup(const char *str);
49b470eb
FB
50
51void *qemu_vmalloc(size_t size);
52void qemu_vfree(void *ptr);
ea88812f
FB
53
54void *get_mmap_addr(unsigned long size);
55
aa26bb2d
TS
56int qemu_create_pidfile(const char *filename);
57
29b3a662 58#ifdef _WIN32
c6d29ad6
AZ
59int ffs(int i);
60
29b3a662
PB
61typedef struct {
62 long tv_sec;
63 long tv_usec;
64} qemu_timeval;
65int qemu_gettimeofday(qemu_timeval *tp);
66#else
67typedef struct timeval qemu_timeval;
68#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
69#endif /* !_WIN32 */
70
ea88812f 71#endif