summaryrefslogtreecommitdiffstats
path: root/backport-include/linux/math64.h
diff options
context:
space:
mode:
authorroot <root@artemis.panaceas.org>2015-12-25 15:00:15 +0000
committerroot <root@artemis.panaceas.org>2015-12-25 15:00:15 +0000
commitddd86436f4e3643c04b797f858dab95d5f2e4de9 (patch)
treebfe7a780cf9a2f4fc33aec32c82e625e79dece1f /backport-include/linux/math64.h
downloadbackports-3.10.19-1-master.tar.gz
backports-3.10.19-1-master.tar.bz2
backports-3.10.19-1-master.zip
Diffstat (limited to 'backport-include/linux/math64.h')
-rw-r--r--backport-include/linux/math64.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/backport-include/linux/math64.h b/backport-include/linux/math64.h
new file mode 100644
index 0000000..7f3a81b
--- /dev/null
+++ b/backport-include/linux/math64.h
@@ -0,0 +1,41 @@
+#ifndef _COMPAT_LINUX_MATH64_H
+#define _COMPAT_LINUX_MATH64_H 1
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
+#include_next <linux/math64.h>
+#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+#if BITS_PER_LONG == 64
+
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+ *remainder = dividend % divisor;
+ return dividend / divisor;
+}
+
+#elif BITS_PER_LONG == 32
+
+#ifndef div_u64_rem
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+ *remainder = do_div(dividend, divisor);
+ return dividend;
+}
+#endif
+
+#endif /* BITS_PER_LONG */
+
+#ifndef div_u64
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+ u32 remainder;
+ return div_u64_rem(dividend, divisor, &remainder);
+}
+#endif
+
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
+
+#endif /* _COMPAT_LINUX_MATH64_H */