From: Sergei Poselenov Date: Tue, 4 Nov 2008 12:51:18 +0000 (+0100) Subject: Add a do_div() wrapper macro, lldiv(). X-Git-Tag: v2009.03-rc1~198 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3feb647f3fd0881382c7a29f4cf280b66473ae0a;p=u-boot Add a do_div() wrapper macro, lldiv(). Add a do_div() wrapper, lldiv(). The new inline function doesn't modify the dividend and returns the result of division, so it is useful in complex expressions, i.e. "return(a/b)" -> "return(lldiv(a,b))" Signed-off-by: Sergei Poselenov --- diff --git a/include/div64.h b/include/div64.h index c495aefb01..d83314435d 100644 --- a/include/div64.h +++ b/include/div64.h @@ -36,4 +36,14 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); __rem; \ }) +/* Wrapper for do_div(). Doesn't modify dividend and returns + * the result, not reminder. + */ +static inline uint64_t lldiv(uint64_t dividend, uint32_t divisor) +{ + uint64_t __res = dividend; + do_div(__res, divisor); + return(__res); +} + #endif /* _ASM_GENERIC_DIV64_H */