/** * div_u64 - unsigned 64bit divide with 32bit divisor * @dividend: unsigned 64bit dividend * @divisor: unsigned 32bit divisor * * This is the most common 64bit divide and should be used if possible, * as many 32bit archs can optimize this variant better than a full 64bit * divide. * * Return: dividend / divisor
*/ #ifndef div_u64 staticinline u64 div_u64(u64 dividend, u32 divisor)
{
u32 remainder; return div_u64_rem(dividend, divisor, &remainder);
} #endif
#ifndef mul_u32_u32 /* * Many a GCC version messes this up and generates a 64x64 mult :-(
*/ staticinline u64 mul_u32_u32(u32 a, u32 b)
{ return (u64)a * b;
} #endif
/* * Each of these lines computes a 64-bit intermediate result into "c", * starting at bits 32-95. The low 32-bits go into the result of the * multiplication, the high 32-bits are carried into the next step.
*/
rl.l.high = c = (u64)rl.l.high + rm.l.low + rn.l.low;
rh.l.low = c = (c >> 32) + rm.l.high + rn.l.high + rh.l.low;
rh.l.high = (c >> 32) + rh.l.high;
/* * The 128-bit result of the multiplication is in rl.ll and rh.ll, * shift it right and throw away the high part of the result.
*/ if (shift == 0) return rl.ll; if (shift < 64) return (rl.ll >> shift) | (rh.ll << (64 - shift)); return rh.ll >> (shift & 63);
} #endif/* mul_u64_u64_shr */
/** * DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer * @dividend: signed 64bit dividend * @divisor: signed 32bit divisor * * Divide signed 64bit dividend by signed 32bit divisor * and round to closest integer. * * Return: dividend / divisor rounded to nearest integer
*/ #define DIV_S64_ROUND_CLOSEST(dividend, divisor)( \
{ \
s64 __x = (dividend); \
s32 __d = (divisor); \
((__x > 0) == (__d > 0)) ? \
div_s64((__x + (__d / 2)), __d) : \
div_s64((__x - (__d / 2)), __d); \
} \
)
/** * roundup_u64 - Round up a 64bit value to the next specified 32bit multiple * @x: the value to up * @y: 32bit multiple to round up to * * Rounds @x to the next multiple of @y. For 32bit @x values, see roundup and * the faster round_up() for powers of 2. * * Return: rounded up value.
*/ staticinline u64 roundup_u64(u64 x, u32 y)
{ return DIV_U64_ROUND_UP(x, y) * y;
} #endif/* _LINUX_MATH64_H */
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.