From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH kvm-unit-tests v2 02/17] libcflat: introduce is_power_of_2() Date: Wed, 9 Nov 2016 10:10:09 -0500 Message-ID: <1478704224-20472-3-git-send-email-peterx@redhat.com> References: <1478704224-20472-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, rkrcmar@redhat.com, peterx@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48422 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933883AbcKIPKf (ORCPT ); Wed, 9 Nov 2016 10:10:35 -0500 In-Reply-To: <1478704224-20472-1-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Suggested-by: Andrew Jones Signed-off-by: Peter Xu --- lib/libcflat.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/libcflat.h b/lib/libcflat.h index 72b1bf9..19bd0c6 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -103,4 +103,9 @@ do { \ } \ } while (0) +static inline bool is_power_of_2(unsigned long n) +{ + return (n && !(n & (n - 1))); +} + #endif -- 2.7.4