summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2017-04-11 07:34:56 +0200
committerDenys Vlasenko2017-04-11 07:34:56 +0200
commit8a134ec68075fc2fd415558bcf6a37cda3ff285f (patch)
treee6c4927ebcb071b6dcb6e9832ebe6d7f4b721461 /coreutils
parent10673c44f11045a0c99b19f32930097e9b3ae148 (diff)
downloadbusybox-8a134ec68075fc2fd415558bcf6a37cda3ff285f.zip
busybox-8a134ec68075fc2fd415558bcf6a37cda3ff285f.tar.gz
libbb: move isqrt from factor, use it in diff too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/factor.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/coreutils/factor.c b/coreutils/factor.c
index f910fdb..11cc04f 100644
--- a/coreutils/factor.c
+++ b/coreutils/factor.c
@@ -44,24 +44,7 @@ typedef unsigned long half_t;
#error Cant find an integer type which is half as wide as ullong
#endif
-/* Returns such x that x+1 > sqrt(N) */
-static inline half_t isqrt(wide_t N)
-{
- half_t x;
- unsigned shift;
-
- shift = WIDE_BITS - 2;
- x = 0;
- do {
- x = (x << 1) + 1;
- if ((wide_t)x * x > (N >> shift))
- x--; /* whoops, that +1 was too much */
- shift -= 2;
- } while ((int)shift >= 0);
- return x;
-}
-
-static NOINLINE half_t isqrt_odd(wide_t N)
+static half_t isqrt_odd(wide_t N)
{
half_t s = isqrt(N);
/* Subtract 1 from even s, odd s won't change: */