summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Poselenov <sposelenov@emcraft.com>2008-11-04 13:51:18 +0100
committerWolfgang Denk <wd@denx.de>2009-01-24 00:23:09 +0100
commit3feb647f3fd0881382c7a29f4cf280b66473ae0a (patch)
tree98c94301b02b76944dd2191ab2f32efdc86da3a9
parent6dadc9195ad642cc662632f4d92f92d3d71e8bf2 (diff)
downloadu-boot-imx-3feb647f3fd0881382c7a29f4cf280b66473ae0a.zip
u-boot-imx-3feb647f3fd0881382c7a29f4cf280b66473ae0a.tar.gz
u-boot-imx-3feb647f3fd0881382c7a29f4cf280b66473ae0a.tar.bz2
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 <sposelenov@emcraft.com>
-rw-r--r--include/div64.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/div64.h b/include/div64.h
index c495aef..d833144 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 */