diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-16 13:36:57 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-16 13:36:57 +0000 |
commit | ac509d88877c07bb06497206d74a2baa25b6d895 (patch) | |
tree | 1146602c5a370fd479b139f72746e598c7a7178a /osdep.h | |
parent | 2acf5af04daf02723a4ba1b720a53b6e718023f4 (diff) | |
download | qemu-ac509d88877c07bb06497206d74a2baa25b6d895.zip qemu-ac509d88877c07bb06497206d74a2baa25b6d895.tar.gz qemu-ac509d88877c07bb06497206d74a2baa25b6d895.tar.bz2 |
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
Diffstat (limited to 'osdep.h')
-rw-r--r-- | osdep.h | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -23,9 +23,14 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) +#endif +#ifndef container_of #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |