qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [kvm-unit-tests PATCH v8 03/14] libcflat: introduce is_powe


From: Peter Xu
Subject: [Qemu-devel] [kvm-unit-tests PATCH v8 03/14] libcflat: introduce is_power_of_2()
Date: Mon, 12 Dec 2016 11:08:09 +0800

Suggested-by: Andrew Jones <address@hidden>
Reviewed-by: Andrew Jones <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]