File:  [Qemu by Fabrice Bellard] / qemu / osdep.h
Revision 1.1.1.5 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:50:43 2018 UTC (3 years, 3 months ago) by root
Branches: qemu, MAIN
CVS tags: qemu0111, qemu0110, qemu0105, qemu0104, qemu0103, qemu0102, qemu0101, qemu0100, HEAD
qemu 0.10.0

    1: #ifndef QEMU_OSDEP_H
    2: #define QEMU_OSDEP_H
    3: 
    4: #include <stdarg.h>
    5: #ifdef __OpenBSD__
    6: #include <sys/types.h>
    7: #include <sys/signal.h>
    8: #endif
    9: 
   10: #ifndef _WIN32
   11: #include <sys/time.h>
   12: #endif
   13: 
   14: #ifndef glue
   15: #define xglue(x, y) x ## y
   16: #define glue(x, y) xglue(x, y)
   17: #define stringify(s)	tostring(s)
   18: #define tostring(s)	#s
   19: #endif
   20: 
   21: #ifndef likely
   22: #if __GNUC__ < 3
   23: #define __builtin_expect(x, n) (x)
   24: #endif
   25: 
   26: #define likely(x)   __builtin_expect(!!(x), 1)
   27: #define unlikely(x)   __builtin_expect(!!(x), 0)
   28: #endif
   29: 
   30: #ifndef offsetof
   31: #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
   32: #endif
   33: #ifndef container_of
   34: #define container_of(ptr, type, member) ({                      \
   35:         const typeof(((type *) 0)->member) *__mptr = (ptr);     \
   36:         (type *) ((char *) __mptr - offsetof(type, member));})
   37: #endif
   38: 
   39: #ifndef MIN
   40: #define MIN(a, b) (((a) < (b)) ? (a) : (b))
   41: #endif
   42: #ifndef MAX
   43: #define MAX(a, b) (((a) > (b)) ? (a) : (b))
   44: #endif
   45: 
   46: #ifndef ARRAY_SIZE
   47: #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   48: #endif
   49: 
   50: #ifndef always_inline
   51: #if (__GNUC__ < 3) || defined(__APPLE__)
   52: #define always_inline inline
   53: #else
   54: #define always_inline __attribute__ (( always_inline )) __inline__
   55: #ifdef __OPTIMIZE__
   56: #define inline always_inline
   57: #endif
   58: #endif
   59: #else
   60: #define inline always_inline
   61: #endif
   62: 
   63: #ifdef __i386__
   64: #define REGPARM __attribute((regparm(3)))
   65: #else
   66: #define REGPARM
   67: #endif
   68: 
   69: #define qemu_printf printf
   70: 
   71: #if defined (__GNUC__) && defined (__GNUC_MINOR__)
   72: # define QEMU_GNUC_PREREQ(maj, min) \
   73:          ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
   74: #else
   75: # define QEMU_GNUC_PREREQ(maj, min) 0
   76: #endif
   77: 
   78: void *qemu_memalign(size_t alignment, size_t size);
   79: void *qemu_vmalloc(size_t size);
   80: void qemu_vfree(void *ptr);
   81: 
   82: int qemu_create_pidfile(const char *filename);
   83: 
   84: #ifdef _WIN32
   85: int ffs(int i);
   86: 
   87: typedef struct {
   88:     long tv_sec;
   89:     long tv_usec;
   90: } qemu_timeval;
   91: int qemu_gettimeofday(qemu_timeval *tp);
   92: #else
   93: typedef struct timeval qemu_timeval;
   94: #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
   95: #endif /* !_WIN32 */
   96: 
   97: #endif

unix.superglobalmegacorp.com