aboutsummaryrefslogtreecommitdiffstats
path: root/misc.h
blob: 98c645504831ebbaf4d096473ca7a9e18cd61953 (plain)
1
2
3
4
5
6
7
8
9
10
/*
 * misc useful #defines ...
 */
#include <stddef.h>

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

#define array_size(x) (sizeof(x)/sizeof(x[0]))