Commit c9689ca3 authored by Simon Glass's avatar Simon Glass
Browse files

Add a way of checking the position of a structure member

U-Boot uses structures for hardware access so it is important that these
structures are correct. Add a way of asserting that a structure member is
at a particular offset. This can be created using the datasheet for the

This implementation uses Static_assert() since BUILD_BUG_ON() only works
within functions.

Signed-off-by: default avatarSimon Glass <>
parent 4eae498e
......@@ -1010,6 +1010,17 @@ int cpu_release(int nr, int argc, char * const argv[]);
#define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) \
* check_member() - Check the offset of a structure member
* @structure: Name of structure (e.g. global_data)
* @member: Name of member (e.g. baudrate)
* @offset: Expected offset in bytes
#define check_member(structure, member, offset) _Static_assert( \
offsetof(struct structure, member) == offset, \
"`struct " #structure "` offset for `" #member "` is not " #offset)
/* Pull in stuff for the build system */
# include <environment.h>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment