~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpn/generic/dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, 2001, 2002 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
#if GMP_NUMB_BITS % 4 == 0
 
31
void
 
32
mpn_dump (mp_srcptr ptr, mp_size_t n)
 
33
{
 
34
  MPN_NORMALIZE (ptr, n);
 
35
 
 
36
  if (n == 0)
 
37
    printf ("0\n");
 
38
  else
 
39
    {
 
40
      n--;
 
41
#if _LONG_LONG_LIMB
 
42
      if ((ptr[n] >> GMP_LIMB_BITS / 2) != 0)
 
43
        {
 
44
          printf ("%lX", (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2));
 
45
          printf ("%0*lX", (GMP_LIMB_BITS / 2 / 4), (unsigned long) ptr[n]);
 
46
        }
 
47
      else
 
48
#endif
 
49
        printf ("%lX", (unsigned long) ptr[n]);
 
50
 
 
51
      while (n)
 
52
        {
 
53
          n--;
 
54
#if _LONG_LONG_LIMB
 
55
          printf ("%0*lX", (GMP_NUMB_BITS - GMP_LIMB_BITS / 2) / 4,
 
56
                  (unsigned long) (ptr[n] >> GMP_LIMB_BITS / 2));
 
57
          printf ("%0*lX", GMP_LIMB_BITS / 2 / 4, (unsigned long) ptr[n]);
 
58
#else
 
59
          printf ("%0*lX", GMP_NUMB_BITS / 4, (unsigned long) ptr[n]);
 
60
#endif
 
61
        }
 
62
      printf ("\n");
 
63
    }
 
64
}
 
65
 
 
66
#else
 
67
 
 
68
static void
 
69
mpn_recdump (mp_ptr p, mp_size_t n)
 
70
{
 
71
  mp_limb_t lo;
 
72
  if (n != 0)
 
73
    {
 
74
      lo = p[0] & 0xf;
 
75
      mpn_rshift (p, p, n, 4);
 
76
      mpn_recdump (p, n);
 
77
      printf ("%lX", lo);
 
78
    }
 
79
}
 
80
 
 
81
void
 
82
mpn_dump (mp_srcptr p, mp_size_t n)
 
83
{
 
84
  mp_ptr tp;
 
85
  TMP_DECL (marker);
 
86
  TMP_MARK (marker);
 
87
  tp = TMP_ALLOC_LIMBS (n);
 
88
  MPN_COPY (tp, p, n);
 
89
  TMP_FREE (marker);
 
90
}
 
91
 
 
92
#endif