Add dePop64() and fix dePop32() to use unsigned input value
authorPyry Haulos <phaulos@google.com>
Thu, 9 Apr 2015 22:59:20 +0000 (15:59 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 9 Apr 2015 22:59:20 +0000 (15:59 -0700)
Change-Id: I4dc04dc4d948b5ddd329ba4765afc556a12e78ef

framework/delibs/debase/deInt32.h

index 57969b8..f25daf0 100644 (file)
@@ -321,7 +321,7 @@ DE_INLINE deUint32 deLog2Clz(deInt32 a)
  * \param a    Input value.
  * \return The number of one bits in the input.
  *//*--------------------------------------------------------------------*/
-DE_INLINE int dePop32 (int a)
+DE_INLINE int dePop32 (deUint32 a)
 {
        deUint32 mask0 = 0x55555555; /* 1-bit values. */
        deUint32 mask1 = 0x33333333; /* 2-bit values. */
@@ -337,6 +337,11 @@ DE_INLINE int dePop32 (int a)
        return (int)t;
 }
 
+DE_INLINE int dePop64 (deUint64 a)
+{
+       return dePop32((deUint32)(a & 0xffffffffull)) + dePop32((deUint32)(a >> 32));
+}
+
 /*--------------------------------------------------------------------*//*!
  * \brief Reverse bytes in 32-bit integer (for example MSB -> LSB).
  * \param a    Input value.