Permalink
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (13 sloc) 433 Bytes
#ifndef _SRC_COMMON_H_
#define _SRC_COMMON_H_
#ifndef offset_of
// g++ in strict mode complains loudly about the system offsetof() macro
// because it uses NULL as the base address.
# define offset_of(type, member) \
((intptr_t) ((char *) &(((type *) 8)->member) - 8))
#endif
#ifndef container_of
# define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offset_of(type, member)))
#endif
#endif // _SRC_COMMON_H_