Add 'const' keyword in various places. Adopted from Tcl

This commit is contained in:
nijtmans 2017-09-19 13:35:15 +02:00 committed by Steffen Jaeckel
parent 5aec0c4094
commit 41de585524
13 changed files with 24 additions and 24 deletions

View File

@ -16,7 +16,7 @@
*/
/* compare two ints (signed)*/
int mp_cmp(mp_int *a, mp_int *b)
int mp_cmp(const mp_int *a, mp_int *b)
{
/* compare based on sign */
if (a->sign != b->sign) {

View File

@ -16,7 +16,7 @@
*/
/* compare a digit */
int mp_cmp_d(mp_int *a, mp_digit b)
int mp_cmp_d(const mp_int *a, mp_digit b)
{
/* compare based on sign */
if (a->sign == MP_NEG) {

View File

@ -16,7 +16,7 @@
*/
/* compare maginitude of two ints (unsigned) */
int mp_cmp_mag(mp_int *a, mp_int *b)
int mp_cmp_mag(const mp_int *a, mp_int *b)
{
int n;
mp_digit *tmpa, *tmpb;

View File

@ -20,7 +20,7 @@ static const int lnz[16] = {
};
/* Counts the number of lsbs which are zero before the first zero bit */
int mp_cnt_lsb(mp_int *a)
int mp_cnt_lsb(const mp_int *a)
{
int x;
mp_digit q, qq;

View File

@ -16,7 +16,7 @@
*/
/* copy, b = a */
int mp_copy(mp_int *a, mp_int *b)
int mp_copy(const mp_int *a, mp_int *b)
{
int res, n;

View File

@ -16,7 +16,7 @@
*/
/* returns the number of bits in an int */
int mp_count_bits(mp_int *a)
int mp_count_bits(const mp_int *a)
{
int r;
mp_digit q;

View File

@ -16,7 +16,7 @@
*/
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d)
int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d)
{
mp_digit D, r, rr;
int x, res;

View File

@ -16,7 +16,7 @@
*/
/* creates "a" then copies b into it */
int mp_init_copy(mp_int *a, mp_int *b)
int mp_init_copy(mp_int *a, const mp_int *b)
{
int res;

View File

@ -16,7 +16,7 @@
*/
/* calc a value mod 2**b */
int mp_mod_2d(mp_int *a, int b, mp_int *c)
int mp_mod_2d(const mp_int *a, int b, mp_int *c)
{
int x, res;

View File

@ -16,7 +16,7 @@
*/
/* shift left by a certain bit count */
int mp_mul_2d(mp_int *a, int b, mp_int *c)
int mp_mul_2d(const mp_int *a, int b, mp_int *c)
{
mp_digit d;
int res;

View File

@ -16,7 +16,7 @@
*/
/* b = -a */
int mp_neg(mp_int *a, mp_int *b)
int mp_neg(const mp_int *a, mp_int *b)
{
int res;
if (a != b) {

View File

@ -16,7 +16,7 @@
*/
/* returns size of ASCII reprensentation */
int mp_radix_size(mp_int *a, int radix, int *size)
int mp_radix_size(const mp_int *a, int radix, int *size)
{
int res, digs;
mp_int t;

View File

@ -238,10 +238,10 @@ int mp_init_set(mp_int *a, mp_digit b);
int mp_init_set_int(mp_int *a, unsigned long b);
/* copy, b = a */
int mp_copy(mp_int *a, mp_int *b);
int mp_copy(const mp_int *a, mp_int *b);
/* inits and copies, a = b */
int mp_init_copy(mp_int *a, mp_int *b);
int mp_init_copy(mp_int *a, const mp_int *b);
/* trim unused digits */
void mp_clamp(mp_int *a);
@ -261,25 +261,25 @@ void mp_rshd(mp_int *a, int b);
int mp_lshd(mp_int *a, int b);
/* c = a / 2**b, implemented as c = a >> b */
int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d);
int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
/* b = a/2 */
int mp_div_2(mp_int *a, mp_int *b);
/* c = a * 2**b, implemented as c = a << b */
int mp_mul_2d(mp_int *a, int b, mp_int *c);
int mp_mul_2d(const mp_int *a, int b, mp_int *c);
/* b = a*2 */
int mp_mul_2(mp_int *a, mp_int *b);
/* c = a mod 2**b */
int mp_mod_2d(mp_int *a, int b, mp_int *c);
int mp_mod_2d(const mp_int *a, int b, mp_int *c);
/* computes a = 2**b */
int mp_2expt(mp_int *a, int b);
/* Counts the number of lsbs which are zero before the first zero bit */
int mp_cnt_lsb(mp_int *a);
int mp_cnt_lsb(const mp_int *a);
/* I Love Earth! */
@ -299,16 +299,16 @@ int mp_and(mp_int *a, mp_int *b, mp_int *c);
/* ---> Basic arithmetic <--- */
/* b = -a */
int mp_neg(mp_int *a, mp_int *b);
int mp_neg(const mp_int *a, mp_int *b);
/* b = |a| */
int mp_abs(mp_int *a, mp_int *b);
/* compare a to b */
int mp_cmp(mp_int *a, mp_int *b);
int mp_cmp(const mp_int *a, const mp_int *b);
/* compare |a| to |b| */
int mp_cmp_mag(mp_int *a, mp_int *b);
int mp_cmp_mag(const mp_int *a, const mp_int *b);
/* c = a + b */
int mp_add(mp_int *a, mp_int *b, mp_int *c);
@ -331,7 +331,7 @@ int mp_mod(mp_int *a, mp_int *b, mp_int *c);
/* ---> single digit functions <--- */
/* compare against a single digit */
int mp_cmp_d(mp_int *a, mp_digit b);
int mp_cmp_d(const mp_int *a, mp_digit b);
/* c = a + b */
int mp_add_d(mp_int *a, mp_digit b, mp_int *c);
@ -524,7 +524,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat);
/* ---> radix conversion <--- */
int mp_count_bits(mp_int *a);
int mp_count_bits(const mp_int *a);
int mp_unsigned_bin_size(mp_int *a);
int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c);
@ -539,7 +539,7 @@ int mp_to_signed_bin_n(mp_int *a, unsigned char *b, unsigned long *outlen);
int mp_read_radix(mp_int *a, const char *str, int radix);
int mp_toradix(mp_int *a, char *str, int radix);
int mp_toradix_n(mp_int *a, char *str, int radix, int maxlen);
int mp_radix_size(mp_int *a, int radix, int *size);
int mp_radix_size(const mp_int *a, int radix, int *size);
#ifndef LTM_NO_FILE
int mp_fread(mp_int *a, int radix, FILE *stream);