https://github.com/torvalds/linux
Revision 3d4248885b9fca818e7fe6b66328e714876d36ad authored by Linus Torvalds on 07 November 2006, 22:55:40 UTC, committed by Linus Torvalds on 07 November 2006, 22:55:40 UTC
* master.kernel.org:/home/rmk/linux-2.6-arm:
  [ARM] 3927/1: Allow show_mem() to work with holes in memory map.
  [ARM] 3926/1: make timer led handle HZ != 100
  [ARM] 3923/1: S3C24XX: update s3c2410_defconfig with new drivers
  [ARM] 3922/1: S3C24XX: update s3c2410_defconfig to 2.6.19-rc4
  [ARM] 3921/1: S3C24XX: remove bast_defconfig
  [ARM] 3920/1: S3C24XX: Remove smdk2410_defconfig
  [ARM] 3919/1: Fixed definition of some PXA270 CIF related registers
  [ARM] 3918/1: ixp4xx irq-chip rework
  [ARM] 3912/1: Make PXA270 advertise HWCAP_IWMMXT capability
  [ARM] 3915/1: S3C2412: Add s3c2410_gpio_getirq() to general gpio.c
  [ARM] 3917/1: Fix dmabounce symbol exports
2 parent s edd106f + 5e70982
Raw File
Tip revision: 3d4248885b9fca818e7fe6b66328e714876d36ad authored by Linus Torvalds on 07 November 2006, 22:55:40 UTC
Merge master.kernel.org:/home/rmk/linux-2.6-arm
Tip revision: 3d42488
int_sqrt.c

#include <linux/kernel.h>
#include <linux/module.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 op, res, one;

	op = x;
	res = 0;

	one = 1UL << (BITS_PER_LONG - 2);
	while (one > op)
		one >>= 2;

	while (one != 0) {
		if (op >= res + one) {
			op = op - (res + one);
			res = res +  2 * one;
		}
		res /= 2;
		one /= 4;
	}
	return res;
}
EXPORT_SYMBOL(int_sqrt);
back to top