dm: types: add container_of macro

Add standard container_of macro to access
the parent struct pointer.

Tracked-On: #1536
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Tomas Winkler 2018-10-19 09:20:49 +03:00 committed by wenlingz
parent 4e057c32d2
commit 6a96878e0b

View File

@ -18,6 +18,11 @@ typedef uint64_t cap_ioctl_t;
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define container_of(ptr, type, member) ({ \
const typeof(((type *)0)->member) * __mptr = (ptr); \
(type *)((char *)__mptr - (offsetof(type, member))); \
})
#define __aligned(x) __attribute__((aligned(x)))
#define __section(x) __attribute__((__section__(x)))
#define __MAKE_SET(set, sym) \