MCPcopy Create free account
hub / github.com/F-Stack/f-stack / isqrt

Function isqrt

freebsd/vm/vm_pageout.c:965–982  ·  view source on GitHub ↗

* Compute the integer square root. */

Source from the content-addressed store, hash-verified

963 * Compute the integer square root.
964 */
965static u_int
966isqrt(u_int num)
967{
968 u_int bit, root, tmp;
969
970 bit = num != 0 ? (1u << ((fls(num) - 1) & ~1)) : 0;
971 root = 0;
972 while (bit != 0) {
973 tmp = root + bit;
974 root >>= 1;
975 if (num >= tmp) {
976 num -= tmp;
977 root += bit;
978 }
979 bit >>= 2;
980 }
981 return (root);
982}
983
984/*
985 * Perform the work of the laundry thread: periodically wake up and determine

Callers 1

Calls 1

flsFunction · 0.50

Tested by

no test coverage detected