commonlib/helpers: Add helper macro for member_size

member_size macro provides the size of a structure member.

Change-Id: I53e9c9bf70b3ebed0d15e8258111b17e50667a74
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/19384
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins)
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Furquan Shaikh 2017-04-19 19:25:52 -07:00 committed by Martin Roth
parent 4d74836488
commit 10d1fde575
1 changed files with 3 additions and 0 deletions

View File

@ -85,6 +85,9 @@
const __typeof__(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); })
/* Calculate size of structure member. */
#define member_size(type, member) (sizeof(((type *)0)->member))
#ifndef __unused
#define __unused __attribute__((unused))
#endif