Add container_of() macro
This will allow to get the parent of an embedded struct.
This commit is contained in:
parent
2ddf760c09
commit
08f1fd46c8
1 changed files with 3 additions and 0 deletions
|
@ -8,4 +8,7 @@
|
|||
#define MIN(X,Y) (X) < (Y) ? (X) : (Y)
|
||||
#define MAX(X,Y) (X) > (Y) ? (X) : (Y)
|
||||
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *) (((char *) (ptr)) - offsetof(type, member)))
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue