summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-22 12:38:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-22 12:38:13 (GMT)
commit0ff0a94010dcb27842e2f78515d4cfd9ae70ed26 (patch)
tree0039b2834b2fc851232d975823f4b59352cfff9b
parentb556c1feccfb6f7985b80cc4fc906ab529ea6f01 (diff)
downloadtcl-0ff0a94010dcb27842e2f78515d4cfd9ae70ed26.zip
tcl-0ff0a94010dcb27842e2f78515d4cfd9ae70ed26.tar.gz
tcl-0ff0a94010dcb27842e2f78515d4cfd9ae70ed26.tar.bz2
Take over recent commmits on the support/1.x branch
-rw-r--r--libtommath/bn_mp_log_u32.c8
-rw-r--r--libtommath/bn_mp_set_double.c4
-rw-r--r--libtommath/bn_s_mp_rand_jenkins.c4
-rw-r--r--libtommath/demo/test.c22
-rw-r--r--libtommath/tommath.h2
5 files changed, 20 insertions, 20 deletions
diff --git a/libtommath/bn_mp_log_u32.c b/libtommath/bn_mp_log_u32.c
index f7bca01..b86d789 100644
--- a/libtommath/bn_mp_log_u32.c
+++ b/libtommath/bn_mp_log_u32.c
@@ -6,7 +6,7 @@
/* Compute log_{base}(a) */
static mp_word s_pow(mp_word base, mp_word exponent)
{
- mp_word result = 1uLL;
+ mp_word result = 1u;
while (exponent != 0u) {
if ((exponent & 1u) == 1u) {
result *= base;
@@ -20,8 +20,8 @@ static mp_word s_pow(mp_word base, mp_word exponent)
static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
{
- mp_word bracket_low = 1uLL, bracket_mid, bracket_high, N;
- mp_digit ret, high = 1uL, low = 0uL, mid;
+ mp_word bracket_low = 1u, bracket_mid, bracket_high, N;
+ mp_digit ret, high = 1u, low = 0uL, mid;
if (n < base) {
return 0uL;
@@ -40,7 +40,7 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
bracket_high *= bracket_high;
}
- while (((mp_digit)(high - low)) > 1uL) {
+ while (((mp_digit)(high - low)) > 1u) {
mid = (low + high) >> 1;
bracket_mid = bracket_low * s_pow(base, (mp_word)(mid - low));
diff --git a/libtommath/bn_mp_set_double.c b/libtommath/bn_mp_set_double.c
index a42fc70..7f1ab75 100644
--- a/libtommath/bn_mp_set_double.c
+++ b/libtommath/bn_mp_set_double.c
@@ -16,7 +16,7 @@ mp_err mp_set_double(mp_int *a, double b)
cast.dbl = b;
exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFu);
- frac = (cast.bits & ((1uLL << 52) - 1uLL)) | (1uLL << 52);
+ frac = (cast.bits & (((uint64_t)1 << 52) - (uint64_t)1)) | ((uint64_t)1 << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
@@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b)
return err;
}
- if (((cast.bits >> 63) != 0uLL) && !MP_IS_ZERO(a)) {
+ if (((cast.bits >> 63) != 0u) && !MP_IS_ZERO(a)) {
a->sign = MP_NEG;
}
diff --git a/libtommath/bn_s_mp_rand_jenkins.c b/libtommath/bn_s_mp_rand_jenkins.c
index da0771c..c64afac 100644
--- a/libtommath/bn_s_mp_rand_jenkins.c
+++ b/libtommath/bn_s_mp_rand_jenkins.c
@@ -27,10 +27,10 @@ static uint64_t s_rand_jenkins_val(void)
void s_mp_rand_jenkins_init(uint64_t seed)
{
- uint64_t i;
+ int i;
jenkins_x.a = 0xf1ea5eedULL;
jenkins_x.b = jenkins_x.c = jenkins_x.d = seed;
- for (i = 0uLL; i < 20uLL; ++i) {
+ for (i = 0; i < 20; ++i) {
(void)s_rand_jenkins_val();
}
}
diff --git a/libtommath/demo/test.c b/libtommath/demo/test.c
index 7b29a4c..14b0c58 100644
--- a/libtommath/demo/test.c
+++ b/libtommath/demo/test.c
@@ -754,7 +754,7 @@ LBL_ERR:
static int test_mp_get_u64(void)
{
- unsigned long long q, r;
+ uint64_t q, r;
int i;
mp_int a, b;
@@ -762,20 +762,20 @@ static int test_mp_get_u64(void)
return EXIT_FAILURE;
}
- for (i = 0; i < (int)(MP_SIZEOF_BITS(unsigned long long) - 1); ++i) {
- r = (1ULL << (i+1)) - 1;
+ for (i = 0; i < (int)(MP_SIZEOF_BITS(uint64_t) - 1); ++i) {
+ r = ((uint64_t)1 << (i+1)) - 1;
if (!r)
- r = ~0ULL;
- printf(" r = 0x%llx i = %d\r", r, i);
+ r = UINT64_MAX;
+ printf(" r = 0x%" PRIx64 " i = %d\r", r, i);
do {
mp_set_u64(&a, r);
q = mp_get_u64(&a);
if (q != r) {
- printf("\nmp_get_u64() bad result! 0x%llx != 0x%llx", q, r);
+ printf("\nmp_get_u64() bad result! 0x%" PRIx64 " != 0x%" PRIx64, q, r);
goto LBL_ERR;
}
r <<= 1;
- } while (r != 0uLL);
+ } while (r != 0u);
}
mp_clear_multi(&a, &b, NULL);
@@ -2313,7 +2313,7 @@ static int test_mp_read_write_ubin(void)
size = mp_ubin_size(&a);
printf("mp_to_ubin_size %zu\n", size);
- buf = malloc(sizeof(*buf) * size);
+ buf = (unsigned char *)malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (u) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2354,7 +2354,7 @@ static int test_mp_read_write_sbin(void)
size = mp_sbin_size(&a);
printf("mp_to_sbin_size %zu\n", size);
- buf = malloc(sizeof(*buf) * size);
+ buf = (unsigned char *)malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (s) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2395,7 +2395,7 @@ static int test_mp_pack_unpack(void)
count = mp_pack_count(&a, 0, 1);
- buf = malloc(count);
+ buf = (unsigned char *)malloc(count);
if (buf == NULL) {
fprintf(stderr, "test_pack_unpack failed to allocate\n");
goto LTM_ERR;
@@ -2483,7 +2483,7 @@ static int unit_tests(int argc, char **argv)
ok = fail = nop = 0;
t = (uint64_t)time(NULL);
- printf("SEED: 0x%"PRIx64"\n\n", t);
+ printf("SEED: 0x%" PRIx64 "\n\n", t);
s_mp_rand_jenkins_init(t);
mp_rand_source(s_mp_rand_jenkins);
diff --git a/libtommath/tommath.h b/libtommath/tommath.h
index 2c4023c..fd28894 100644
--- a/libtommath/tommath.h
+++ b/libtommath/tommath.h
@@ -200,7 +200,7 @@ TOOM_SQR_CUTOFF;
#endif
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
+#define PRIVATE_MP_WARRAY (int)(1 << (((CHAR_BIT * (int)sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
#define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)
#if defined(__GNUC__) && __GNUC__ >= 4