literal suffix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
diff --git a/demo/mtest_opponent.c b/demo/mtest_opponent.c
index 648a654..edbecc0 100644
--- a/demo/mtest_opponent.c
+++ b/demo/mtest_opponent.c
@@ -304,7 +304,7 @@ static int mtest_opponent(void)
DO(mp_read_radix(&c, buf, 64));
DO(mp_invmod(&a, &b, &d));
DO(mp_mulmod(&d, &a, &b, &e));
- if (mp_cmp_d(&e, 1uL) != MP_EQ) {
+ if (mp_cmp_d(&e, 1u) != MP_EQ) {
printf("inv [wrong value from MPI?!] failure\n");
draw(&a);
draw(&b);
diff --git a/demo/test.c b/demo/test.c
index 3b97873..4a4170b 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -115,20 +115,20 @@ static int test_trivial_stuff(void)
DO(mp_abs(&a, &b));
EXPECT(!mp_isneg(&b));
/* a: -5-> b: -4 */
- DO(mp_add_d(&a, 1uL, &b));
+ DO(mp_add_d(&a, 1u, &b));
EXPECT(mp_isneg(&b));
EXPECT(mp_get_i32(&b) == -4);
EXPECT(mp_get_u32(&b) == (uint32_t)-4);
EXPECT(mp_get_mag_u32(&b) == 4);
/* a: -5-> b: 1 */
- DO(mp_add_d(&a, 6uL, &b));
+ DO(mp_add_d(&a, 6u, &b));
EXPECT(mp_get_u32(&b) == 1);
/* a: -5-> a: 1 */
- DO(mp_add_d(&a, 6uL, &a));
+ DO(mp_add_d(&a, 6u, &a));
EXPECT(mp_get_u32(&a) == 1);
mp_zero(&a);
/* a: 0-> a: 6 */
- DO(mp_add_d(&a, 6uL, &a));
+ DO(mp_add_d(&a, 6u, &a));
EXPECT(mp_get_u32(&a) == 6);
mp_set(&a, 42u);
@@ -223,9 +223,9 @@ static int test_mp_get_set_i64(void)
DOR(mp_init(&a));
- check_get_set_i64(&a, 0);
- check_get_set_i64(&a, -1);
- check_get_set_i64(&a, 1);
+ check_get_set_i64(&a, 0LL);
+ check_get_set_i64(&a, -1LL);
+ check_get_set_i64(&a, 1LL);
check_get_set_i64(&a, INT64_MIN);
check_get_set_i64(&a, INT64_MAX);
@@ -282,7 +282,7 @@ static int test_mp_rand(void)
DO(mp_rand(&a, n));
DO(mp_incr(&a));
DO(mp_div_2d(&a, n * MP_DIGIT_BIT, &b, NULL));
- if (mp_cmp_d(&b, 1) != MP_EQ) {
+ if (mp_cmp_d(&b, 1u) != MP_EQ) {
ndraw(&a, "mp_rand() a");
ndraw(&b, "mp_rand() b");
e = MP_ERR;
@@ -729,7 +729,7 @@ static int test_mp_sqrt(void)
printf("\nmp_sqrt() error!");
goto LBL_ERR;
}
- DO(mp_root_u32(&a, 2uL, &c));
+ DO(mp_root_u32(&a, 2u, &c));
if (mp_cmp_mag(&b, &c) != MP_EQ) {
printf("mp_sqrt() bad result!\n");
goto LBL_ERR;
@@ -770,7 +770,7 @@ static int test_mp_is_square(void)
}
/* test for false positives */
- DO(mp_add_d(&a, 1uL, &a));
+ DO(mp_add_d(&a, 1u, &a));
if (mp_is_square(&a, &res) != MP_OKAY) {
printf("\nfp:mp_is_square() error!");
goto LBL_ERR;
@@ -879,9 +879,9 @@ static int test_mp_prime_is_prime(void)
}
/* About the same size as Arnault's pseudoprime */
printf("\rTesting mp_prime_is_prime() with certified prime 2^1119 + 53 ");
- mp_set(&a, 1uL);
+ mp_set(&a, 1u);
DO(mp_mul_2d(&a,1119,&a));
- DO(mp_add_d(&a, 53uL, &a));
+ DO(mp_add_d(&a, 53u, &a));
e = mp_prime_is_prime(&a, mp_prime_rabin_miller_trials(mp_count_bits(&a)), &cnt);
/* small problem */
if (e != MP_OKAY) {
@@ -912,7 +912,7 @@ static int test_mp_prime_is_prime(void)
goto LBL_ERR;
}
/* let's see if it's really a safe prime */
- DO(mp_sub_d(&a, 1uL, &b));
+ DO(mp_sub_d(&a, 1u, &b));
DO(mp_div_2(&b, &b));
e = mp_prime_is_prime(&b, mp_prime_rabin_miller_trials(mp_count_bits(&b)), &cnt);
/* small problem */
@@ -1010,7 +1010,7 @@ static int test_mp_prime_next_prime(void)
putchar('\n');
goto LBL_ERR;
}
- mp_set(&a, 8);
+ mp_set(&a, 8u);
DO(mp_prime_next_prime(&a, 5, true));
if (mp_cmp_d(&a, 11u) != MP_EQ) {
printf("mp_prime_next_prime: output should have been 11 but was: ");
@@ -1183,7 +1183,7 @@ static int test_mp_cnt_lsb(void)
mp_int a, b;
DOR(mp_init_multi(&a, &b, NULL));
- mp_set(&a, 1uL);
+ mp_set(&a, 1u);
for (ix = 0; ix < 1024; ix++) {
if (mp_cnt_lsb(&a) != ix) {
printf("Failed at %d, %d\n", ix, mp_cnt_lsb(&a));
@@ -1212,7 +1212,7 @@ static int test_mp_reduce_2k(void)
mp_digit tmp;
DO(mp_2expt(&a, cnt));
- DO(mp_sub_d(&a, 2uL, &a)); /* a = 2**cnt - 2 */
+ DO(mp_sub_d(&a, 2u, &a)); /* a = 2**cnt - 2 */
printf("\r %4d bits", cnt);
printf("(%d)", mp_reduce_is_2k(&a));
@@ -1226,7 +1226,7 @@ static int test_mp_reduce_2k(void)
DO(mp_rand(&b, (cnt / MP_DIGIT_BIT + 1) * 2));
DO(mp_copy(&c, &b));
DO(mp_mod(&c, &a, &c));
- DO(mp_reduce_2k(&b, &a, 2uL));
+ DO(mp_reduce_2k(&b, &a, 2u));
if (mp_cmp(&c, &b) != MP_EQ) {
printf("FAILED\n");
goto LBL_ERR;
@@ -1249,7 +1249,7 @@ static int test_mp_div_3(void)
DOR(mp_init_multi(&a, &b, &c, &d, &e, NULL));
/* test mp_div_3 */
- mp_set(&d, 3uL);
+ mp_set(&d, 3u);
for (cnt = 0; cnt < 10000;) {
mp_digit r2;
@@ -1306,7 +1306,7 @@ static int test_mp_dr_reduce(void)
fflush(stdout);
}
DO(mp_sqr(&b, &b));
- DO(mp_add_d(&b, 1uL, &b));
+ DO(mp_add_d(&b, 1u, &b));
DO(mp_copy(&b, &c));
DO(mp_mod(&b, &a, &b));
@@ -1370,10 +1370,10 @@ static int test_mp_reduce_2k_l(void)
fflush(stdout);
for (cnt = 0; cnt < (int)(1uL << 20); cnt++) {
DO(mp_sqr(&b, &b));
- DO(mp_add_d(&b, 1uL, &b));
+ DO(mp_add_d(&b, 1u, &b));
DO(mp_reduce_2k_l(&b, &a, &d));
DO(mp_sqr(&c, &c));
- DO(mp_add_d(&c, 1uL, &c));
+ DO(mp_add_d(&c, 1u, &c));
DO(mp_mod(&c, &a, &c));
if (mp_cmp(&b, &c) != MP_EQ) {
printf("mp_reduce_2k_l() failed at step %d\n", cnt);
@@ -1439,7 +1439,7 @@ static int test_mp_log_u32(void)
0 x MP_VAL
1 x MP_VAL
*/
- mp_set(&a, 42uL);
+ mp_set(&a, 42u);
base = 0u;
if (mp_log_u32(&a, base, &lb) != MP_VAL) {
goto LBL_ERR;
@@ -1520,8 +1520,8 @@ static int test_mp_log_u32(void)
/*Test upper edgecase with base UINT32_MAX and number (UINT32_MAX/2)*UINT32_MAX^10 */
mp_set(&a, max_base);
- DO(mp_expt_u32(&a, 10uL, &a));
- DO(mp_add_d(&a, max_base / 2, &a));
+ DO(mp_expt_u32(&a, 10u, &a));
+ DO(mp_add_d(&a, max_base / 2u, &a));
DO(mp_log_u32(&a, max_base, &lb));
if (lb != 10u) {
goto LBL_ERR;
@@ -1543,7 +1543,7 @@ static int test_mp_incr(void)
/* Does it increment inside the limits of a MP_xBIT limb? */
mp_set(&a, MP_MASK/2);
DO(mp_incr(&a));
- if (mp_cmp_d(&a, (MP_MASK/2uL) + 1uL) != MP_EQ) {
+ if (mp_cmp_d(&a, (MP_MASK/2u) + 1u) != MP_EQ) {
goto LBL_ERR;
}
@@ -1551,22 +1551,22 @@ static int test_mp_incr(void)
mp_set(&a, MP_MASK);
mp_set(&b, MP_MASK);
DO(mp_incr(&a));
- DO(mp_add_d(&b, 1uL, &b));
+ DO(mp_add_d(&b, 1u, &b));
if (mp_cmp(&a, &b) != MP_EQ) {
goto LBL_ERR;
}
/* Does it increment from -1 to 0? */
- mp_set(&a, 1uL);
+ mp_set(&a, 1u);
a.sign = MP_NEG;
DO(mp_incr(&a));
- if (mp_cmp_d(&a, 0uL) != MP_EQ) {
+ if (mp_cmp_d(&a, 0u) != MP_EQ) {
goto LBL_ERR;
}
/* Does it increment from -(MP_MASK + 1) to -MP_MASK? */
mp_set(&a, MP_MASK);
- DO(mp_add_d(&a, 1uL, &a));
+ DO(mp_add_d(&a, 1u, &a));
a.sign = MP_NEG;
DO(mp_incr(&a));
if (a.sign != MP_NEG) {
@@ -1593,13 +1593,13 @@ static int test_mp_decr(void)
/* Does it decrement inside the limits of a MP_xBIT limb? */
mp_set(&a, MP_MASK/2);
DO(mp_decr(&a));
- if (mp_cmp_d(&a, (MP_MASK/2uL) - 1uL) != MP_EQ) {
+ if (mp_cmp_d(&a, (MP_MASK/2u) - 1u) != MP_EQ) {
goto LBL_ERR;
}
/* Does it decrement outside of the limits of a MP_xBIT limb? */
mp_set(&a, MP_MASK);
- DO(mp_add_d(&a, 1uL, &a));
+ DO(mp_add_d(&a, 1u, &a));
DO(mp_decr(&a));
if (mp_cmp_d(&a, MP_MASK) != MP_EQ) {
goto LBL_ERR;
@@ -1610,7 +1610,7 @@ static int test_mp_decr(void)
DO(mp_decr(&a));
if (a.sign == MP_NEG) {
a.sign = MP_ZPOS;
- if (mp_cmp_d(&a, 1uL) != MP_EQ) {
+ if (mp_cmp_d(&a, 1u) != MP_EQ) {
goto LBL_ERR;
}
} else {
@@ -1623,7 +1623,7 @@ static int test_mp_decr(void)
a.sign = MP_NEG;
mp_set(&b, MP_MASK);
b.sign = MP_NEG;
- DO(mp_sub_d(&b, 1uL, &b));
+ DO(mp_sub_d(&b, 1u, &b));
DO(mp_decr(&a));
if (mp_cmp(&a, &b) != MP_EQ) {
goto LBL_ERR;
@@ -2038,7 +2038,7 @@ static int test_mp_radix_size(void)
DOR(mp_init(&a));
/* number to result in a different size for every base: 67^(4 * 67) */
- mp_set(&a, 67);
+ mp_set(&a, 67u);
DO(mp_expt_u32(&a, 268u, &a));
for (radix = 2; radix < 65; radix++) {
@@ -2254,7 +2254,7 @@ static int test_mp_pack_unpack(void)
DOR(mp_init_multi(&a, &b, NULL));
DO(mp_rand(&a, 15));
- count = mp_pack_count(&a, 0, 1);
+ count = mp_pack_count(&a, 0uL, 1uL);
buf = malloc(count);
if (buf == NULL) {
@@ -2262,10 +2262,10 @@ static int test_mp_pack_unpack(void)
goto LBL_ERR;
}
- DO(mp_pack((void *)buf, count, &written, order, 1,
- endianess, 0, &a));
- DO(mp_unpack(&b, count, order, 1,
- endianess, 0, (const void *)buf));
+ DO(mp_pack((void *)buf, count, &written, order, 1uL,
+ endianess, 0uL, &a));
+ DO(mp_unpack(&b, count, order, 1uL,
+ endianess, 0uL, (const void *)buf));
if (mp_cmp(&a, &b) != MP_EQ) {
fprintf(stderr, "pack/unpack cycle failed\n");
diff --git a/etc/tune.c b/etc/tune.c
index 9657910..0b73734 100644
--- a/etc/tune.c
+++ b/etc/tune.c
@@ -281,7 +281,7 @@ int main(int argc, char **argv)
/*int preset[8];*/
char *endptr, *str;
- uint64_t seed = 0xdeadbeef;
+ uint64_t seed = 0xdeadbeefULL;
int opt;
struct cutoffs orig, updated;
diff --git a/tommath.h b/tommath.h
index d024a33..68a1592 100644
--- a/tommath.h
+++ b/tommath.h
@@ -375,10 +375,10 @@ mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d) MP_WUR;
mp_err mp_mod(const mp_int *a, const mp_int *b, mp_int *c) MP_WUR;
/* Increment "a" by one like "a++". Changes input! */
-#define mp_incr(a) mp_add_d((a), 1, (a))
+#define mp_incr(a) mp_add_d((a), 1u, (a))
/* Decrement "a" by one like "a--". Changes input! */
-#define mp_decr(a) mp_sub_d((a), 1, (a))
+#define mp_decr(a) mp_sub_d((a), 1u, (a))
/* ---> single digit functions <--- */