Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
mpi-internal.h File Reference
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/mpi.h>
#include <linux/errno.h>

Go to the source code of this file.

Data Structures

struct  karatsuba_ctx
 

Macros

#define log_debug   printk
 
#define log_bug   printk
 
#define assert(x)
 
#define KARATSUBA_THRESHOLD   16
 
#define ABS(x)   (x >= 0 ? x : -x)
 
#define MIN(l, o)   ((l) < (o) ? (l) : (o))
 
#define MAX(h, i)   ((h) > (i) ? (h) : (i))
 
#define MPN_COPY(d, s, n)
 
#define MPN_COPY_INCR(d, s, n)
 
#define MPN_COPY_DECR(d, s, n)
 
#define MPN_ZERO(d, n)
 
#define MPN_NORMALIZE(d, n)
 
#define MPN_NORMALIZE_NOT_ZERO(d, n)
 
#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace)
 
#define UDIV_QRNND_PREINV(q, r, nh, nl, d, di)
 
#define W_TYPE_SIZE   BITS_PER_MPI_LIMB
 

Typedefs

typedef mpi_limb_tmpi_ptr_t
 
typedef int mpi_size_t
 
typedef mpi_limb_t UWtype
 
typedef unsigned int UHWtype
 
typedef unsigned char UQItype
 
typedef long SItype
 
typedef unsigned long USItype
 

Functions

mpi_ptr_t mpi_alloc_limb_space (unsigned nlimbs)
 
void mpi_free_limb_space (mpi_ptr_t a)
 
void mpi_assign_limb_space (MPI a, mpi_ptr_t ap, unsigned nlimbs)
 
void mpi_rshift_limbs (MPI a, unsigned int count)
 
int mpi_lshift_limbs (MPI a, unsigned int count)
 
mpi_limb_t mpihelp_add_1 (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb)
 
mpi_limb_t mpihelp_add_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size)
 
mpi_limb_t mpihelp_add (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size)
 
mpi_limb_t mpihelp_sub_1 (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb)
 
mpi_limb_t mpihelp_sub_n (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size)
 
mpi_limb_t mpihelp_sub (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size)
 
int mpihelp_cmp (mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size)
 
void mpihelp_release_karatsuba_ctx (struct karatsuba_ctx *ctx)
 
mpi_limb_t mpihelp_addmul_1 (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb)
 
mpi_limb_t mpihelp_submul_1 (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb)
 
int mpihelp_mul_n (mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
 
int mpihelp_mul (mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, mpi_ptr_t vp, mpi_size_t vsize, mpi_limb_t *_result)
 
void mpih_sqr_n_basecase (mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size)
 
void mpih_sqr_n (mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace)
 
int mpihelp_mul_karatsuba_case (mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, mpi_ptr_t vp, mpi_size_t vsize, struct karatsuba_ctx *ctx)
 
mpi_limb_t mpihelp_mul_1 (mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb)
 
mpi_limb_t mpihelp_mod_1 (mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, mpi_limb_t divisor_limb)
 
mpi_limb_t mpihelp_divrem (mpi_ptr_t qp, mpi_size_t qextra_limbs, mpi_ptr_t np, mpi_size_t nsize, mpi_ptr_t dp, mpi_size_t dsize)
 
mpi_limb_t mpihelp_divmod_1 (mpi_ptr_t quot_ptr, mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, mpi_limb_t divisor_limb)
 
mpi_limb_t mpihelp_lshift (mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
 
mpi_limb_t mpihelp_rshift (mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
 

Macro Definition Documentation

#define ABS (   x)    (x >= 0 ? x : -x)

Definition at line 68 of file mpi-internal.h.

#define assert (   x)
Value:
do { \
if (!x) \
log_bug("failed assertion\n"); \
} while (0);

Definition at line 43 of file mpi-internal.h.

#define KARATSUBA_THRESHOLD   16

Definition at line 56 of file mpi-internal.h.

#define log_bug   printk

Definition at line 41 of file mpi-internal.h.

#define log_debug   printk

Definition at line 40 of file mpi-internal.h.

#define MAX (   h,
  i 
)    ((h) > (i) ? (h) : (i))

Definition at line 70 of file mpi-internal.h.

#define MIN (   l,
 
)    ((l) < (o) ? (l) : (o))

Definition at line 69 of file mpi-internal.h.

#define MPN_COPY (   d,
  s,
  n 
)
Value:
do { \
for (_i = 0; _i < (n); _i++) \
(d)[_i] = (s)[_i]; \
} while (0)

