Browse Source

util: is_power_of_two function

Luke Dashjr 11 years ago
parent
commit
38166477fe
1 changed files with 3 additions and 0 deletions
  1. 3 0
      util.h

+ 3 - 0
util.h

@@ -403,6 +403,9 @@ void pk_u64le(void * const bufp, const int offset, const uint64_t nv)
 	buf[offset+7] = (nv >> 0x38) & 0xff;
 }
 
+#define is_power_of_two(n)  \
+	(0 == ((n) && ((n) - 1)))
+
 static inline
 uint32_t upper_power_of_two_u32(uint32_t n)
 {