From 825faebbdfc9bcd3e6e6ac3d8f7b321deb43a94e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 28 Dec 2019 10:45:08 -0700 Subject: common: Move check_member() to kernel.h The kernel.h file has a number of useful macros including a few related to structures. Move check_member() there too. Signed-off-by: Simon Glass --- include/linux/kernel.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/linux/kernel.h') diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 564819a1c0..fefbc07375 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -268,4 +268,15 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +/* + * 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) + #endif -- cgit v1.2.3