mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
util: Add util_unsigned_logbase2.
Cherry picked from Keith's commit f911c3b989.
This commit is contained in:
parent
c40eddd294
commit
fdb3e75f7e
1 changed files with 12 additions and 0 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue