From e319aaa0cf489488d7796b6abea7f88a21d6e07f Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 19 Jul 2018 15:47:30 +0300 Subject: [PATCH] compiler: Add FIELD_SIZEOF helper Signed-off-by: Cyrill Gorcunov Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andrei Vagin --- include/common/compiler.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/common/compiler.h b/include/common/compiler.h index ada79f293..eaf545b26 100644 --- a/include/common/compiler.h +++ b/include/common/compiler.h @@ -57,6 +57,10 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +#ifndef FIELD_SIZEOF +# define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#endif + #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) #define round_down(x, y) ((x) & ~__round_mask(x, y))