Skip to contentSkip to conversation

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))"

PATCH New Sergei Poselenov 1 participant 1 message Oct 29, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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))"

---
 include/div64.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/div64.h +8 -0
index c495aef..df3f73b 100644
@@ -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 */
Signature · 1 line
1.5.6.1