Definition at line 80 of file mpi-internal.h.

#define MPN_COPY_DECR (   d,
  s,
  n 
)
Value:
do { \
for (_i = (n)-1; _i >= 0; _i--) \
(d)[_i] = (s)[_i]; \
} while (0)

Definition at line 94 of file mpi-internal.h.

#define MPN_COPY_INCR (   d,
  s,
  n 
)
Value:
do { \
for (_i = 0; _i < (n); _i++) \
(d)[_i] = (d)[_i]; \
} while (0)

Definition at line 87 of file mpi-internal.h.

#define MPN_MUL_N_RECURSE (   prodp,
  up,
  vp,
  size,
  tspace 
)
Value:
do { \
mul_n_basecase(prodp, up, vp, size); \
else \
mul_n(prodp, up, vp, size, tspace); \
} while (0);

Definition at line 127 of file mpi-internal.h.

#define MPN_NORMALIZE (   d,
  n 
)
Value:
do { \
while ((n) > 0) { \
if ((d)[(n)-1]) \
break; \
(n)--; \
} \
} while (0)

Definition at line 109 of file mpi-internal.h.

#define MPN_NORMALIZE_NOT_ZERO (   d,
  n 
)
Value:
do { \
for (;;) { \
if ((d)[(n)-1]) \
break; \
(n)--; \
} \
} while (0)

Definition at line 118 of file mpi-internal.h.

#define MPN_ZERO (   d,
  n 
)
Value:
do { \
int _i; \
for (_i = 0; _i < (n); _i++) \
(d)[_i] = 0; \
} while (0)

Definition at line 102 of file mpi-internal.h.

#define UDIV_QRNND_PREINV (   q,
  r,
  nh,
  nl,
  d,
  di 
)
Value:
do { \
mpi_limb_t _q, _ql, _r; \
mpi_limb_t _xh, _xl; \
umul_ppmm(_q, _ql, (nh), (di)); \
_q += (nh); /* DI is 2**BITS_PER_MPI_LIMB too small */ \
umul_ppmm(_xh, _xl, _q, (d)); \
sub_ddmmss(_xh, _r, (nh), (nl), _xh, _xl); \
if (_xh) { \
sub_ddmmss(_xh, _r, _xh, _r, 0, (d)); \
_q++; \
if (_xh) { \
sub_ddmmss(_xh, _r, _xh, _r, 0, (d)); \
_q++; \
} \
} \
if (_r >= (d)) { \
_r -= (d); \
_q++; \
} \
(r) = _r; \
(q) = _q; \
} while (0)

Definition at line 141 of file mpi-internal.h.

#define W_TYPE_SIZE   BITS_PER_MPI_LIMB

Definition at line 242 of file mpi-internal.h.

Typedef Documentation

Definition at line 65 of file mpi-internal.h.

typedef int mpi_size_t

Definition at line 66 of file mpi-internal.h.

typedef long SItype

Definition at line 253 of file mpi-internal.h.

typedef unsigned int UHWtype

Definition at line 244 of file mpi-internal.h.

typedef unsigned char UQItype

Definition at line 252 of file mpi-internal.h.

typedef unsigned long USItype

Definition at line 254 of file mpi-internal.h.

typedef mpi_limb_t UWtype

Definition at line 243 of file mpi-internal.h.

Function Documentation

mpi_ptr_t mpi_alloc_limb_space ( unsigned  nlimbs)

Definition at line 57 of file mpiutil.c.

void mpi_assign_limb_space ( MPI  a,
mpi_ptr_t  ap,
unsigned  nlimbs 
)

Definition at line 75 of file mpiutil.c.

void mpi_free_limb_space ( mpi_ptr_t  a)

Definition at line 67 of file mpiutil.c.

int mpi_lshift_limbs ( MPI  a,
unsigned int  count 
)
void mpi_rshift_limbs ( MPI  a,
unsigned int  count 
)
void mpih_sqr_n ( mpi_ptr_t  prodp,
mpi_ptr_t  up,
mpi_size_t  size,
mpi_ptr_t  tspace 
)

