From d712806b39d0c92082eba336fcfd9ea7708283f3 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 7 Sep 2022 10:18:44 +0000 Subject: [PATCH] lib/zt_common.h: add macro for determining field size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro `sizeof_field` is used in the next patch. Signed-off-by: Marc Hartmayer Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- include/lib/zt_common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/lib/zt_common.h b/include/lib/zt_common.h index 858d19cd..6dcfe18f 100644 --- a/include/lib/zt_common.h +++ b/include/lib/zt_common.h @@ -32,6 +32,10 @@ #ifndef __ASSEMBLER__ +#ifndef sizeof_field +#define sizeof_field(type, field) (sizeof((type *)0)->field) +#endif + #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused))