Add deIsPowerOfTwoSize() to deInt32.h
authorPyry Haulos <phaulos@google.com>
Thu, 17 Dec 2015 04:29:57 +0000 (20:29 -0800)
committerPyry Haulos <phaulos@google.com>
Thu, 17 Dec 2015 04:29:57 +0000 (20:29 -0800)
Change-Id: Idb2b0d6d3d89deefbc83daf0a7f0511cfb5ebda3

framework/delibs/debase/deInt32.h

index 6550267..18e68e5 100644 (file)
@@ -218,6 +218,24 @@ DE_INLINE deBool deIsPowerOfTwo64 (deUint64 a)
 }
 
 /*--------------------------------------------------------------------*//*!
+ * \brief Check if a value is a power-of-two.
+ * \param a Input value.
+ * \return True if input is a power-of-two value, false otherwise.
+ *
+ * \note Also returns true for zero.
+ *//*--------------------------------------------------------------------*/
+DE_INLINE deBool deIsPowerOfTwoSize (size_t a)
+{
+#if (DE_PTR_SIZE == 4)
+       return deIsPowerOfTwo32(a);
+#elif (DE_PTR_SIZE == 8)
+       return deIsPowerOfTwo64(a);
+#else
+#      error "Invalid DE_PTR_SIZE"
+#endif
+}
+
+/*--------------------------------------------------------------------*//*!
  * \brief Check if an integer is aligned to given power-of-two size.
  * \param a            Input value.
  * \param align        Alignment to check for.