From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH kvm-unit-tests v5 03/14] libcflat: introduce is_power_of_2() Date: Tue, 15 Nov 2016 17:24:58 -0500 Message-ID: <1479248709-10281-4-git-send-email-peterx@redhat.com> References: <1479248709-10281-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, pbonzini@redhat.com, peterx@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbcKOWZQ (ORCPT ); Tue, 15 Nov 2016 17:25:16 -0500 In-Reply-To: <1479248709-10281-1-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Suggested-by: Andrew Jones Reviewed-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..038ea1d 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