diff --git a/demo/test.c b/demo/test.c
index 3e432cf0e..1ea60c005 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -41,6 +41,16 @@ static int64_t rand_int64(void)
return x;
}
+static intmax_t rand_intmax(void)
+{
+ intmax_t x;
+ if (s_mp_rand_source(&x, sizeof(x)) != MP_OKAY) {
+ fprintf(stderr, "s_mp_rand_source failed\n");
+ exit(EXIT_FAILURE);
+ }
+ return x;
+}
+
static uint32_t uabs32(int32_t x)
{
return (x > 0) ? (uint32_t)x : -(uint32_t)x;
@@ -51,6 +61,11 @@ static uint64_t uabs64(int64_t x)
return (x > 0) ? (uint64_t)x : -(uint64_t)x;
}
+static uintmax_t uabsmax(intmax_t x)
+{
+ return (x > 0) ? (uintmax_t)x : -(uintmax_t)x;
+}
+
/* This function prototype is needed
* to test dead code elimination
* which is used for feature detection.
@@ -243,6 +258,51 @@ static int test_mp_get_set_i64(void)
return EXIT_FAILURE;
}
+static int check_get_set_max(mp_int *a, intmax_t b)
+{
+ mp_clear(a);
+ if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
+
+ mp_set_max(a, b);
+ if (mp_shrink(a) != MP_OKAY) return EXIT_FAILURE;
+ if (mp_get_max(a) != b) return EXIT_FAILURE;
+ if (mp_get_umax(a) != (uintmax_t)b) return EXIT_FAILURE;
+ if (mp_get_mag_umax(a) != uabsmax(b)) return EXIT_FAILURE;
+
+ mp_set_umax(a, (uintmax_t)b);
+ if (mp_get_umax(a) != (uintmax_t)b) return EXIT_FAILURE;
+ if (mp_get_max(a) != (intmax_t)(uintmax_t)b) return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}
+
+static int test_mp_get_set_max(void)
+{
+ int i;
+ mp_int a;
+
+ DOR(mp_init(&a));
+
+ check_get_set_max(&a, 0LL);
+ check_get_set_max(&a, -1LL);
+ check_get_set_max(&a, 1LL);
+ check_get_set_max(&a, INTMAX_MIN);
+ check_get_set_max(&a, INTMAX_MAX);
+
+ for (i = 0; i < 1000; ++i) {
+ intmax_t b = rand_intmax();
+ if (check_get_set_max(&a, b) != EXIT_SUCCESS) {
+ goto LBL_ERR;
+ }
+ }
+
+ mp_clear(&a);
+ return EXIT_SUCCESS;
+LBL_ERR:
+ mp_clear(&a);
+ return EXIT_FAILURE;
+}
+
static int test_mp_fread_fwrite(void)
{
mp_int a, b;
@@ -713,6 +773,38 @@ static int test_mp_get_u64(void)
}
+static int test_mp_get_umax(void)
+{
+ uintmax_t q, r;
+ int i;
+
+ mp_int a, b;
+ DOR(mp_init_multi(&a, &b, NULL));
+
+ for (i = 0; i < (int)(MP_SIZEOF_BITS(uintmax_t) - 1); ++i) {
+ r = ((uintmax_t)1 << (i+1)) - 1;
+ if (!r)
+ r = UINTMAX_MAX;
+ printf(" r = 0x%" PRIxMAX " i = %d\r", r, i);
+ do {
+ mp_set_umax(&a, r);
+ q = mp_get_umax(&a);
+ if (q != r) {
+ printf("\nmp_get_umax() bad result! 0x%" PRIxMAX " != 0x%" PRIxMAX, q, r);
+ goto LBL_ERR;
+ }
+ r <<= 1;
+ } while (r != 0uLL);
+ }
+
+ mp_clear_multi(&a, &b, NULL);
+ return EXIT_SUCCESS;
+LBL_ERR:
+ mp_clear_multi(&a, &b, NULL);
+ return EXIT_FAILURE;
+
+}
+
static int test_mp_sqrt(void)
{
int i, n;
@@ -2293,6 +2385,7 @@ static int unit_tests(int argc, char **argv)
T0(trivial_stuff),
T2(mp_get_set_i32, MP_GET_I32, MP_GET_MAG_U32),
T2(mp_get_set_i64, MP_GET_I64, MP_GET_MAG_U64),
+ T2(mp_get_set_max, MP_GET_MAX, MP_GET_MAG_UMAX),
T1(mp_and, MP_AND),
T1(mp_cnt_lsb, MP_CNT_LSB),
T1(mp_complement, MP_COMPLEMENT),
@@ -2303,6 +2396,7 @@ static int unit_tests(int argc, char **argv)
T2(mp_fread_fwrite, MP_FREAD, MP_FWRITE),
T1(mp_get_u32, MP_GET_I32),
T1(mp_get_u64, MP_GET_I64),
+ T1(mp_get_umax, MP_GET_MAX),
T1(mp_get_ul, MP_GET_L),
T1(mp_log_u32, MP_LOG_U32),
T1(mp_incr, MP_ADD_D),
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 7e16199e8..a0c81d97c 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -484,6 +484,14 @@
RelativePath="mp_get_mag_ull.c"
>
+
+
+
+
@@ -512,6 +520,10 @@
RelativePath="mp_init_ll.c"
>
+
+
@@ -540,6 +552,10 @@
RelativePath="mp_init_ull.c"
>
+
+
@@ -732,6 +748,10 @@
RelativePath="mp_set_ll.c"
>
+
+
@@ -748,6 +768,10 @@
RelativePath="mp_set_ull.c"
>
+
+
diff --git a/makefile b/makefile
index 88eff7921..e7bb0808e 100644
--- a/makefile
+++ b/makefile
@@ -31,22 +31,23 @@ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count
mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \
mp_error_to_string.o mp_exch.o mp_expt_u32.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_ll.o \
-mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
-mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
-mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
-mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
-mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
-mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
-mp_prime_strong_lucas_selfridge.o mp_radix_size.o mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
-mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \
-mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
-mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o \
-mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \
-mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
-s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o \
-s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o \
-s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
+mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_get_mag_umax.o mp_get_max.o \
+mp_grow.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_max.o \
+mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o \
+mp_init_umax.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log_u32.o mp_lshd.o mp_mod.o \
+mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o \
+mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \
+mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \
+mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \
+mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
+mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
+mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_max.o \
+mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_set_umax.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o \
+mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o \
+mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \
+s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o \
+s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
+s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o s_mp_rand_jenkins.o \
s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
s_mp_zero_buf.o s_mp_zero_digs.o
diff --git a/makefile.mingw b/makefile.mingw
index 3a3bc631f..34a150fc9 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -33,22 +33,23 @@ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count
mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \
mp_error_to_string.o mp_exch.o mp_expt_u32.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_ll.o \
-mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
-mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
-mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
-mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
-mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
-mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
-mp_prime_strong_lucas_selfridge.o mp_radix_size.o mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
-mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \
-mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
-mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o \
-mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \
-mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
-s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o \
-s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o \
-s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
+mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_get_mag_umax.o mp_get_max.o \
+mp_grow.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_max.o \
+mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o \
+mp_init_umax.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log_u32.o mp_lshd.o mp_mod.o \
+mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o \
+mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \
+mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \
+mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \
+mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
+mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
+mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_max.o \
+mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_set_umax.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o \
+mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o \
+mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \
+s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o \
+s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
+s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o s_mp_rand_jenkins.o \
s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
s_mp_zero_buf.o s_mp_zero_digs.o
diff --git a/makefile.msvc b/makefile.msvc
index a22267c4a..b82cb6f4a 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -26,22 +26,23 @@ mp_cmp.obj mp_cmp_d.obj mp_cmp_mag.obj mp_cnt_lsb.obj mp_complement.obj mp_copy.
mp_div.obj mp_div_2.obj mp_div_2d.obj mp_div_d.obj mp_dr_is_modulus.obj mp_dr_reduce.obj mp_dr_setup.obj \
mp_error_to_string.obj mp_exch.obj mp_expt_u32.obj mp_exptmod.obj mp_exteuclid.obj mp_fread.obj mp_from_sbin.obj \
mp_from_ubin.obj mp_fwrite.obj mp_gcd.obj mp_get_double.obj mp_get_i32.obj mp_get_i64.obj mp_get_l.obj mp_get_ll.obj \
-mp_get_mag_u32.obj mp_get_mag_u64.obj mp_get_mag_ul.obj mp_get_mag_ull.obj mp_grow.obj mp_init.obj mp_init_copy.obj \
-mp_init_i32.obj mp_init_i64.obj mp_init_l.obj mp_init_ll.obj mp_init_multi.obj mp_init_set.obj mp_init_size.obj \
-mp_init_u32.obj mp_init_u64.obj mp_init_ul.obj mp_init_ull.obj mp_invmod.obj mp_is_square.obj mp_kronecker.obj mp_lcm.obj \
-mp_log_u32.obj mp_lshd.obj mp_mod.obj mp_mod_2d.obj mp_montgomery_calc_normalization.obj mp_montgomery_reduce.obj \
-mp_montgomery_setup.obj mp_mul.obj mp_mul_2.obj mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj mp_neg.obj mp_or.obj mp_pack.obj \
-mp_pack_count.obj mp_prime_fermat.obj mp_prime_frobenius_underwood.obj mp_prime_is_prime.obj \
-mp_prime_miller_rabin.obj mp_prime_next_prime.obj mp_prime_rabin_miller_trials.obj mp_prime_rand.obj \
-mp_prime_strong_lucas_selfridge.obj mp_radix_size.obj mp_rand.obj mp_read_radix.obj mp_reduce.obj mp_reduce_2k.obj \
-mp_reduce_2k_l.obj mp_reduce_2k_setup.obj mp_reduce_2k_setup_l.obj mp_reduce_is_2k.obj mp_reduce_is_2k_l.obj \
-mp_reduce_setup.obj mp_root_u32.obj mp_rshd.obj mp_sbin_size.obj mp_set.obj mp_set_double.obj mp_set_i32.obj mp_set_i64.obj \
-mp_set_l.obj mp_set_ll.obj mp_set_u32.obj mp_set_u64.obj mp_set_ul.obj mp_set_ull.obj mp_shrink.obj mp_signed_rsh.obj \
-mp_sqrmod.obj mp_sqrt.obj mp_sqrtmod_prime.obj mp_sub.obj mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj \
-mp_to_ubin.obj mp_ubin_size.obj mp_unpack.obj mp_xor.obj mp_zero.obj s_mp_add.obj s_mp_copy_digs.obj s_mp_div_3.obj \
-s_mp_div_recursive.obj s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_mp_get_bit.obj \
-s_mp_invmod.obj s_mp_invmod_odd.obj s_mp_log.obj s_mp_log_d.obj s_mp_log_pow2.obj s_mp_montgomery_reduce_comba.obj \
-s_mp_mul.obj s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj \
+mp_get_mag_u32.obj mp_get_mag_u64.obj mp_get_mag_ul.obj mp_get_mag_ull.obj mp_get_mag_umax.obj mp_get_max.obj \
+mp_grow.obj mp_init.obj mp_init_copy.obj mp_init_i32.obj mp_init_i64.obj mp_init_l.obj mp_init_ll.obj mp_init_max.obj \
+mp_init_multi.obj mp_init_set.obj mp_init_size.obj mp_init_u32.obj mp_init_u64.obj mp_init_ul.obj mp_init_ull.obj \
+mp_init_umax.obj mp_invmod.obj mp_is_square.obj mp_kronecker.obj mp_lcm.obj mp_log_u32.obj mp_lshd.obj mp_mod.obj \
+mp_mod_2d.obj mp_montgomery_calc_normalization.obj mp_montgomery_reduce.obj mp_montgomery_setup.obj mp_mul.obj \
+mp_mul_2.obj mp_mul_2d.obj mp_mul_d.obj mp_mulmod.obj mp_neg.obj mp_or.obj mp_pack.obj mp_pack_count.obj mp_prime_fermat.obj \
+mp_prime_frobenius_underwood.obj mp_prime_is_prime.obj mp_prime_miller_rabin.obj mp_prime_next_prime.obj \
+mp_prime_rabin_miller_trials.obj mp_prime_rand.obj mp_prime_strong_lucas_selfridge.obj mp_radix_size.obj \
+mp_rand.obj mp_read_radix.obj mp_reduce.obj mp_reduce_2k.obj mp_reduce_2k_l.obj mp_reduce_2k_setup.obj \
+mp_reduce_2k_setup_l.obj mp_reduce_is_2k.obj mp_reduce_is_2k_l.obj mp_reduce_setup.obj mp_root_u32.obj mp_rshd.obj \
+mp_sbin_size.obj mp_set.obj mp_set_double.obj mp_set_i32.obj mp_set_i64.obj mp_set_l.obj mp_set_ll.obj mp_set_max.obj \
+mp_set_u32.obj mp_set_u64.obj mp_set_ul.obj mp_set_ull.obj mp_set_umax.obj mp_shrink.obj mp_signed_rsh.obj mp_sqrmod.obj \
+mp_sqrt.obj mp_sqrtmod_prime.obj mp_sub.obj mp_sub_d.obj mp_submod.obj mp_to_radix.obj mp_to_sbin.obj mp_to_ubin.obj \
+mp_ubin_size.obj mp_unpack.obj mp_xor.obj mp_zero.obj s_mp_add.obj s_mp_copy_digs.obj s_mp_div_3.obj s_mp_div_recursive.obj \
+s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_mp_get_bit.obj s_mp_invmod.obj \
+s_mp_invmod_odd.obj s_mp_log.obj s_mp_log_d.obj s_mp_log_pow2.obj s_mp_montgomery_reduce_comba.obj s_mp_mul.obj \
+s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj \
s_mp_mul_toom.obj s_mp_prime_is_divisible.obj s_mp_prime_tab.obj s_mp_radix_map.obj s_mp_rand_jenkins.obj \
s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj s_mp_sqr_karatsuba.obj s_mp_sqr_toom.obj s_mp_sub.obj \
s_mp_zero_buf.obj s_mp_zero_digs.obj
diff --git a/makefile.shared b/makefile.shared
index ad58e61fe..dafd25d45 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -28,22 +28,23 @@ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count
mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \
mp_error_to_string.o mp_exch.o mp_expt_u32.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_ll.o \
-mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
-mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
-mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
-mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
-mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
-mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
-mp_prime_strong_lucas_selfridge.o mp_radix_size.o mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
-mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \
-mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
-mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o \
-mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \
-mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
-s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o \
-s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o \
-s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
+mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_get_mag_umax.o mp_get_max.o \
+mp_grow.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_max.o \
+mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o \
+mp_init_umax.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log_u32.o mp_lshd.o mp_mod.o \
+mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o \
+mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \
+mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \
+mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \
+mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
+mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
+mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_max.o \
+mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_set_umax.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o \
+mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o \
+mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \
+s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o \
+s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
+s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o s_mp_rand_jenkins.o \
s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
s_mp_zero_buf.o s_mp_zero_digs.o
diff --git a/makefile.unix b/makefile.unix
index 1e0da7393..d421d2bcf 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -34,22 +34,23 @@ mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count
mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \
mp_error_to_string.o mp_exch.o mp_expt_u32.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_ll.o \
-mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
-mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_multi.o mp_init_set.o mp_init_size.o \
-mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
-mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
-mp_montgomery_setup.o mp_mul.o mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o \
-mp_pack_count.o mp_prime_fermat.o mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
-mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
-mp_prime_strong_lucas_selfridge.o mp_radix_size.o mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
-mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \
-mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
-mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o \
-mp_sqrmod.o mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o \
-mp_to_ubin.o mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
-s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o \
-s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o \
-s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
+mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_get_mag_umax.o mp_get_max.o \
+mp_grow.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.o mp_init_max.o \
+mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o mp_init_ull.o \
+mp_init_umax.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log_u32.o mp_lshd.o mp_mod.o \
+mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o \
+mp_mul_2.o mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \
+mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \
+mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \
+mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o mp_reduce_2k_l.o mp_reduce_2k_setup.o \
+mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o mp_reduce_setup.o mp_root_u32.o mp_rshd.o \
+mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o mp_set_l.o mp_set_ll.o mp_set_max.o \
+mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_set_umax.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o \
+mp_sqrt.o mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o \
+mp_ubin_size.o mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o s_mp_div_recursive.o \
+s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_bit.o s_mp_invmod.o \
+s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
+s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o s_mp_rand_jenkins.o \
s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
s_mp_zero_buf.o s_mp_zero_digs.o
diff --git a/mp_get_mag_umax.c b/mp_get_mag_umax.c
new file mode 100644
index 000000000..9887ea92c
--- /dev/null
+++ b/mp_get_mag_umax.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_GET_MAG_UMAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_MAG(mp_get_mag_umax, uintmax_t)
+#endif
diff --git a/mp_get_max.c b/mp_get_max.c
new file mode 100644
index 000000000..9976b6775
--- /dev/null
+++ b/mp_get_max.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_GET_MAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_GET_SIGNED(mp_get_max, mp_get_mag_umax, intmax_t, uintmax_t)
+#endif
diff --git a/mp_init_max.c b/mp_init_max.c
new file mode 100644
index 000000000..1c0262309
--- /dev/null
+++ b/mp_init_max.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_INIT_MAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_max, mp_set_max, intmax_t)
+#endif
diff --git a/mp_init_umax.c b/mp_init_umax.c
new file mode 100644
index 000000000..d81047acf
--- /dev/null
+++ b/mp_init_umax.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_INIT_UMAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_INIT_INT(mp_init_umax, mp_set_umax, uintmax_t)
+#endif
diff --git a/mp_set_max.c b/mp_set_max.c
new file mode 100644
index 000000000..2a6259b38
--- /dev/null
+++ b/mp_set_max.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_SET_MAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_SIGNED(mp_set_max, mp_set_umax, intmax_t, uintmax_t)
+#endif
diff --git a/mp_set_umax.c b/mp_set_umax.c
new file mode 100644
index 000000000..2d3299d1b
--- /dev/null
+++ b/mp_set_umax.c
@@ -0,0 +1,7 @@
+#include "tommath_private.h"
+#ifdef MP_SET_UMAX_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+MP_SET_UNSIGNED(mp_set_umax, uintmax_t)
+#endif
diff --git a/tommath.def b/tommath.def
index 8bc6eacfa..d36c4118d 100644
--- a/tommath.def
+++ b/tommath.def
@@ -48,6 +48,8 @@ EXPORTS
mp_get_mag_u64
mp_get_mag_ul
mp_get_mag_ull
+ mp_get_mag_umax
+ mp_get_max
mp_grow
mp_init
mp_init_copy
@@ -55,6 +57,7 @@ EXPORTS
mp_init_i64
mp_init_l
mp_init_ll
+ mp_init_max
mp_init_multi
mp_init_set
mp_init_size
@@ -62,6 +65,7 @@ EXPORTS
mp_init_u64
mp_init_ul
mp_init_ull
+ mp_init_umax
mp_invmod
mp_is_square
mp_kronecker
@@ -110,10 +114,12 @@ EXPORTS
mp_set_i64
mp_set_l
mp_set_ll
+ mp_set_max
mp_set_u32
mp_set_u64
mp_set_ul
mp_set_ull
+ mp_set_umax
mp_shrink
mp_signed_rsh
mp_sqrmod
diff --git a/tommath.h b/tommath.h
index 5e75c98b5..7a59026d4 100644
--- a/tommath.h
+++ b/tommath.h
@@ -243,6 +243,7 @@ uint32_t mp_get_mag_u32(const mp_int *a) MP_WUR;
uint64_t mp_get_mag_u64(const mp_int *a) MP_WUR;
unsigned long mp_get_mag_ul(const mp_int *a) MP_WUR;
unsigned long long mp_get_mag_ull(const mp_int *a) MP_WUR;
+uintmax_t mp_get_mag_umax(const mp_int *a) MP_WUR;
/* get integer, set integer (long) */
long mp_get_l(const mp_int *a) MP_WUR;
@@ -264,6 +265,16 @@ mp_err mp_init_ll(mp_int *a, long long b) MP_WUR;
void mp_set_ull(mp_int *a, unsigned long long b);
mp_err mp_init_ull(mp_int *a, unsigned long long b) MP_WUR;
+/* get integer, set integer (intmax_t) */
+intmax_t mp_get_max(const mp_int *a) MP_WUR;
+void mp_set_max(mp_int *a, intmax_t b);
+mp_err mp_init_max(mp_int *a, intmax_t b) MP_WUR;
+
+/* get integer, set integer (uintmax_t) */
+#define mp_get_umax(a) ((uintmax_t)mp_get_max(a))
+void mp_set_umax(mp_int *a, uintmax_t b);
+mp_err mp_init_umax(mp_int *a, uintmax_t b) MP_WUR;
+
/* set to single unsigned digit, up to MP_DIGIT_MAX */
void mp_set(mp_int *a, mp_digit b);
mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
diff --git a/tommath_class.h b/tommath_class.h
index f5f99074c..0b641f1aa 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -54,6 +54,8 @@
# define MP_GET_MAG_U64_C
# define MP_GET_MAG_UL_C
# define MP_GET_MAG_ULL_C
+# define MP_GET_MAG_UMAX_C
+# define MP_GET_MAX_C
# define MP_GROW_C
# define MP_INIT_C
# define MP_INIT_COPY_C
@@ -61,6 +63,7 @@
# define MP_INIT_I64_C
# define MP_INIT_L_C
# define MP_INIT_LL_C
+# define MP_INIT_MAX_C
# define MP_INIT_MULTI_C
# define MP_INIT_SET_C
# define MP_INIT_SIZE_C
@@ -68,6 +71,7 @@
# define MP_INIT_U64_C
# define MP_INIT_UL_C
# define MP_INIT_ULL_C
+# define MP_INIT_UMAX_C
# define MP_INVMOD_C
# define MP_IS_SQUARE_C
# define MP_KRONECKER_C
@@ -116,10 +120,12 @@
# define MP_SET_I64_C
# define MP_SET_L_C
# define MP_SET_LL_C
+# define MP_SET_MAX_C
# define MP_SET_U32_C
# define MP_SET_U64_C
# define MP_SET_UL_C
# define MP_SET_ULL_C
+# define MP_SET_UMAX_C
# define MP_SHRINK_C
# define MP_SIGNED_RSH_C
# define MP_SQRMOD_C
@@ -393,6 +399,13 @@
#if defined(MP_GET_MAG_ULL_C)
#endif
+#if defined(MP_GET_MAG_UMAX_C)
+#endif
+
+#if defined(MP_GET_MAX_C)
+# define MP_GET_MAG_UMAX_C
+#endif
+
#if defined(MP_GROW_C)
# define S_MP_ZERO_DIGS_C
#endif
@@ -426,6 +439,11 @@
# define MP_SET_LL_C
#endif
+#if defined(MP_INIT_MAX_C)
+# define MP_INIT_C
+# define MP_SET_MAX_C
+#endif
+
#if defined(MP_INIT_MULTI_C)
# define MP_CLEAR_C
# define MP_INIT_C
@@ -459,6 +477,11 @@
# define MP_SET_ULL_C
#endif
+#if defined(MP_INIT_UMAX_C)
+# define MP_INIT_C
+# define MP_SET_UMAX_C
+#endif
+
#if defined(MP_INVMOD_C)
# define MP_CMP_D_C
# define S_MP_INVMOD_C
@@ -846,6 +869,10 @@
# define MP_SET_ULL_C
#endif
+#if defined(MP_SET_MAX_C)
+# define MP_SET_UMAX_C
+#endif
+
#if defined(MP_SET_U32_C)
# define S_MP_ZERO_DIGS_C
#endif
@@ -862,6 +889,10 @@
# define S_MP_ZERO_DIGS_C
#endif
+#if defined(MP_SET_UMAX_C)
+# define S_MP_ZERO_DIGS_C
+#endif
+
#if defined(MP_SHRINK_C)
#endif
diff --git a/tommath_private.h b/tommath_private.h
index f6295020f..03700927f 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -153,7 +153,7 @@ MP_STATIC_ASSERT(correct_word_size, sizeof(mp_word) == (2u * sizeof(mp_digit)))
* - Must be at least 3 for s_mp_div_school.
* - Must be large enough such that uint64_t can be stored in mp_int without growing
*/
-#define MP_MIN_PREC MP_MAX(3, (((int)MP_SIZEOF_BITS(long long) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
+#define MP_MIN_PREC MP_MAX(3, (((int)MP_SIZEOF_BITS(intmax_t) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
MP_STATIC_ASSERT(prec_geq_min_prec, MP_PREC >= MP_MIN_PREC)
/* random number source */