summaryrefslogtreecommitdiffstats
path: root/libtommath/tommath.h
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-09-06 14:53:03 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-09-06 14:53:03 +0200
commit8afc069c742f80d3e383ba3d0e38697aeeeb147b (patch)
tree4c010eac56a1d6958e7c86d97579be6338552d51 /libtommath/tommath.h
parent3d758323280763fe59b1f61d4f86aa2a29fe3775 (diff)
parentc5fb18ff697aefb156dfebe87ded77a9e1371c45 (diff)
downloadkernel-crypto-ncr-standalone-master.tar.gz
kernel-crypto-ncr-standalone-master.tar.xz
kernel-crypto-ncr-standalone-master.zip
Merge remote branch 'standalone/master' into standalone-masterncr-standalone-master
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)