From 654bfae6f71584c71d064bc8e88d069b54db5fbc Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 17 Jun 2009 14:17:40 +0200 Subject: [PATCH] util: add fieldsizeof and fieldtypeof macros Signed-off-by: Julien Danjou --- common/util.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/util.h b/common/util.h index 6d2c23cd..5353d160 100644 --- a/common/util.h +++ b/common/util.h @@ -80,6 +80,8 @@ typedef struct #define ssizeof(foo) (ssize_t)sizeof(foo) #define countof(foo) (ssizeof(foo) / ssizeof(foo[0])) +#define fieldsizeof(type_t, m) sizeof(((type_t *)0)->m) +#define fieldtypeof(type_t, m) typeof(((type_t *)0)->m) #define p_alloca(type, count) \ ((type *)memset(alloca(sizeof(type) * (count)), \