62a6e3e19a
From linux kernel sources, xen bits will use it, put it into a place where others can see and use it too ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5057 c046a42c-6fe2-441c-8c8c-71466251a162
80 lines
1.6 KiB
C
80 lines
1.6 KiB
C
#ifndef QEMU_OSDEP_H
|
|
#define QEMU_OSDEP_H
|
|
|
|
#include <stdarg.h>
|
|
#ifdef __OpenBSD__
|
|
#include <sys/types.h>
|
|
#include <sys/signal.h>
|
|
#endif
|
|
|
|
#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
|
|
|
|
#define container_of(ptr, type, member) ({ \
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
#ifndef MIN
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
#endif
|
|
#ifndef MAX
|
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
#endif
|
|
|
|
#ifndef ARRAY_SIZE
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
#endif
|
|
|
|
#ifndef always_inline
|
|
#if (__GNUC__ < 3) || defined(__APPLE__)
|
|
#define always_inline inline
|
|
#else
|
|
#define always_inline __attribute__ (( always_inline )) __inline__
|
|
#define inline always_inline
|
|
#endif
|
|
#else
|
|
#define inline always_inline
|
|
#endif
|
|
|
|
#ifdef __i386__
|
|
#define REGPARM __attribute((regparm(3)))
|
|
#else
|
|
#define REGPARM
|
|
#endif
|
|
|
|
#define qemu_printf printf
|
|
|
|
void *qemu_memalign(size_t alignment, size_t size);
|
|
void *qemu_vmalloc(size_t size);
|
|
void qemu_vfree(void *ptr);
|
|
|
|
int qemu_create_pidfile(const char *filename);
|
|
|
|
#ifdef _WIN32
|
|
int ffs(int i);
|
|
|
|
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 */
|
|
|
|
#endif
|