Skip to content

Commit

Permalink
tools headers: Syncronize linux/build_bug.h with the kernel sources
Browse files Browse the repository at this point in the history
To pick up the changes in:

  07a368b ("bug: introduce ASSERT_STRUCT_OFFSET")

This cset only introduces a build time assert macro, that may be useful
at some point for tooling, for now it silences this perf build warning:

  Warning: Kernel ABI header at 'tools/include/linux/build_bug.h' differs from latest version at 'include/linux/build_bug.h'
  diff -u tools/include/linux/build_bug.h include/linux/build_bug.h

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Link: http://lore.kernel.org/lkml/Y8f0jqQFYDAOBkHx@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 18, 2023
1 parent d352588 commit c905ecf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/include/linux/build_bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit c905ecf

Please sign in to comment.