Skip to content

Commit

Permalink
Switched test code over to use bsdnt_printf.
Browse files Browse the repository at this point in the history
  • Loading branch information
William Hart committed Nov 11, 2010
1 parent 9cabe32 commit 31dc588
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 51 deletions.
11 changes: 9 additions & 2 deletions helper.c
Expand Up @@ -126,8 +126,15 @@ void bsdnt_printf(const char * str, ...)
{ {
case 'w': case 'w':
w = (word_t) va_arg(ap, word_t); w = (word_t) va_arg(ap, word_t);
printf(WORD_FMT, w); if (str[2] == 'x')
printf(str2 + 2); {
printf(WORD_FMT "x", w);
printf(str2 + 3);
} else
{
printf(WORD_FMT "d", w);
printf(str2 + 2);
}
break; break;
case 'b': case 'b':
b = (bits_t) va_arg(ap, bits_t); b = (bits_t) va_arg(ap, bits_t);
Expand Down
8 changes: 4 additions & 4 deletions helper.h
Expand Up @@ -45,7 +45,7 @@ typedef int32_t len_t;
typedef int32_t bits_t; typedef int32_t bits_t;
#define WORD_BITS 32 #define WORD_BITS 32
#define WORD(x) (x##UL) #define WORD(x) (x##UL)
#define WORD_FMT "%lu" #define WORD_FMT "%l"
#define LEN_FMT "%ld" #define LEN_FMT "%ld"
#define BITS_FMT "%ld" #define BITS_FMT "%ld"


Expand All @@ -57,7 +57,7 @@ typedef int64_t len_t;
typedef int64_t bits_t; typedef int64_t bits_t;
#define WORD_BITS 64 #define WORD_BITS 64
#define WORD(x) (x##UL) #define WORD(x) (x##UL)
#define WORD_FMT "%lu" #define WORD_FMT "%l"
#define LEN_FMT "%ld" #define LEN_FMT "%ld"
#define BITS_FMT "%ld" #define BITS_FMT "%ld"


Expand All @@ -76,13 +76,13 @@ typedef const word_t * nn_src_t;


typedef struct preinv1_t typedef struct preinv1_t
{ {
word_t norm; /* the number of leading zero bits in d */ bits_t norm; /* the number of leading zero bits in d */
word_t dinv; /* the precomputed inverse of d (see below) */ word_t dinv; /* the precomputed inverse of d (see below) */
} preinv1_t; } preinv1_t;


typedef struct preinv1_2_t typedef struct preinv1_2_t
{ {
word_t norm; /* the number of leading zero bits in d */ bits_t norm; /* the number of leading zero bits in d */
word_t dinv; /* the precomputed inverse of d1 (see below) */ word_t dinv; /* the precomputed inverse of d1 (see below) */
word_t d1; /* the normalised leading WORD_BITS of d */ word_t d1; /* the normalised leading WORD_BITS of d */
} preinv1_2_t; } preinv1_2_t;
Expand Down
78 changes: 39 additions & 39 deletions test/t-nn_linear.c
Expand Up @@ -71,7 +71,7 @@ int test_bit_set(void)


if (!result) if (!result)
{ {
printf("bit = %ld\n", bit); bsdnt_printf("bit = %b\n", bit);
print_debug(a, m); print_debug(a, m);
} }
} TEST_END; } TEST_END;
Expand All @@ -92,7 +92,7 @@ int test_bit_set(void)


if (!result) if (!result)
{ {
printf("bit = %ld, sh1 = %ld\n", bit, sh1); bsdnt_printf("bit = %b, sh1 = %b\n", bit, sh1);
print_debug(a, m); print_debug(a, m);
} }
} TEST_END; } TEST_END;
Expand Down Expand Up @@ -123,7 +123,7 @@ int test_bit_clear(void)


