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 <alx@kernel.org>
This commit is contained in:
parent
1db190cb66
commit
3f90eff494
@ -169,6 +169,7 @@ static inline void memzero(void *ptr, size_t size)
|
|||||||
#define SCALE DAY
|
#define SCALE DAY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WIDTHOF(x) (sizeof(x) * CHAR_BIT)
|
||||||
#define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0]))
|
#define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0]))
|
||||||
|
|
||||||
/* Copy string pointed by B to array A with size checking. It was originally
|
/* Copy string pointed by B to array A with size checking. It was originally
|
||||||
|
Loading…
x
Reference in New Issue
Block a user