summaryrefslogtreecommitdiff
path: root/include/libk/container_of.h
blob: fdc400ce0ec35bec7db5b2641027261e4361fd0e (plain)
1
2
3
4
5
6
7
8
9
10
#ifndef LIBK_CONTAINER_OF_H
#define LIBK_CONTAINER_OF_H

#ifndef container_of
#define container_of(ptr, type, member) ({                              \
                const typeof(((type*)0)->member)*__mptr = (ptr);        \
                (type*)((char*)__mptr - offsetof(type, member)); })
#endif

#endif