util: add spdk_u64_is_pow2()
There already is a spdk_u32_is_pow2() function that handles uint32_t. Add a spdk_u64_is_pow2() function that handles uint64_t. Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Change-Id: Idc96680dbe280d1510aba94a6900eff64ccb4f03 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10179 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1f9c7a74bc
commit
01f94ea947
@ -110,6 +110,19 @@ spdk_u32_is_pow2(uint32_t x)
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a uint64_t is a power of 2.
|
||||
*/
|
||||
static inline bool
|
||||
spdk_u64_is_pow2(uint64_t x)
|
||||
{
|
||||
if (x == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
spdk_divide_round_up(uint64_t num, uint64_t divisor)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user