perf: builtin-record: Document and check that mmap_pages must be a power of two.
[linux-2.6-block.git] / tools / perf / util / util.h
index 0128906bac88d258e9e100aeabae5abd462e465b..37be34dff7983c2834b051bc8cc3347ab213383b 100644 (file)
@@ -245,4 +245,15 @@ int readn(int fd, void *buf, size_t size);
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
+/*
+ *  Determine whether some value is a power of two, where zero is
+ * *not* considered a power of two.
+ */
+
+static inline __attribute__((const))
+bool is_power_of_2(unsigned long n)
+{
+       return (n != 0 && ((n & (n - 1)) == 0));
+}
+
 #endif