2012-05-26 06:28:05 +02:00
|
|
|
/* Taken from include/linux/kernel.h from the Linux kernel tree */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* container_of - cast a member of a structure out to the containing structure
|
|
|
|
* @ptr: the pointer to the member.
|
|
|
|
* @type: the type of the container struct this is embedded in.
|
|
|
|
* @member: the name of the member within the struct.
|
|
|
|
*
|
|
|
|
*/
|
2013-03-15 12:09:19 +01:00
|
|
|
|
|
|
|
#ifndef PIOS_STRUCT_HELPER_H
|
|
|
|
#define PIOS_STRUCT_HELPER_H
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
#define container_of(ptr, type, member) \
|
|
|
|
({ \
|
|
|
|
const typeof(((type *)0)->member) * __mptr = (ptr); \
|
|
|
|
(type *)((char *)__mptr - offsetof(type, member)); } \
|
|
|
|
)
|
2013-03-15 12:09:19 +01:00
|
|
|
|
|
|
|
#endif /* PIOS_STRUCT_HELPER_H */
|