2004-02-16 23:12:40 +01:00
|
|
|
#ifndef QEMU_OSDEP_H
|
|
|
|
#define QEMU_OSDEP_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2007-11-19 01:38:33 +01:00
|
|
|
#ifndef glue
|
|
|
|
#define xglue(x, y) x ## y
|
|
|
|
#define glue(x, y) xglue(x, y)
|
|
|
|
#define stringify(s) tostring(s)
|
|
|
|
#define tostring(s) #s
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef likely
|
|
|
|
#if __GNUC__ < 3
|
|
|
|
#define __builtin_expect(x, n) (x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define likely(x) __builtin_expect(!!(x), 1)
|
|
|
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef always_inline
|
|
|
|
#if (__GNUC__ < 3) || defined(__APPLE__)
|
|
|
|
#define always_inline inline
|
|
|
|
#else
|
|
|
|
#define always_inline __attribute__ (( always_inline )) __inline__
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#define inline always_inline
|
|
|
|
|
|
|
|
#ifdef __i386__
|
|
|
|
#define REGPARM(n) __attribute((regparm(n)))
|
|
|
|
#else
|
|
|
|
#define REGPARM(n)
|
|
|
|
#endif
|
|
|
|
|
2006-08-01 17:50:14 +02:00
|
|
|
#define qemu_printf printf
|
2004-02-16 23:12:40 +01:00
|
|
|
|
|
|
|
void *qemu_malloc(size_t size);
|
2004-03-14 22:48:47 +01:00
|
|
|
void *qemu_mallocz(size_t size);
|
2004-02-16 23:12:40 +01:00
|
|
|
void qemu_free(void *ptr);
|
2004-07-14 19:21:57 +02:00
|
|
|
char *qemu_strdup(const char *str);
|
2005-02-10 22:59:25 +01:00
|
|
|
|
2007-12-24 15:33:24 +01:00
|
|
|
void *qemu_memalign(size_t alignment, size_t size);
|
2005-02-10 22:59:25 +01:00
|
|
|
void *qemu_vmalloc(size_t size);
|
|
|
|
void qemu_vfree(void *ptr);
|
2004-02-16 23:12:40 +01:00
|
|
|
|
|
|
|
void *get_mmap_addr(unsigned long size);
|
|
|
|
|
2007-03-25 23:33:06 +02:00
|
|
|
int qemu_create_pidfile(const char *filename);
|
|
|
|
|
2007-06-08 01:09:47 +02:00
|
|
|
#ifdef _WIN32
|
2007-12-16 13:55:24 +01:00
|
|
|
int ffs(int i);
|
|
|
|
|
2007-06-08 01:09:47 +02:00
|
|
|
typedef struct {
|
|
|
|
long tv_sec;
|
|
|
|
long tv_usec;
|
|
|
|
} qemu_timeval;
|
|
|
|
int qemu_gettimeofday(qemu_timeval *tp);
|
|
|
|
#else
|
|
|
|
typedef struct timeval qemu_timeval;
|
|
|
|
#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
|
|
|
|
#endif /* !_WIN32 */
|
|
|
|
|
2004-02-16 23:12:40 +01:00
|
|
|
#endif
|