Lines Matching +full:32 +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0
5 * Based on former do_div() implementation from asm-parisc/div64.h:
6 * Copyright (C) 1999 Hewlett-Packard Co
7 * Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
10 * Generic C version of 64bit/32bit division and modulo, with
11 * 64bit result and 32bit remainder.
13 * The fast case for (n>>32 == 0) is handled inline by do_div().
16 * for some CPUs. __div64_32() can be overridden by linking arch-specific
28 /* Not needed on 64bit architectures */
29 #if BITS_PER_LONG == 32
37 uint32_t high = rem >> 32; in __div64_32()
39 /* Reduce the thing a bit first */ in __div64_32()
43 res = (uint64_t) high << 32; in __div64_32()
44 rem -= (uint64_t) (high*base) << 32; in __div64_32()
54 rem -= b; in __div64_32()
73 quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); in div_s64_rem()
74 *remainder = -*remainder; in div_s64_rem()
76 quotient = -quotient; in div_s64_rem()
80 quotient = -quotient; in div_s64_rem()
88 * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
89 * @dividend: 64bit dividend
90 * @divisor: 64bit divisor
91 * @remainder: 64bit remainder
95 * is kept distinct to avoid slowing down the div64_u64 operation on 32bit
101 u32 high = divisor >> 32; in div64_u64_rem()
113 quot--; in div64_u64_rem()
115 *remainder = dividend - quot * divisor; in div64_u64_rem()
118 *remainder -= divisor; in div64_u64_rem()
128 * div64_u64 - unsigned 64bit divide with 64bit divisor
129 * @dividend: 64bit dividend
130 * @divisor: 64bit divisor
141 u32 high = divisor >> 32; in div64_u64()
151 quot--; in div64_u64()
152 if ((dividend - quot * divisor) >= divisor) in div64_u64()
169 return (quot ^ t) - t; in div64_s64()
174 #endif /* BITS_PER_LONG == 32 */
201 u32 a_lo = a, a_hi = a >> 32, b_lo = b, b_hi = b >> 32; in mul_u64_u64_div_u64()
205 y = (u64)a_lo * b_hi + (u32)(x >> 32); in mul_u64_u64_div_u64()
206 z = (u64)a_hi * b_hi + (u32)(y >> 32); in mul_u64_u64_div_u64()
208 z += (u32)(y >> 32); in mul_u64_u64_div_u64()
209 x = (y << 32) + (u32)x; in mul_u64_u64_div_u64()
217 #pragma GCC diagnostic ignored "-Wdiv-by-zero" in mul_u64_u64_div_u64()
226 u64 n = shift ? (n_lo >> shift) | (n_hi << (64 - shift)) : n_lo; in mul_u64_u64_div_u64()
232 * rem = (rem << shift) + (n_lo - (n << shift)); in mul_u64_u64_div_u64()
238 return -1; in mul_u64_u64_div_u64()
255 p -= shift; in mul_u64_u64_div_u64()
257 n_hi |= n_lo >> (64 - shift); in mul_u64_u64_div_u64()
260 n_hi -= c; in mul_u64_u64_div_u64()