projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
018e3f7
)
gallium/util: add util_bit_last - finds the last bit set in a word
author
Marek Olšák
<maraeo@gmail.com>
Thu, 29 Mar 2012 22:21:11 +0000
(
00:21
+0200)
committer
Marek Olšák
<maraeo@gmail.com>
Tue, 17 Jul 2012 19:22:14 +0000
(21:22 +0200)
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 f35c35ffe47c704fe83fa740780d22613e424a2a..90b421ed841935d3ee430bc15d1bf3d7ed8c90e6 100644
(file)
--- a/
src/gallium/auxiliary/util/u_math.h
+++ b/
src/gallium/auxiliary/util/u_math.h
@@
-477,6
+477,20
@@
unsigned ffs( unsigned u )
#endif /* FFS_DEFINED */
+/**
+ * Find last bit set in a word. The least significant bit is 1.
+ * Return 0 if no bits are set.
+ */
+static INLINE unsigned util_last_bit(unsigned u)
+{
+ unsigned r = 0;
+ while (u) {
+ r++;
+ u >>= 1;
+ }
+ return r;
+}
+
/* Destructively loop over all of the bits in a mask as in:
*