remove empty dir
[ghc-hetmet.git] / ghc / rts / gmp / mpn / generic / dump.c
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 (C) 1996, 2000 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 the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or (at your
13 option) any later version.
14
15 The GNU MP Library is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18 License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 MA 02111-1307, USA.
24 */
25
26 #include <stdio.h>
27 #include "gmp.h"
28 #include "gmp-impl.h"
29
30 void
31 #if __STDC__
32 mpn_dump (mp_srcptr ptr, mp_size_t size)
33 #else
34 mpn_dump (ptr, size)
35      mp_srcptr ptr;
36      mp_size_t size;
37 #endif
38 {
39   MPN_NORMALIZE (ptr, size);
40
41   if (size == 0)
42     printf ("0\n");
43   else
44     {
45       size--;
46       if (BYTES_PER_MP_LIMB > sizeof (long))
47         {
48           if ((ptr[size] >> BITS_PER_MP_LIMB/2) != 0)
49             {
50               printf ("%lX",
51                       (unsigned long) (ptr[size] >> BITS_PER_MP_LIMB/2));
52               printf ("%0*lX", (int) (BYTES_PER_MP_LIMB),
53                       (unsigned long) ptr[size]);
54             }
55           else
56             printf ("%lX", (unsigned long) ptr[size]);
57         }
58       else
59         printf ("%lX", ptr[size]);
60
61       while (size)
62         {
63           size--;
64           if (BYTES_PER_MP_LIMB > sizeof (long))
65             {
66               printf ("%0*lX", (int) (BYTES_PER_MP_LIMB),
67                 (unsigned long) (ptr[size] >> BITS_PER_MP_LIMB/2));
68               printf ("%0*lX", (int) (BYTES_PER_MP_LIMB),
69                 (unsigned long) ptr[size]);
70             }
71           else
72             printf ("%0*lX", (int) (2 * BYTES_PER_MP_LIMB), ptr[size]);
73         }
74       printf ("\n");
75     }
76 }