introduce MP_HAS_SET_DOUBLE

This commit is contained in:
Steffen Jaeckel 2020-03-05 13:57:07 +01:00
parent c5cb0c6f62
commit c1cf807382
3 changed files with 10 additions and 3 deletions

View File

@ -522,7 +522,7 @@ LBL_ERR:
} }
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559) || defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(_M_X86) || defined(__aarch64__) || defined(__arm__) #if defined(MP_HAS_SET_DOUBLE)
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
@ -2172,7 +2172,7 @@ static int unit_tests(int argc, char **argv)
T1(mp_reduce_2k_l, MP_REDUCE_2K_L), T1(mp_reduce_2k_l, MP_REDUCE_2K_L),
T1(mp_radix_size, MP_RADIX_SIZE), T1(mp_radix_size, MP_RADIX_SIZE),
T1(s_mp_radix_size_overestimate, S_MP_RADIX_SIZE_OVERESTIMATE), T1(s_mp_radix_size_overestimate, S_MP_RADIX_SIZE_OVERESTIMATE),
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559) #if defined(MP_HAS_SET_DOUBLE)
T1(mp_set_double, MP_SET_DOUBLE), T1(mp_set_double, MP_SET_DOUBLE),
#endif #endif
T1(mp_signed_rsh, MP_SIGNED_RSH), T1(mp_signed_rsh, MP_SIGNED_RSH),

View File

@ -3,7 +3,7 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ /* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */ /* SPDX-License-Identifier: Unlicense */
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559) || defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(_M_X86) || defined(__aarch64__) || defined(__arm__) #if defined(MP_HAS_SET_DOUBLE)
mp_err mp_set_double(mp_int *a, double b) mp_err mp_set_double(mp_int *a, double b)
{ {
uint64_t frac; uint64_t frac;

View File

@ -164,6 +164,13 @@ MP_STATIC_ASSERT(prec_geq_min_prec, MP_DEFAULT_DIGIT_COUNT >= MP_MIN_DIGIT_COUNT
*/ */
#define MP_MAX_DIGIT_COUNT ((INT_MAX - 2) / MP_DIGIT_BIT) #define MP_MAX_DIGIT_COUNT ((INT_MAX - 2) / MP_DIGIT_BIT)
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559) \
|| defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) \
|| defined(__i386__) || defined(_M_X86) \
|| defined(__aarch64__) || defined(__arm__)
#define MP_HAS_SET_DOUBLE
#endif
/* random number source */ /* random number source */
extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size); extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size);