diff options
author | tege <tege@gmplib.org> | 2002-05-17 16:10:57 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 2002-05-17 16:10:57 +0200 |
commit | da2a8bee0aff5690ef1120e3feda650d21d50fb6 (patch) | |
tree | 7c27c936973b0de0ba449a32311c90e366a9a069 | |
parent | 9e2929f6f6cebfa12d42c51eb75a04a104e87ad4 (diff) | |
download | gmp-da2a8bee0aff5690ef1120e3feda650d21d50fb6.tar.gz |
Rewrite and nailify.
-rw-r--r-- | mpn/generic/dump.c | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/mpn/generic/dump.c b/mpn/generic/dump.c index 8e68ad37c..377ef4480 100644 --- a/mpn/generic/dump.c +++ b/mpn/generic/dump.c @@ -27,45 +27,66 @@ MA 02111-1307, USA. #include "gmp.h" #include "gmp-impl.h" +#if GMP_NUMB_BITS % 4 == 0 void -mpn_dump (mp_srcptr ptr, mp_size_t size) +mpn_dump (mp_srcptr ptr, mp_size_t n) { - MPN_NORMALIZE (ptr, size); + MPN_NORMALIZE (ptr, n); - if (size == 0) + if (n == 0) printf ("0\n"); else { - size--; - if (BYTES_PER_MP_LIMB > sizeof (long)) + n--; +#if _LONG_LONG_LIMB + if ((ptr[n] >> GMP_LIMB_BITS / 2) != 0) { - if ((ptr[size] >> BITS_PER_MP_LIMB/2) != 0) - { - printf ("%lX", - (unsigned long) (ptr[size] >> BITS_PER_MP_LIMB/2)); - printf ("%0*lX", (int) (BYTES_PER_MP_LIMB), - (unsigned long) ptr[size]); - } - else - printf ("%lX", (unsigned long) ptr[size]); + printf ("%lX", (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2)); + printf ("%0*lX", (GMP_LIMB_BITS / 2 / 4), (unsigned long) ptr[n]); } else - printf ("%lX", (unsigned long) ptr[size]); +#endif + printf ("%lX", (unsigned long) ptr[n]); - while (size) + while (n) { - size--; - if (BYTES_PER_MP_LIMB > sizeof (long)) - { - printf ("%0*lX", (int) (BYTES_PER_MP_LIMB), - (unsigned long) (ptr[size] >> BITS_PER_MP_LIMB/2)); - printf ("%0*lX", (int) (BYTES_PER_MP_LIMB), - (unsigned long) ptr[size]); - } - else - printf ("%0*lX", (int) (2 * BYTES_PER_MP_LIMB), - (unsigned long) ptr[size]); + n--; +#if _LONG_LONG_LIMB + printf ("%0*lX", (GMP_NUMB_BITS - GMP_LIMB_BITS / 2) / 4, + (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2)); + printf ("%0*lX", GMP_LIMB_BITS / 2 / 4, (unsigned long) ptr[n]); +#else + printf ("%0*lX", GMP_NUMB_BITS / 4, (unsigned long) ptr[n]); +#endif } printf ("\n"); } } + +#else + +static void +mpn_recdump (mp_ptr p, mp_size_t n) +{ + mp_limb_t lo; + if (n != 0) + { + lo = p[0] & 0xf; + mpn_rshift (p, p, n, 4); + mpn_recdump (p, n); + printf ("%lX", lo); + } +} + +void +mpn_dump (mp_srcptr p, mp_size_t n) +{ + mp_ptr tp; + TMP_DECL (marker); + TMP_MARK (marker); + tp = TMP_ALLOC_LIMBS (n); + MPN_COPY (tp, p, n); + TMP_FREE (marker); +} + +#endif |