Prefix CONTAINER_OF with UC_
This commit is contained in:
@@ -46,14 +46,14 @@
|
||||
//a 'zap' member inside a struct foo.
|
||||
//give us the struct foo*:
|
||||
//struct foo *f = CONTAINER_OF(p, struct foo, zap);
|
||||
#define CONTAINER_OF(ptr, type, member) ({ \
|
||||
#define UC_CONTAINER_OF(ptr, type, member) ({ \
|
||||
typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)((void *)(unsigned char *)__mptr - offsetof(type, member) ); })
|
||||
|
||||
//the void* cast is to suppress alignment warnings
|
||||
|
||||
//Same as CONTAINER_OF, but for a const pointer to avoid gcc warnings..
|
||||
#define CONST_CONTAINER_OF(ptr, type, member) ({ \
|
||||
//Same as UC_CONTAINER_OF, but for a const pointer to avoid gcc warnings..
|
||||
#define UC_CONST_CONTAINER_OF(ptr, type, member) ({ \
|
||||
const typeof( ((const type *)0)->member ) *__mptr = (ptr); \
|
||||
(const type *)((const void *)(const unsigned char *)__mptr - offsetof(const type, member) ); })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user