Commit ac509d88877c07bb06497206d74a2baa25b6d895
1 parent
2acf5af0
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
Showing
5 changed files
with
7 additions
and
18 deletions
block-qcow2.c
exec-all.h
| ... | ... | @@ -256,10 +256,6 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, |
| 256 | 256 | |
| 257 | 257 | TranslationBlock *tb_find_pc(unsigned long pc_ptr); |
| 258 | 258 | |
| 259 | -#ifndef offsetof | |
| 260 | -#define offsetof(type, field) ((size_t) &((type *)0)->field) | |
| 261 | -#endif | |
| 262 | - | |
| 263 | 259 | #if defined(_WIN32) |
| 264 | 260 | #define ASM_DATA_SECTION ".section \".data\"\n" |
| 265 | 261 | #define ASM_PREVIOUS_SECTION ".section .text\n" | ... | ... |
linux-user/signal.c
| ... | ... | @@ -549,10 +549,6 @@ int do_sigaction(int sig, const struct target_sigaction *act, |
| 549 | 549 | return ret; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | -#ifndef offsetof | |
| 553 | -#define offsetof(type, field) ((size_t) &((type *)0)->field) | |
| 554 | -#endif | |
| 555 | - | |
| 556 | 552 | static inline int copy_siginfo_to_user(target_siginfo_t *tinfo, |
| 557 | 553 | const target_siginfo_t *info) |
| 558 | 554 | { | ... | ... |
monitor.c
osdep.h
| ... | ... | @@ -23,9 +23,14 @@ |
| 23 | 23 | #define unlikely(x) __builtin_expect(!!(x), 0) |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | +#ifndef offsetof | |
| 27 | +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) | |
| 28 | +#endif | |
| 29 | +#ifndef container_of | |
| 26 | 30 | #define container_of(ptr, type, member) ({ \ |
| 27 | - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | |
| 28 | - (type *)( (char *)__mptr - offsetof(type,member) );}) | |
| 31 | + const typeof(((type *) 0)->member) *__mptr = (ptr); \ | |
| 32 | + (type *) ((char *) __mptr - offsetof(type, member));}) | |
| 33 | +#endif | |
| 29 | 34 | |
| 30 | 35 | #ifndef MIN |
| 31 | 36 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | ... | ... |