summaryrefslogtreecommitdiffstats
path: root/libtommath/tommath.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath/tommath.h')
-rw-r--r--libtommath/tommath.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 31ded829977..3fa7ae89853 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/ctype.h>
+#include <linux/math64.h>
#define CHAR_BIT sizeof(uint8_t)*8
@@ -64,16 +65,23 @@ extern "C" {
* At the very least a mp_digit must be able to hold 7 bits
* [any size beyond that is ok provided it doesn't overflow the data type]
*/
-#if BITS_PER_LONG <= 32
+
+/* FIXME: This can be improved, but requires to use 128bit division
+ * on 64bit machines, which is not available in kernel now.
+ */
+#if BITS_PER_LONG < 32
typedef uint16_t mp_digit;
typedef uint32_t mp_word;
# define DIGIT_BIT 15
-#elif BITS_PER_LONG == 64
-
+#elif BITS_PER_LONG <= 64
+
typedef uint32_t mp_digit;
typedef uint64_t mp_word;
+
+# define word_div_int(x,y) div_u64((x),(y))
+
# define DIGIT_BIT 31
#endif
@@ -88,6 +96,11 @@ extern "C" {
#endif
+#ifndef word_div_int
+# define word_div_int(x,y) ((x)/(y))
+#endif
+
+
/* define heap macros */
#ifndef XMALLOC
# define XMALLOC(x) kmalloc(x, GFP_KERNEL)