basic/logarithm: add popcount() wrapper
__builtin_popcount() is a bit of a mouthful, so let's provide a helper. Using _Generic has the advantage that if a type other then the ones on the list is given, compilation will fail. This is nice, because if by any change we pass a wider type, it is rejected immediately instead of being truncated. log.h is also needed. It is included transitively, but let's include it directly. macro.h is *not* needed.
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include "hexdecoct.h"
|
||||
#include "hmac.h"
|
||||
#include "lock-util.h"
|
||||
#include "log.h"
|
||||
#include "logarithm.h"
|
||||
#include "memory-util.h"
|
||||
#include "openssl-util.h"
|
||||
#include "parse-util.h"
|
||||
@@ -773,7 +775,7 @@ size_t tpm2_tpms_pcr_selection_weight(const TPMS_PCR_SELECTION *s) {
|
||||
|
||||
uint32_t mask;
|
||||
tpm2_tpms_pcr_selection_to_mask(s, &mask);
|
||||
return (size_t)__builtin_popcount(mask);
|
||||
return popcount(mask);
|
||||
}
|
||||
|
||||
/* Utility functions for TPML_PCR_SELECTION. */
|
||||
|
||||
Reference in New Issue
Block a user