...
 
Commits (3)
libtommath (1.1.0-3~exp2) experimental; urgency=medium
* add patch to fix m68k builds.
Thanks to Christoph Zurnieden
-- Dominique Dumont <dod@debian.org> Fri, 08 Feb 2019 16:49:35 +0100
libtommath (1.1.0-3~exp1) experimental; urgency=medium
* add patch to fix x32 build issues
......
Description: Fix m68k floats
Date: Thu Feb 7 22:09:06 2019 +0100
.
patch for m86k floats
.
diff --git a/bn_mp_set_double.c b/bn_mp_set_double.c
index 76f6293..ca33af7 100644
Author: czurnieden <czurnieden@gmx.de>
Origin: https://github.com/libtom/libtommath/pull/156
--- a/bn_mp_set_double.c
+++ b/bn_mp_set_double.c
@@ -13,6 +13,7 @@
*/
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
+/* defined by GNU C, SAS/C, and Stratus VOS C -- in that order */
int mp_set_double(mp_int *a, double b)
{
uint64_t frac;
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -166,6 +166,8 @@
unsigned long long q, r;
mp_digit mp;
int i, n, err, should, cnt;
+ double dbl_count;
+
#endif
if (mp_init_multi(&a, &b, &c, &d, &e, &f, NULL)!= MP_OKAY)
@@ -483,6 +485,9 @@
/* test mp_get_double/mp_set_double */
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
printf("\n\nTesting: mp_get_double");
+
+ /*printf(" with a m86k cpu ");*/
+
if (mp_set_double(&a, +1.0/0.0) != MP_VAL) {
printf("\nmp_set_double should return MP_VAL for +inf");
return EXIT_FAILURE;
@@ -500,15 +505,60 @@
return EXIT_FAILURE;
}
+#include <float.h>
+ if (mp_set_double(&a, DBL_MAX) != MP_OKAY) {
+ printf("\nmp_set_double(DBL_MAX) failed");
+ return EXIT_FAILURE;
+ }
+ if (DBL_MAX != mp_get_double(&a)) {
+ printf("\nmp_get_double(DBL_MAX) bad result! %20.2f != %20.2f \n", DBL_MAX, mp_get_double(&a));
+ return EXIT_FAILURE;
+ }
+ if (mp_set_double(&a, DBL_MIN) != MP_OKAY) {
+ printf("\nmp_set_double(DBL_MIN) failed");
+ return EXIT_FAILURE;
+ }
+ if (0.0 != mp_get_double(&a)) {
+ printf("\nmp_get_double(DBL_MIN) bad result! %20.2f != %20.2f \n", DBL_MAX, mp_get_double(&a));
+ return EXIT_FAILURE;
+ }
+
+ dbl_count = 2.0;
+ for (i = 0; i < 301; ++i) {
+ if (mp_set_double(&a, -dbl_count) != MP_OKAY) {
+ printf("\nmp_set_double(dbl_count) failed");
+ return EXIT_FAILURE;
+ }
+ if (-dbl_count != mp_get_double(&a)) {
+ printf("\nmp_get_double(+dbl_count) at i = %d bad result! %20.20f != %20.20f\n",
+ i, -dbl_count, mp_get_double(&a) );
+ return EXIT_FAILURE;
+ }
+ dbl_count = (dbl_count * 2.0);
+ }
+ dbl_count = 2.0;
+ for (i = 0; i < 301; ++i) {
+ if (mp_set_double(&a, -dbl_count) != MP_OKAY) {
+ printf("\nmp_set_double(dbl_count) failed");
+ return EXIT_FAILURE;
+ }
+ if (-dbl_count != mp_get_double(&a)) {
+ printf("\nmp_get_double(+dbl_count) at i = %d bad result! %20.20f != %20.20f\n",
+ i, -dbl_count, mp_get_double(&a) );
+ return EXIT_FAILURE;
+ }
+ dbl_count = (dbl_count * 2.0) -1;
+ }
+
for (i = 0; i < 1000; ++i) {
int tmp = rand();
- double dbl = (double)tmp * rand() + 1;
+ double dbl = (double) tmp * rand() + 1.0;
if (mp_set_double(&a, dbl) != MP_OKAY) {
printf("\nmp_set_double() failed");
return EXIT_FAILURE;
}
if (dbl != mp_get_double(&a)) {
- printf("\nmp_get_double() bad result!");
+ printf("\nmp_get_double() bad result! %20.2f != %20.2f \n", dbl, mp_get_double(&a));
return EXIT_FAILURE;
}
if (mp_set_double(&a, -dbl) != MP_OKAY) {
@@ -516,12 +566,11 @@
return EXIT_FAILURE;
}
if (-dbl != mp_get_double(&a)) {
- printf("\nmp_get_double() bad result!");
+ printf("\nmp_get_double() bad result! %20.2f != %20.2f \n", dbl, mp_get_double(&a));
return EXIT_FAILURE;
}
}
#endif
-
/* test mp_get_int */
printf("\n\nTesting: mp_get_int");
for (i = 0; i < 1000; ++i) {
--- a/bn_mp_get_double.c
+++ b/bn_mp_get_double.c
@@ -24,6 +24,7 @@
}
return (mp_isneg(a) != MP_NO) ? -d : d;
}
+
#endif
/* ref: HEAD -> master, tag: v1.1.0 */
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -95,6 +95,14 @@
_ARCH := $(shell arch)
endif
+#TODO: check for more compilers that support both m68k and something
+# like "-ffloat-store"
+ifeq ($(_ARCH),m68k)
+ ifneq ($(findstring gcc,$(CC)),)
+CFLAGS += -ffloat-store
+ endif
+endif
+
# adjust coverage set
ifneq ($(filter $(_ARCH), i386 i686 x86_64 amd64 ia64),)
COVERAGE = test_standalone timing
......@@ -3,3 +3,4 @@ remove-undefined-macro
fix-shift-count-overflow-on-x32
fix-compilation-and-linkage
x32-relocation
fix-m68k-floats