Definition at line 258 of file mpih-mul.c.

void mpih_sqr_n_basecase ( mpi_ptr_t  prodp,
mpi_ptr_t  up,
mpi_size_t  size 
)

Definition at line 220 of file mpih-mul.c.

mpi_limb_t mpihelp_add ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_ptr_t  s2_ptr,
mpi_size_t  s2_size 
)

Definition at line 65 of file mpi-inline.h.

mpi_limb_t mpihelp_add_1 ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_limb_t  s2_limb 
)

Definition at line 37 of file mpi-inline.h.

mpi_limb_t mpihelp_add_n ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_ptr_t  s2_ptr,
mpi_size_t  size 
)

Definition at line 34 of file generic_mpih-add1.c.

mpi_limb_t mpihelp_addmul_1 ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_limb_t  s2_limb 
)

Definition at line 33 of file generic_mpih-mul2.c.

int mpihelp_cmp ( mpi_ptr_t  op1_ptr,
mpi_ptr_t  op2_ptr,
mpi_size_t  size 
)

Definition at line 38 of file mpih-cmp.c.

mpi_limb_t mpihelp_divmod_1 ( mpi_ptr_t  quot_ptr,
mpi_ptr_t  dividend_ptr,
mpi_size_t  dividend_size,
mpi_limb_t  divisor_limb 
)
mpi_limb_t mpihelp_divrem ( mpi_ptr_t  qp,
mpi_size_t  qextra_limbs,
mpi_ptr_t  np,
mpi_size_t  nsize,
mpi_ptr_t  dp,
mpi_size_t  dsize 
)

Definition at line 58 of file mpih-div.c.

mpi_limb_t mpihelp_lshift ( mpi_ptr_t  wp,
mpi_ptr_t  up,
mpi_size_t  usize,
unsigned  cnt 
)
mpi_limb_t mpihelp_mod_1 ( mpi_ptr_t  dividend_ptr,
mpi_size_t  dividend_size,
mpi_limb_t  divisor_limb 
)
int mpihelp_mul ( mpi_ptr_t  prodp,
mpi_ptr_t  up,
mpi_size_t  usize,
mpi_ptr_t  vp,
mpi_size_t  vsize,
mpi_limb_t _result 
)

Definition at line 440 of file mpih-mul.c.

mpi_limb_t mpihelp_mul_1 ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_limb_t  s2_limb 
)

Definition at line 33 of file generic_mpih-mul1.c.

int mpihelp_mul_karatsuba_case ( mpi_ptr_t  prodp,
mpi_ptr_t  up,
mpi_size_t  usize,
mpi_ptr_t  vp,
mpi_size_t  vsize,
struct karatsuba_ctx ctx 
)

Definition at line 334 of file mpih-mul.c.

int mpihelp_mul_n ( mpi_ptr_t  prodp,
mpi_ptr_t  up,
mpi_ptr_t  vp,
mpi_size_t  size 
)
void mpihelp_release_karatsuba_ctx ( struct karatsuba_ctx ctx)

Definition at line 406 of file mpih-mul.c.

mpi_limb_t mpihelp_rshift ( mpi_ptr_t  wp,
mpi_ptr_t  up,
mpi_size_t  usize,
unsigned  cnt 
)

Definition at line 42 of file generic_mpih-rshift.c.

mpi_limb_t mpihelp_sub ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_ptr_t  s2_ptr,
mpi_size_t  s2_size 
)

Definition at line 108 of file mpi-inline.h.

mpi_limb_t mpihelp_sub_1 ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_limb_t  s2_limb 
)

Definition at line 80 of file mpi-inline.h.

mpi_limb_t mpihelp_sub_n ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_ptr_t  s2_ptr,
mpi_size_t  size 
)

Definition at line 33 of file generic_mpih-sub1.c.

mpi_limb_t mpihelp_submul_1 ( mpi_ptr_t  res_ptr,
mpi_ptr_t  s1_ptr,
mpi_size_t  s1_size,
mpi_limb_t  s2_limb 
)

Definition at line 33 of file generic_mpih-mul3.c.