Commit c1cf80738219dbd70cba0c0c1244698aad842ec7

Steffen Jaeckel 2020-03-05T13:57:07

introduce MP_HAS_SET_DOUBLE

diff --git a/demo/test.c b/demo/test.c
index 279e44e..98a8499 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -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
 #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_radix_size, MP_RADIX_SIZE),
       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),
 #endif
       T1(mp_signed_rsh, MP_SIGNED_RSH),
diff --git a/mp_set_double.c b/mp_set_double.c
index cdc644d..0ede359 100644
--- a/mp_set_double.c
+++ b/mp_set_double.c
@@ -3,7 +3,7 @@
 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
 /* 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)
 {
    uint64_t frac;
diff --git a/tommath_private.h b/tommath_private.h
index 0096479..0c94831 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -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)
 
+#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 */
 extern MP_PRIVATE mp_err(*s_mp_rand_source)(void *out, size_t size);