Commit | Line | Data |
---|---|---|
d79865b9 MD |
1 | #ifndef _BABELTRACE_COMPILER_H |
2 | #define _BABELTRACE_COMPILER_H | |
3 | ||
334c0a83 MD |
4 | #include <stddef.h> /* for offsetof */ |
5 | ||
d79865b9 MD |
6 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) |
7 | ||
fc93b2bd MD |
8 | #ifndef container_of |
9 | #define container_of(ptr, type, member) \ | |
10 | ({ \ | |
11 | const typeof(((type *)NULL)->member) * __ptr = (ptr); \ | |
12 | (type *)((char *)__ptr - offsetof(type, member)); \ | |
13 | }) | |
14 | #endif | |
15 | ||
d79865b9 | 16 | #endif /* _BABELTRACE_COMPILER_H */ |