Commit | Line | Data |
---|---|---|
ccd7e1c8 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
ccd7e1c8 | 3 | * |
0235b0db | 4 | * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
ccd7e1c8 MD |
5 | */ |
6 | ||
0235b0db MJ |
7 | #ifndef _BABELTRACE_COMPILER_H |
8 | #define _BABELTRACE_COMPILER_H | |
9 | ||
334c0a83 MD |
10 | #include <stddef.h> /* for offsetof */ |
11 | ||
d79865b9 MD |
12 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) |
13 | ||
fc93b2bd MD |
14 | #ifndef container_of |
15 | #define container_of(ptr, type, member) \ | |
16 | ({ \ | |
17 | const typeof(((type *)NULL)->member) * __ptr = (ptr); \ | |
18 | (type *)((char *)__ptr - offsetof(type, member)); \ | |
19 | }) | |
20 | #endif | |
21 | ||
6e1bc0df MD |
22 | #define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
23 | ||
d79865b9 | 24 | #endif /* _BABELTRACE_COMPILER_H */ |