From: Alejandro Colomar Date: Wed, 18 Jan 2023 11:38:18 +0000 (+0100) Subject: Add WIDTHOF() to get the width in bits X-Git-Tag: 4.14.0-rc1~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f90eff4947ffeb7022696ab9861ed3d80bb61d8;p=thirdparty%2Fshadow.git Add WIDTHOF() to get the width in bits It is common to use the expression 'sizeof(x) * CHAR_BIT' to mean the width in bits of a type or object. Now that there are _WIDTH macros for some types, indicating the number of bits that they use, it makes sense to wrap this calculation in a macro of a similar name. Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index d3416f119..5ef11c021 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -169,6 +169,7 @@ static inline void memzero(void *ptr, size_t size) #define SCALE DAY #endif +#define WIDTHOF(x) (sizeof(x) * CHAR_BIT) #define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0])) /* Copy string pointed by B to array A with size checking. It was originally