diff options
| author | Takashi Iwai <tiwai@suse.de> | 2023-03-03 14:20:56 +0100 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2023-03-03 14:20:56 +0100 |
| commit | 26ed1d29fc44f3f2f0c396c1392abefac5f0454e (patch) | |
| tree | ffba9ebddf759f04cbeca8adace5cc8093c58c2d /tools/include/linux/build_bug.h | |
| parent | e97fc9cffbb9f372b53b42c36cd7b20aab44a554 (diff) | |
| parent | 7933b90b42896f5b6596e6a829bb31c5121fc2a9 (diff) | |
Merge branch 'for-next' into for-linus
Diffstat (limited to 'tools/include/linux/build_bug.h')
| -rw-r--r-- | tools/include/linux/build_bug.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/include/linux/build_bug.h b/tools/include/linux/build_bug.h index cc7070c7439b..b4898ff085de 100644 --- a/tools/include/linux/build_bug.h +++ b/tools/include/linux/build_bug.h @@ -79,4 +79,13 @@ #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) #endif // static_assert + +/* + * Compile time check that field has an expected offset + */ +#define ASSERT_STRUCT_OFFSET(type, field, expected_offset) \ + BUILD_BUG_ON_MSG(offsetof(type, field) != (expected_offset), \ + "Offset of " #field " in " #type " has changed.") + + #endif /* _LINUX_BUILD_BUG_H */ |
