diff options
author | Furquan Shaikh <furquan@chromium.org> | 2017-04-19 19:25:52 -0700 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-04-24 19:27:35 +0200 |
commit | 10d1fde5756d9535b2301806c01d0b029661eddc (patch) | |
tree | 88bc97dc2dcf2bcbed70aeabb62163469b4664f8 /src/commonlib/include | |
parent | 4d74836488ac1deb32da0abe0a887cfbe1c33ba4 (diff) |
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>
Diffstat (limited to 'src/commonlib/include')
-rw-r--r-- | src/commonlib/include/commonlib/helpers.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/commonlib/include/commonlib/helpers.h b/src/commonlib/include/commonlib/helpers.h index d2ef94196d..0a796ba85b 100644 --- a/src/commonlib/include/commonlib/helpers.h +++ b/src/commonlib/include/commonlib/helpers.h @@ -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 |