Merge pull request #134 from libtom/fixup/123_124 Fixup PR for #123 #124
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
diff --git a/bn_mp_set_double.c b/bn_mp_set_double.c
index 6d84874..c78cb22 100644
--- a/bn_mp_set_double.c
+++ b/bn_mp_set_double.c
@@ -49,7 +49,12 @@ int mp_set_double(mp_int *a, double b)
return MP_OKAY;
}
#else
-# warning "mp_set_double implementation is only available on platforms with IEEE754 floating point format"
+/* pragma message() not supported by several compilers (in mostly older but still used versions) */
+# ifdef _MSC_VER
+# pragma message("mp_set_double implementation is only available on platforms with IEEE754 floating point format")
+# else
+# warning "mp_set_double implementation is only available on platforms with IEEE754 floating point format"
+# endif
#endif
#endif
diff --git a/demo/demo.c b/demo/demo.c
index 7ab66ee..368f062 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -284,20 +284,20 @@ int main(void)
/* test mp_tc_div_2d */
printf("\n\nTesting: mp_tc_div_2d");
for (i = 0; i < 1000; ++i) {
- int l, m;
+ int l, em;
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
mp_set_int(&a, labs(l));
if (l < 0)
mp_neg(&a, &a);
- m = rand() % 32;
+ em = rand() % 32;
- mp_set_int(&d, labs(l >> m));
- if ((l >> m) < 0)
+ mp_set_int(&d, labs(l >> em));
+ if ((l >> em) < 0)
mp_neg(&d, &d);
- mp_tc_div_2d(&a, m, &b);
+ mp_tc_div_2d(&a, em, &b);
if (mp_cmp(&b, &d) != MP_EQ) {
printf("\nmp_tc_div_2d() bad result!");
return EXIT_FAILURE;
@@ -305,22 +305,22 @@ int main(void)
}
/* test mp_tc_xor */
- printf("\n\nTesting: mp_tc_or");
+ printf("\n\nTesting: mp_tc_xor");
for (i = 0; i < 1000; ++i) {
- int l, m;
+ int l, em;
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
mp_set_int(&a, labs(l));
if (l < 0)
mp_neg(&a, &a);
- m = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
- mp_set_int(&b, labs(m));
- if (m < 0)
+ em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
+ mp_set_int(&b, labs(em));
+ if (em < 0)
mp_neg(&b, &b);
- mp_set_int(&d, labs(l ^ m));
- if ((l ^ m) < 0)
+ mp_set_int(&d, labs(l ^ em));
+ if ((l ^ em) < 0)
mp_neg(&d, &d);
mp_tc_xor(&a, &b, &c);
@@ -333,20 +333,20 @@ int main(void)
/* test mp_tc_or */
printf("\n\nTesting: mp_tc_or");
for (i = 0; i < 1000; ++i) {
- int l, m;
+ int l, em;
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
mp_set_int(&a, labs(l));
if (l < 0)
mp_neg(&a, &a);
- m = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
- mp_set_int(&b, labs(m));
- if (m < 0)
+ em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
+ mp_set_int(&b, labs(em));
+ if (em < 0)
mp_neg(&b, &b);
- mp_set_int(&d, labs(l | m));
- if ((l | m) < 0)
+ mp_set_int(&d, labs(l | em));
+ if ((l | em) < 0)
mp_neg(&d, &d);
mp_tc_or(&a, &b, &c);
@@ -359,20 +359,20 @@ int main(void)
/* test mp_tc_and */
printf("\n\nTesting: mp_tc_and");
for (i = 0; i < 1000; ++i) {
- int l, m;
+ int l, em;
l = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
mp_set_int(&a, labs(l));
if (l < 0)
mp_neg(&a, &a);
- m = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
- mp_set_int(&b, labs(m));
- if (m < 0)
+ em = (rand() * rand() + 1) * (rand() % 1 ? -1 : 1);
+ mp_set_int(&b, labs(em));
+ if (em < 0)
mp_neg(&b, &b);
- mp_set_int(&d, labs(l & m));
- if ((l & m) < 0)
+ mp_set_int(&d, labs(l & em));
+ if ((l & em) < 0)
mp_neg(&d, &d);
mp_tc_and(&a, &b, &c);