Prefix CONTAINER_OF with UC_

This commit is contained in:
Nils O. Selåsdal
2013-09-28 23:45:51 +02:00
parent ff0fd32ae1
commit dd517a5d85
8 changed files with 29 additions and 19 deletions
+3 -3
View File
@@ -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) ); })