[U-Boot] [PATCH] Added a do_div() wrapper macro, lldiv().

From 9ccffd30d2f3fbc5e35e5ce445834c53d1d2a4fa Mon Sep 17 00:00:00 2001
From: Sergei Poselenov psl@pollux.denx.de Date: Wed, 29 Oct 2008 13:04:16 +0100 Subject: [PATCH] Added a do_div() wrapper macro, lldiv(). The new macro 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 sposelenov@emcraft.com --- include/div64.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/div64.h b/include/div64.h index c495aef..df3f73b 100644 --- a/include/div64.h +++ b/include/div64.h @@ -36,4 +36,12 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); __rem; \ })
+/* Wrapper for do_div() + */ +# define lldiv(a,b) ({ \ + uint64_t __temp = (a); \ + do_div(__temp, (b)); \ + __temp; \ + }) + #endif /* _ASM_GENERIC_DIV64_H */

Dear Sergei,
In message 200811011404.mA1E4J91008389@wooster.emcraft.com you wrote:
Subject: [PATCH] Added a do_div() wrapper macro, lldiv(). The new macro 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))"
Instead of a macro, please make this an inline function (which is better as it allows for examply more strict type checking by the compiler).
Thanks.
Best regards,
Wolfgang Denk
participants (2)
-
sposelenov@emcraft.com
-
Wolfgang Denk