Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define _MACROS_H
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include <common/compat/string.h>
#define ARRAY_SIZE(array) (sizeof(array) / (sizeof((array)[0])))
#endif
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)NULL)->member) * __ptr = (ptr); \
+ (type *)((char *)__ptr - offsetof(type, member)); \
+ })
+#endif
+
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif