summaryrefslogtreecommitdiffstats
path: root/lib/bitops.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-03-31 21:17:00 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-03-31 21:17:00 +0200
commitc60cdd8c3926a1b3d9156327e8aae64986084ff4 (patch)
treea6ee8b63c24478687d5ac03149a28f2a8044bcab /lib/bitops.c
parentb1a597e0c3821c791a41278454e74261cf1b95fb (diff)
downloadbird-c60cdd8c3926a1b3d9156327e8aae64986084ff4.tar
bird-c60cdd8c3926a1b3d9156327e8aae64986084ff4.zip
Cleanup changes
Diffstat (limited to 'lib/bitops.c')
-rw-r--r--lib/bitops.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/bitops.c b/lib/bitops.c
index 88cef78..b63274b 100644
--- a/lib/bitops.c
+++ b/lib/bitops.c
@@ -52,12 +52,13 @@ u32_masklen(u32 x)
*
* This function computes a integral part of binary logarithm of given
* integer @v and returns it. The computed value is also an index of the
- * first non-zero bit position.
+ * most significant non-zero bit position.
*/
u32
u32_log2(u32 v)
{
+ /* The code from http://www-graphics.stanford.edu/~seander/bithacks.html */
u32 r, shift;
r = (v > 0xFFFF) << 4; v >>= r;
shift = (v > 0xFF ) << 3; v >>= shift; r |= shift;
@@ -66,3 +67,4 @@ u32_log2(u32 v)
r |= (v >> 1);
return r;
}
+