osdep.h: Move some compiler-specific things to compiler.h
osdep.h has a few things which are really compiler specific; move them to compiler.h, and include compiler.h from osdep.h. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
71baf787d8
commit
4912086865
@ -42,6 +42,53 @@
|
|||||||
# define QEMU_PACKED __attribute__((packed))
|
# define QEMU_PACKED __attribute__((packed))
|
||||||
#endif
|
#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
|
||||||
|
|
||||||
|
#ifndef container_of
|
||||||
|
#define container_of(ptr, type, member) ({ \
|
||||||
|
const typeof(((type *) 0)->member) *__mptr = (ptr); \
|
||||||
|
(type *) ((char *) __mptr - offsetof(type, member));})
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Convert from a base type to a parent type, with compile time checking. */
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
|
||||||
|
char __attribute__((unused)) offset_must_be_zero[ \
|
||||||
|
-offsetof(type, field)]; \
|
||||||
|
container_of(dev, type, field);}))
|
||||||
|
#else
|
||||||
|
#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define typeof_field(type, field) typeof(((type *)0)->field)
|
||||||
|
#define type_check(t1,t2) ((t1*)0 - (t2*)0)
|
||||||
|
|
||||||
|
#ifndef always_inline
|
||||||
|
#if !((__GNUC__ < 3) || defined(__APPLE__))
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#undef inline
|
||||||
|
#define inline __attribute__ (( always_inline )) __inline__
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#undef inline
|
||||||
|
#define inline always_inline
|
||||||
|
#endif
|
||||||
|
|
||||||
#define cat(x,y) x ## y
|
#define cat(x,y) x ## y
|
||||||
#define cat2(x,y) cat(x,y)
|
#define cat2(x,y) cat(x,y)
|
||||||
#define QEMU_BUILD_BUG_ON(x) \
|
#define QEMU_BUILD_BUG_ON(x) \
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define QEMU_OSDEP_H
|
#define QEMU_OSDEP_H
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
#include "qemu/compiler.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -27,41 +28,6 @@ typedef unsigned int uint_fast16_t;
|
|||||||
typedef signed int int_fast16_t;
|
typedef signed int int_fast16_t;
|
||||||
#endif
|
#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
|
|
||||||
|
|
||||||
#ifndef container_of
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
|
||||||
const typeof(((type *) 0)->member) *__mptr = (ptr); \
|
|
||||||
(type *) ((char *) __mptr - offsetof(type, member));})
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convert from a base type to a parent type, with compile time checking. */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define DO_UPCAST(type, field, dev) ( __extension__ ( { \
|
|
||||||
char __attribute__((unused)) offset_must_be_zero[ \
|
|
||||||
-offsetof(type, field)]; \
|
|
||||||
container_of(dev, type, field);}))
|
|
||||||
#else
|
|
||||||
#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define typeof_field(type, field) typeof(((type *)0)->field)
|
|
||||||
#define type_check(t1,t2) ((t1*)0 - (t2*)0)
|
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
@ -87,18 +53,6 @@ typedef signed int int_fast16_t;
|
|||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef always_inline
|
|
||||||
#if !((__GNUC__ < 3) || defined(__APPLE__))
|
|
||||||
#ifdef __OPTIMIZE__
|
|
||||||
#undef inline
|
|
||||||
#define inline __attribute__ (( always_inline )) __inline__
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#undef inline
|
|
||||||
#define inline always_inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int qemu_daemon(int nochdir, int noclose);
|
int qemu_daemon(int nochdir, int noclose);
|
||||||
void *qemu_try_memalign(size_t alignment, size_t size);
|
void *qemu_try_memalign(size_t alignment, size_t size);
|
||||||
void *qemu_memalign(size_t alignment, size_t size);
|
void *qemu_memalign(size_t alignment, size_t size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user