Move offsetof to osdep.h, remove local defintions.
With this container_of can actually be used without causing build errors. Reformat container_of. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5234 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
2acf5af04d
commit
ac509d8887
|
@ -61,10 +61,6 @@
|
||||||
|
|
||||||
#define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */
|
#define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */
|
||||||
|
|
||||||
#ifndef offsetof
|
|
||||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct QCowHeader {
|
typedef struct QCowHeader {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
|
@ -256,10 +256,6 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
|
||||||
|
|
||||||
TranslationBlock *tb_find_pc(unsigned long pc_ptr);
|
TranslationBlock *tb_find_pc(unsigned long pc_ptr);
|
||||||
|
|
||||||
#ifndef offsetof
|
|
||||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define ASM_DATA_SECTION ".section \".data\"\n"
|
#define ASM_DATA_SECTION ".section \".data\"\n"
|
||||||
#define ASM_PREVIOUS_SECTION ".section .text\n"
|
#define ASM_PREVIOUS_SECTION ".section .text\n"
|
||||||
|
|
|
@ -549,10 +549,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef offsetof
|
|
||||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
|
static inline int copy_siginfo_to_user(target_siginfo_t *tinfo,
|
||||||
const target_siginfo_t *info)
|
const target_siginfo_t *info)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,10 +40,6 @@
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
//#define DEBUG_COMPLETION
|
//#define DEBUG_COMPLETION
|
||||||
|
|
||||||
#ifndef offsetof
|
|
||||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Supported types:
|
* Supported types:
|
||||||
*
|
*
|
||||||
|
|
9
osdep.h
9
osdep.h
|
@ -23,9 +23,14 @@
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef offsetof
|
||||||
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
|
||||||
|
#endif
|
||||||
|
#ifndef container_of
|
||||||
#define container_of(ptr, type, member) ({ \
|
#define container_of(ptr, type, member) ({ \
|
||||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
const typeof(((type *) 0)->member) *__mptr = (ptr); \
|
||||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
(type *) ((char *) __mptr - offsetof(type, member));})
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
Loading…
Reference in a new issue