summaryrefslogtreecommitdiffstats
path: root/crypto/userspace/libtommath/tommath.h
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-09-06 15:00:17 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-09-06 15:00:17 +0200
commitc61c13594953d462597ed18d6c77e736878ff9d9 (patch)
tree583b7cb956cb9fce6c630cc634e772942e3bbaf7 /crypto/userspace/libtommath/tommath.h
parent9cab3a1a9660ed5f798b063aa7e827eb0c95ba94 (diff)
parent8afc069c742f80d3e383ba3d0e38697aeeeb147b (diff)
downloadkernel-crypto-c61c13594953d462597ed18d6c77e736878ff9d9.tar.gz
kernel-crypto-c61c13594953d462597ed18d6c77e736878ff9d9.tar.xz
kernel-crypto-c61c13594953d462597ed18d6c77e736878ff9d9.zip
Merge branch 'standalone-master' into standalone-renamencr-standalone-rename
Conflicts: crypto/userspace/libtomcrypt/misc/qsort.c crypto/userspace/libtommath/bn_mp_and.c crypto/userspace/libtommath/bn_mp_exteuclid.c crypto/userspace/libtommath/bn_mp_jacobi.c crypto/userspace/libtommath/bn_mp_or.c crypto/userspace/libtommath/bn_mp_prime_fermat.c crypto/userspace/libtommath/bn_mp_radix_size.c crypto/userspace/libtommath/bn_mp_radix_smap.c crypto/userspace/libtommath/bn_mp_read_radix.c crypto/userspace/libtommath/bn_mp_sqrt.c crypto/userspace/libtommath/bn_mp_toradix.c crypto/userspace/libtommath/bn_mp_toradix_n.c crypto/userspace/libtommath/bn_mp_xor.c examples/Makefile examples/ncr.c examples/pk.c
Diffstat (limited to 'crypto/userspace/libtommath/tommath.h')
-rw-r--r--crypto/userspace/libtommath/tommath.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/crypto/userspace/libtommath/tommath.h b/crypto/userspace/libtommath/tommath.h
index 31ded829977..3fa7ae89853 100644
--- a/crypto/userspace/libtommath/tommath.h
+++ b/crypto/userspace/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)