1 /* THIS IS AN INTERNAL FUNCTION WITH A MUTABLE INTERFACE. IT IS NOT SAFE TO
2 CALL THIS FUNCTION DIRECTLY. IN FACT, IT IS ALMOST GUARANTEED THAT THIS
3 FUNCTION WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
4
5
6 Copyright 1996, 2000-2002, 2005 Free Software Foundation, Inc.
7
8 This file is part of the GNU MP Library.
9
10 The GNU MP Library is free software; you can redistribute it and/or modify
11 it under the terms of either:
12
13 * the GNU Lesser General Public License as published by the Free
14 Software Foundation; either version 3 of the License, or (at your
15 option) any later version.
16
17 or
18
19 * the GNU General Public License as published by the Free Software
20 Foundation; either version 2 of the License, or (at your option) any
21 later version.
22
23 or both in parallel, as here.
24
25 The GNU MP Library is distributed in the hope that it will be useful, but
26 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 for more details.
29
30 You should have received copies of the GNU General Public License and the
31 GNU Lesser General Public License along with the GNU MP Library. If not,
32 see https://www.gnu.org/licenses/. */
33
34 #include <stdio.h>
35 #include "gmp-impl.h"
36
37 #if GMP_NUMB_BITS % 4 == 0
38 void
mpn_dump(mp_srcptr ptr,mp_size_t n)39 mpn_dump (mp_srcptr ptr, mp_size_t n)
40 {
41 MPN_NORMALIZE (ptr, n);
42
43 if (n == 0)
44 printf ("0\n");
45 else
46 {
47 n--;
48 #if _LONG_LONG_LIMB
49 if ((ptr[n] >> GMP_LIMB_BITS / 2) != 0)
50 {
51 printf ("%lX", (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2));
52 printf ("%0*lX", (GMP_LIMB_BITS / 2 / 4), (unsigned long) ptr[n]);
53 }
54 else
55 #endif
56 printf ("%lX", (unsigned long) ptr[n]);
57
58 while (n)
59 {
60 n--;
61 #if _LONG_LONG_LIMB
62 printf ("%0*lX", (GMP_NUMB_BITS - GMP_LIMB_BITS / 2) / 4,
63 (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2));
64 printf ("%0*lX", GMP_LIMB_BITS / 2 / 4, (unsigned long) ptr[n]);
65 #else
66 printf ("%0*lX", GMP_NUMB_BITS / 4, (unsigned long) ptr[n]);
67 #endif
68 }
69 printf ("\n");
70 }
71 }
72
73 #else
74
75 static void
mpn_recdump(mp_ptr p,mp_size_t n)76 mpn_recdump (mp_ptr p, mp_size_t n)
77 {
78 mp_limb_t lo;
79 if (n != 0)
80 {
81 lo = p[0] & 0xf;
82 mpn_rshift (p, p, n, 4);
83 mpn_recdump (p, n);
84 printf ("%lX", lo);
85 }
86 }
87
88 void
mpn_dump(mp_srcptr p,mp_size_t n)89 mpn_dump (mp_srcptr p, mp_size_t n)
90 {
91 mp_ptr tp;
92 TMP_DECL;
93 TMP_MARK;
94 tp = TMP_ALLOC_LIMBS (n);
95 MPN_COPY (tp, p, n);
96 TMP_FREE;
97 }
98
99 #endif
100