projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c40eddd
)
util: Add util_unsigned_logbase2.
author
José Fonseca
<jfonseca@vmware.com>
Sat, 29 Aug 2009 08:15:10 +0000
(09:15 +0100)
committer
José Fonseca
<jfonseca@vmware.com>
Sat, 29 Aug 2009 08:21:42 +0000
(09:21 +0100)
Cherry picked from Keith's commit
f911c3b9897b90132c8621a72bfeb824eb3b01e5
.
src/gallium/auxiliary/util/u_math.h
patch
|
blob
|
history
diff --git
a/src/gallium/auxiliary/util/u_math.h
b/src/gallium/auxiliary/util/u_math.h
index 57410e78b02af71a8965c1307d8e6320ea89b502..b0807c13392359dfea266f1d4a474ec9e6cf03d6 100644
(file)
--- a/
src/gallium/auxiliary/util/u_math.h
+++ b/
src/gallium/auxiliary/util/u_math.h
@@
-375,6
+375,18
@@
unsigned ffs( unsigned u )
#endif
+/* Could also binary search for the highest bit.
+ */
+static INLINE unsigned
+util_unsigned_logbase2(unsigned n)
+{
+ unsigned log2 = 0;
+ while (n >>= 1)
+ ++log2;
+ return log2;
+}
+
+
/**
* Return float bits.
*/