Add container_of() macro

This will allow to get the parent of an embedded struct.
This commit is contained in:
Romain Vimont 2021-04-11 15:01:05 +02:00
parent 2ddf760c09
commit 08f1fd46c8

View file

@ -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