util: add fieldsizeof and fieldtypeof macros
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d088b819f9
commit
654bfae6f7
|
@ -80,6 +80,8 @@ typedef struct
|
||||||
|
|
||||||
#define ssizeof(foo) (ssize_t)sizeof(foo)
|
#define ssizeof(foo) (ssize_t)sizeof(foo)
|
||||||
#define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
|
#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) \
|
#define p_alloca(type, count) \
|
||||||
((type *)memset(alloca(sizeof(type) * (count)), \
|
((type *)memset(alloca(sizeof(type) * (count)), \
|
||||||
|
|
Loading…
Reference in New Issue