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 <sjg@chromium.org>
This commit is contained in:
parent
db41d65a97
commit
825faebbdf
@ -73,17 +73,6 @@
|
|||||||
|
|
||||||
#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
|
#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1))
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 */
|
/* Pull in stuff for the build system */
|
||||||
#ifdef DO_DEPS_ONLY
|
#ifdef DO_DEPS_ONLY
|
||||||
# include <env_internal.h>
|
# include <env_internal.h>
|
||||||
|
@ -268,4 +268,15 @@
|
|||||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
(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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user