mirror of
https://github.com/NVIDIA/open-gpu-kernel-modules.git
synced 2025-03-14 18:29:23 +01:00
Make nvLogBase2
more efficient
This commit is contained in:
parent
d8f3bcff92
commit
8b24fa5b0a
@ -35,20 +35,17 @@
|
||||
//
|
||||
NvU32 nvLogBase2(NvU64 val)
|
||||
{
|
||||
NvU32 i;
|
||||
NvU32 i = 0;
|
||||
|
||||
NV_ASSERT(((val)&(val-1)) == 0);
|
||||
// Use two NV_ASSERTs for better error identification
|
||||
NV_ASSERT(val != 0);
|
||||
NV_ASSERT(((val) & (val - 1)) == 0);
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
while ((val >>= 1))
|
||||
{
|
||||
if ((1ull << i) == val)
|
||||
{
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
NV_ASSERT(i < 64);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -355,4 +352,3 @@ NvU32 nvStringLen(const char * str)
|
||||
;
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user