/*
 * Copyright (C) 2013 Davidlohr Bueso <davidlohr.bueso@hp.com>
 *
 *  Based on the shift-and-subtract algorithm for computing integer
 *  square root from Guy L. Steele.
 */

#include <linux/kernel.h>
#include <linux/export.h>

/**
 * int_sqrt - rough approximation to sqrt
 * @x: integer of which to calculate the sqrt
 *
 * A very rough approximation to the sqrt() function.
 */
unsigned long int_sqrt(unsigned long x)
{
	unsigned long b, m, y = 0;

	if (x <= 1)
		return x;

	m = 1UL << (BITS_PER_LONG - 2);
	while (m != 0) {
		b = y + m;
		y >>= 1;

		if (x >= b) {
			x -= b;
			y += m;
		}
		m >>= 2;
	}

	return y;
}
EXPORT_SYMBOL(int_sqrt);
f='/cgit.cgi/'><img src='/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/cgit.cgi/'>index</a> : <a href='/cgit.cgi/linux/net-next.git/'>net-next.git</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='f4563a75fb93d6a756416d97e13f0773ac373a24'/><select name='h' onchange='this.form.submit();'>
<option value='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/include/net/mip6.h'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/net/mip6.h?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/net/mip6.h?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/net/mip6.h?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/net/mip6.h'>
<input type='hidden' name='id' value='f4563a75fb93d6a756416d97e13f0773ac373a24'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>net</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net/mip6.h?id=f4563a75fb93d6a756416d97e13f0773ac373a24'>mip6.h</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/net/mip6.h?id=f4563a75fb93d6a756416d97e13f0773ac373a24&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>