Go to the documentation of this file.
30 #ifndef G10_MPI_INTERNAL_H
31 #define G10_MPI_INTERNAL_H
33 #include <linux/module.h>
34 #include <linux/kernel.h>
35 #include <linux/slab.h>
36 #include <linux/string.h>
38 #include <linux/errno.h>
40 #define log_debug printk
41 #define log_bug printk
46 log_bug("failed assertion\n"); \
55 #ifndef KARATSUBA_THRESHOLD
56 #define KARATSUBA_THRESHOLD 16
60 #if KARATSUBA_THRESHOLD < 2
61 #undef KARATSUBA_THRESHOLD
62 #define KARATSUBA_THRESHOLD 2
68 #define ABS(x) (x >= 0 ? x : -x)
69 #define MIN(l, o) ((l) < (o) ? (l) : (o))
70 #define MAX(h, i) ((h) > (i) ? (h) : (i))
72 static inline int RESIZE_IF_NEEDED(
MPI a,
unsigned b)
80 #define MPN_COPY(d, s, n) \
83 for (_i = 0; _i < (n); _i++) \
87 #define MPN_COPY_INCR(d, s, n) \
90 for (_i = 0; _i < (n); _i++) \
94 #define MPN_COPY_DECR(d, s, n) \
97 for (_i = (n)-1; _i >= 0; _i--) \
102 #define MPN_ZERO(d, n) \
105 for (_i = 0; _i < (n); _i++) \
109 #define MPN_NORMALIZE(d, n) \
118 #define MPN_NORMALIZE_NOT_ZERO(d, n) \
127 #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
129 if ((size) < KARATSUBA_THRESHOLD) \
130 mul_n_basecase(prodp, up, vp, size); \
132 mul_n(prodp, up, vp, size, tspace); \
141 #define UDIV_QRNND_PREINV(q, r, nh, nl, d, di) \
143 mpi_limb_t _q, _ql, _r; \
144 mpi_limb_t _xh, _xl; \
145 umul_ppmm(_q, _ql, (nh), (di)); \
147 umul_ppmm(_xh, _xl, _q, (d)); \
148 sub_ddmmss(_xh, _r, (nh), (nl), _xh, _xl); \
150 sub_ddmmss(_xh, _r, _xh, _r, 0, (d)); \
153 sub_ddmmss(_xh, _r, _xh, _r, 0, (d)); \
242 #define W_TYPE_SIZE BITS_PER_MPI_LIMB
245 #if defined(__GNUC__)