if (!result) if (!result)
{ {
printf("bit = %ld\n", bit); bsdnt_printf("bit = %b\n", bit);
print_debug(a, m); print_debug(a, m);
} }
} TEST_END; } TEST_END;
Expand All @@ -144,7 +144,7 @@ int test_bit_clear(void)


if (!result) if (!result)
{ {
printf("bit = %ld, sh1 = %ld\n", bit, sh1); bsdnt_printf("bit = %b, sh1 = %b\n", bit, sh1);
print_debug(a, m); print_debug(a, m);
} }
} TEST_END; } TEST_END;
Expand Down Expand Up @@ -201,7 +201,7 @@ int test_add_m(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld\n", m, n); bsdnt_printf("m = %m n = %m\n", m, n);
print_debug(a, m + n); print_debug(b, m + n); print_debug(a, m + n); print_debug(b, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -263,7 +263,7 @@ int test_add(void)


if (!result) if (!result)
{ {
printf("m1 = %ld, m2 = %ld, m3 = %ld\n", m1, m2, m3); bsdnt_printf("m1 = %m, m2 = %m, m3 = %m\n", m1, m2, m3);
print_debug(a, m1 + m2 + m3); print_debug(b, m2 + m3); print_debug(a, m1 + m2 + m3); print_debug(b, m2 + m3);
print_debug_diff(r1, r2, m1 + m2 + m3 + 1); print_debug_diff(r1, r2, m1 + m2 + m3 + 1);
} }
Expand Down Expand Up @@ -321,7 +321,7 @@ int test_sub_m(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld\n", m, n); bsdnt_printf("m = %m, n = %m\n", m, n);
print_debug(a, m + n); print_debug(b, m + n); print_debug(a, m + n); print_debug(b, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand All @@ -344,7 +344,7 @@ int test_sub_m(void)
{ {
print_debug(a, m); print_debug(b, m); print_debug(a, m); print_debug(b, m);
print_debug_diff(r1, a, m); print_debug_diff(r1, a, m);
printf("r1[m] = "); printx_word(r1[m]); printf("\n"); bsdnt_printf("r1[%m] = %wx\n", m, r1[m]);
} }
} TEST_END; } TEST_END;


Expand Down Expand Up @@ -426,7 +426,7 @@ int test_sub(void)


if (!result) if (!result)
{ {
printf("m1 = %ld, m2 = %ld, m3 = %ld\n", m1, m2, m3); bsdnt_printf("m1 = %m, m2 = %m, m3 = %m\n", m1, m2, m3);
print_debug(a, m1 + m2 + m3); print_debug(b, m2 + m3); print_debug(a, m1 + m2 + m3); print_debug(b, m2 + m3);
print_debug_diff(r1, r2, m1 + m2 + m3 + 1); print_debug_diff(r1, r2, m1 + m2 + m3 + 1);
} }
Expand Down Expand Up @@ -465,7 +465,7 @@ int test_shl(void)


if (!result) if (!result)
{ {
printf("m = %ld, sh1 = %ld, sh2 = %ld\n", m, sh1, sh2); bsdnt_printf("m = %m, sh1 = %b, sh2 = %b\n", m, sh1, sh2);
print_debug(a, m); print_debug(a, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -489,7 +489,7 @@ int test_shl(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, sh1 = %ld\n", m, n, sh1); bsdnt_printf("m = %m, n = %m, sh1 = %b\n", m, n, sh1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -570,7 +570,7 @@ int test_shr(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, sh1 = %ld\n", m, n, sh1); bsdnt_printf("m = %m, n = %m, sh1 = %b\n", m, n, sh1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand All @@ -593,7 +593,7 @@ int test_shr(void)


if (!result) if (!result)
{ {
printf("m = %ld, sh1 = %ld\n", m, sh1); bsdnt_printf("m = %m, sh1 = %b\n", m, sh1);
print_debug(a, m); print_debug(r1, m + 1); print_debug(a, m); print_debug(r1, m + 1);
print_debug_diff(a, r2, m); print_debug_diff(a, r2, m);
} }
Expand Down Expand Up @@ -760,7 +760,7 @@ int test_zero(void)
int test_normalise(void) int test_normalise(void)
{ {
int result = 1; int result = 1;
long s1, s2; len_t s1, s2;
nn_t a, r1; nn_t a, r1;
len_t m; len_t m;


Expand All @@ -785,7 +785,7 @@ int test_normalise(void)


if (!result) if (!result)
{ {
printf("m = %ld, s1 = %ld, s2 = %ld\n", m, s1, s2); bsdnt_printf("m = %m, s1 = %m, s2 = %m\n", m, s1, s2);
print_debug(r1, m); print_debug(a, m); print_debug(r1, m); print_debug(a, m);
print_debug_diff(r1, a, m); print_debug_diff(r1, a, m);
} }
Expand Down Expand Up @@ -824,7 +824,7 @@ int test_mul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(t1, m + 1); print_debug(a, m); print_debug(t1, m + 1);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -849,7 +849,7 @@ int test_mul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -890,7 +890,7 @@ int test_addmul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(b, m); print_debug(a, m); print_debug(b, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -917,7 +917,7 @@ int test_addmul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -959,7 +959,7 @@ int test_muladd1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(b, m); print_debug(a, m); print_debug(b, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand Down Expand Up @@ -987,7 +987,7 @@ int test_muladd1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(t1, m + n); print_debug(t2, m + n); print_debug(a, m + n); print_debug(t1, m + n); print_debug(t2, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -1028,7 +1028,7 @@ int test_submul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(b, m); print_debug(a, m); print_debug(b, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -1055,7 +1055,7 @@ int test_submul1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -1093,7 +1093,7 @@ int test_add1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(a, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -1118,7 +1118,7 @@ int test_add1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -1156,7 +1156,7 @@ int test_sub1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx, c2 = %lx\n", m, c1, c2); bsdnt_printf("m = %m, c1 = %wx, c2 = %wx\n", m, c1, c2);
print_debug(a, m); print_debug(a, m);
print_debug_diff(r1, r2, m + 1); print_debug_diff(r1, r2, m + 1);
} }
Expand All @@ -1181,7 +1181,7 @@ int test_sub1(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld, c1 = %lx\n", m, n, c1); bsdnt_printf("m = %m, n = %m, c1 = %wx\n", m, n, c1);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand All @@ -1204,7 +1204,7 @@ int test_sub1(void)


if (!result) if (!result)
{ {
printf("m = %ld, c1 = %lx\n", m, c1); bsdnt_printf("m = %m, c1 = %wx\n", m, c1);
print_debug(a, m + 1); print_debug(a, m + 1);
print_debug_diff(r1, a, m + 1); print_debug_diff(r1, a, m + 1);
} }
Expand Down Expand Up @@ -1292,7 +1292,7 @@ int test_neg(void)


if (!result) if (!result)
{ {
printf("m = %ld, n = %ld\n", m, n); bsdnt_printf("m = %m, n = %m\n", m, n);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n + 1); print_debug_diff(r1, r2, m + n + 1);
} }
Expand Down Expand Up @@ -1444,7 +1444,7 @@ int test_divrem1_simple(void)


if (!result) if (!result)
{ {
printf("ci = %lx, d = %lx\n", ci, d); bsdnt_printf("ci = %wx, d = %wx\n", ci, d);
print_debug(a, m); print_debug(q, m); print_debug(r1, m); print_debug(a, m); print_debug(q, m); print_debug(r1, m);
print_debug_diff(r1, a, m); print_debug_diff(r1, a, m);
} }
Expand All @@ -1469,7 +1469,7 @@ int test_divrem1_simple(void)


if (!result) if (!result)
{ {
printf("ci = %lx, d = %lx, m = %ld, n = %ld\n", ci, d, m, n); bsdnt_printf("ci = %wx, d = %wx, m = %m, n = %m\n", ci, d, m, n);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n); print_debug_diff(r1, r2, m + n);
} }
Expand Down Expand Up @@ -1507,7 +1507,7 @@ int test_divrem1_preinv(void)


if (!result) if (!result)
{ {
printf("ci = %lx, r = %lx\n", ci, r); bsdnt_printf("ci = %wx, r = %wx\n", ci, r);
print_debug(a, m); print_debug(q, m); print_debug(a, m); print_debug(q, m);
print_debug_diff(r1, a, m); print_debug_diff(r1, a, m);
} }
Expand Down Expand Up @@ -1542,7 +1542,7 @@ int test_divrem1_preinv(void)


if (!result) if (!result)
{ {
printf("ci = %lx, rem1 = %lx, rem2 = %lx, m = %ld, n = %ld\n", bsdnt_printf("ci = %wx, rem1 = %wx, rem2 = %wx, m = %m, n = %m\n",
ci, rem1, rem2, m, n); ci, rem1, rem2, m, n);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n); print_debug_diff(r1, r2, m + n);
Expand Down Expand Up @@ -1581,7 +1581,7 @@ int test_divrem_hensel1_preinv(void)


if (!result) if (!result)
{ {
printf("ci = %lx, r = %lx\n, inv = %lx", ci, r, inv); bsdnt_printf("ci = %wx, r = %wx\n, inv = %wx", ci, r, inv);
print_debug(a, m); print_debug(q, m); print_debug(a, m); print_debug(q, m);
print_debug_diff(r1, a, m); print_debug_diff(r1, a, m);
} }
Expand All @@ -1606,7 +1606,7 @@ int test_divrem_hensel1_preinv(void)


if (!result) if (!result)
{ {
printf("ci = %lx, rem1 = %lx, rem2 = %lx, m = %ld, n = %ld, d = %lx, inv = %lx\n", bsdnt_printf("ci = %wx, rem1 = %wx, rem2 = %wx, m = %m, n = %m, d = %wx, inv = %wx\n",
ci, rem1, rem2, m, n, d, inv); ci, rem1, rem2, m, n, d, inv);
print_debug(a, m + n); print_debug(a, m + n);
print_debug_diff(r1, r2, m + n); print_debug_diff(r1, r2, m + n);
Expand Down Expand Up @@ -1646,8 +1646,8 @@ int test_mod1_preinv(void)


if (!result) if (!result)
{ {
printf("rem1 = %lx, rem2 = %lx, m = %ld, d = %lx, " bsdnt_printf("rem1 = %wx, rem2 = %wx, m = %m, d = %wx, "
"minv.b1 = %lx, minv.b2 = %lx, minv.b3 = %lx\n", "minv.b1 = %wx, minv.b2 = %wx, minv.b3 = %wx\n",
rem1, rem2, m, d, minv.b1, minv.b2, minv.b3); rem1, rem2, m, d, minv.b1, minv.b2, minv.b3);
print_debug(a, m); print_debug(q, m); print_debug(a, m); print_debug(q, m);
} }
Expand All @@ -1672,8 +1672,8 @@ int test_mod1_preinv(void)


if (!result) if (!result)
{ {
printf("ci = %lx, rem1 = %lx, rem2 = %lx, m = %ld, n = %ld, d = %lx, " bsdnt_printf("ci = %wx, rem1 = %wx, rem2 = %wx, m = %m, n = %m, d = %wx, "
"minv.b1 = %lx, minv.b2 = %lx, minv.b3 = %lx\n", "minv.b1 = %wx, minv.b2 = %wx, minv.b3 = %wx\n",
ci, rem1, rem2, m, n, d, minv.b1, minv.b2, minv.b3); ci, rem1, rem2, m, n, d, minv.b1, minv.b2, minv.b3);
print_debug(a, m + n); print_debug(a, m + n);
} }
Expand Down

0 comments on commit 31dc588

Please sign in to comment.