Suggested-by: Andrew Jones <drjo...@redhat.com> Reviewed-by: Andrew Jones <drjo...@redhat.com> Signed-off-by: Peter Xu <pet...@redhat.com> --- lib/libcflat.h | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/lib/libcflat.h b/lib/libcflat.h index c622198..8455c3d 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -104,4 +104,9 @@ do { \ } \ } while (0) +static inline bool is_power_of_2(unsigned long n) +{ + return n && !(n & (n - 1)); +} + #endif -- 2.7.4